Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if 'formula' in dct[species] and dct[species]['formula'] is not None:
try:
dct[species]['mol'].res = res # sets resolution in Molecule object
except NameError:
res = int(mzml.auto_resolution())
dct[species]['mol'].res = res
# dct[species]['mol'].sigma = dct[species]['mol'].sigmafwhm()[1] # recalculates sigma with new resolution
dct[species]['bounds'] = dct[species]['mol'].bounds # caclulates bounds
return dct
# ----------------------------------------------------------
# -------------------PROGRAM BEGINS-------------------------
# ----------------------------------------------------------
if verbose is True:
stime = ScriptTime()
stime.printstart()
n = check_integer(n, 'number of scans to sum') # checks integer input and converts to list
if type(xlsx) != dict:
if verbose is True:
sys.stdout.write('Loading processing parameters from excel file')
sys.stdout.flush()
xlfile = XLSX(xlsx, verbose=verbose)
sp = xlfile.pullrsimparams()
else: # if parameters were provided in place of an excel file
sp = xlsx
mskeys = ['+', '-']
for key in sp:
if 'formula' in sp[key] and sp[key]['formula'] is not None: # if formula is specified
abbrv_spec.loader.exec_module(abbrv_module)
user_abbrvs = abbrv_module.user_abbrvs
abbrvs.update(user_abbrvs)
except FileNotFoundError: # if it can't find the file, continue with default abbreviations
pass
"""Mass dictionary associated with the instance"""
MASS_KEY = 'crc_mass'
mass_dict = getattr(
mass_dictionaries,
MASS_KEY,
)
st = ScriptTime(profile=True)
# valid start and end brackets
OPENING_BRACKETS = ['(', '{', '['] # opening brackets
CLOSING_BRACKETS = [')', '}', ']'] # closing brackets
SIGNS = ['+', '-'] # charge signs
VERBOSE = False # toggle for verbose
# valid grouping methods
VALID_GROUP_METHODS = [
'weighted',
'centroid',
]
# valid isotope pattern generation methods
VALID_IPMETHODS = [
'combinatorics',
'multiplicative',
def bin_spectra(filename, start=None, end=None, save=True, dec=3):
"""
Sums spectra from raw file and outputs to excel file
:param filename: raw or mzML filename
:param start: start scan (None will default to 1)
:param end: end scan (None will default to the last scan)
:param save: whether to save into an excel document (if a string is provided, that filename will be used)
:param dec: decimal places to track when binning the spectrum
:return: paired x, summed y lists
"""
st = ScriptTime()
st.printstart()
mzml = mzML(filename) # create mzML object
if start is None:
start = mzml.functions[1]['sr'][0] + 1
if end is None:
end = mzml.functions[1]['sr'][1] + 1
x, y = mzml.sum_scans(
start=start,
end=end,
dec=dec,
)
if save is not False:
if type(save) == str: # if a filename was provided for the Excel file
xlfile = XLSX(save, create=True)
else: # otherwise use the mzML filename
xlfile = XLSX(filename, create=True)
self.profiles[fn.__name__][1].append(elapsed_time)
return ret # returns the calculated call of the function
if self.profile is True:
return with_profiling # returns the decorated function
else:
return fn
def triggerend(self):
"""triggers endpoint and calculates elapsed time since start"""
self._end_seconds = time.time()
self._end_clock = time.localtime()
if __name__ == '__main__':
st = ScriptTime()
time.sleep(2.)
st.triggerend()
st.printend()