Skip to content

Commit

Permalink
Merge pull request #81 from michaelmarty/v3
Browse files Browse the repository at this point in the history
V3
  • Loading branch information
michaelmarty authored Mar 13, 2023
2 parents 6c108d2 + d852d4d commit ecef9b3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ UPP Changes:
* Added ability to select files to load to UPP.
* Added "Global Fixed Mod" to apply the same float value to each pair.
* Special Bispecific Antibody Pairing Calculations (see Help File)
* Fixex issues bugs with use_converted, clear all, and resetting the config.
* Fixed issues bugs with use_converted, clear all, and resetting the config.

Fixed major bugs with 2D zooming and plotting.

Expand Down
26 changes: 22 additions & 4 deletions unidec/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ def check_for_value(row, key, correcttypetuple):
return False


def check_for_floatable(row, key):
try:
val = float(row[key])
if math.isnan(val):
return False
return True
except Exception as e:
return False


def get_time_range(row):
# Look for the time range
starttime = 0
Expand Down Expand Up @@ -255,6 +265,7 @@ def __init__(self):
self.fmodfile = None
self.vmoddf = None
self.fmoddf = None
self.autopw = True
self.correct_pair_mode = False
self.time_range = None

Expand Down Expand Up @@ -286,6 +297,7 @@ def run_df(self, df=None, decon=True, use_converted=True, interactive=False):

# Loop through the DataFrame
for i, row in self.rundf.iterrows():
self.autopw = True
self.eng.reset_config()
path = self.get_file_path(row, use_converted=use_converted)

Expand All @@ -299,10 +311,13 @@ def run_df(self, df=None, decon=True, use_converted=True, interactive=False):
print("Refreshing")
self.eng.open_file(path, time_range=self.time_range, refresh=not use_converted, silent=True)

# If the config file is specified, load it
if "Config File" in row:
try:
self.eng.load_config(row["Config File"])
print("Loaded Config File:", row["Config File"])
# If a config file is loaded, it will not use the auto peak width
self.autopw = False
except Exception as e:
print("Error loading config file", row["Config File"], e)

Expand All @@ -311,9 +326,11 @@ def run_df(self, df=None, decon=True, use_converted=True, interactive=False):

# Run the deconvolution or import the prior deconvolution results
if decon:
autopw = not check_for_value(row, "Config m/z Peak FWHM", (float, int))
print("Auto Peak Width", autopw)
self.eng.autorun(auto_peak_width=autopw, silent=True)
# If the Config m/z Peak FWHM is specified, do not use the auto peak width
if "Config m/z Peak FWHM" in row:
self.autopw = not check_for_floatable(row, "Config m/z Peak FWHM")
print("Auto Peak Width", self.autopw)
self.eng.autorun(auto_peak_width=self.autopw, silent=True)
else:
self.eng.unidec_imports(efficiency=False)
self.eng.pick_peaks()
Expand Down Expand Up @@ -367,7 +384,7 @@ def get_file_path(self, row, use_converted=True):
if "Data Directory" in row:
data_dir = row["Data Directory"]
# print(data_dir, os.path.isdir(data_dir), os.getcwd())
if os.path.isdir(data_dir):
if os.path.isdir(str(data_dir)):
self.data_dir = data_dir
# Find the file
outpath = find_file(file, self.data_dir, use_converted)
Expand Down Expand Up @@ -422,6 +439,7 @@ def run_correct_pair(self, row, pks=None):
path = "C:\\Data\\Wilson_Genentech\\BsAb\\BsAb test short.xlsx"
# path = "C:\\Data\\Wilson_Genentech\\BsAb\\BsAb test.xlsx"
# path = "C:\\Data\\Wilson_Genentech\\BsAb\\test2.csv"
path = "C:\\Data\\Wilson_Genentech\\Test\\BsAb test v2.xlsx"
pd.set_option('display.max_columns', None)
batch.run_file(path, decon=True, use_converted=True, interactive=False)

Expand Down

0 comments on commit ecef9b3

Please sign in to comment.