text
stringlengths 0
828
|
---|
if not self.compound_info['inchikey_id'] in self.compound_ids: |
self.compound_info_all.append(tuple(self.compound_info.values()) + ( |
str(datetime.datetime.now()), |
str(datetime.datetime.now()), |
)) |
self.compound_ids.append(self.compound_info['inchikey_id'])" |
161,"def _store_meta_info(self): |
""""""Update the meta dictionary with the current chunk of meta data details |
"""""" |
# In the mass bank msp files, sometimes the precursor_mz is missing but we have the neutral mass and |
# the precursor_type (e.g. adduct) so we can calculate the precursor_mz |
if not self.meta_info['precursor_mz'] and self.meta_info['precursor_type'] and \ |
self.compound_info['exact_mass']: |
self.meta_info['precursor_mz'] = get_precursor_mz(float(self.compound_info['exact_mass']), |
self.meta_info['precursor_type']) |
if not self.meta_info['polarity']: |
# have to do special check for polarity (as sometimes gets missed) |
m = re.search('^\[.*\](\-|\+)', self.meta_info['precursor_type'], re.IGNORECASE) |
if m: |
polarity = m.group(1).strip() |
if polarity == '+': |
self.meta_info['polarity'] = 'positive' |
elif polarity == '-': |
self.meta_info['polarity'] = 'negative' |
if not self.meta_info['accession']: |
self.meta_info['accession'] = 'unknown accession' |
self.meta_info_all.append( |
(str(self.current_id_meta),) + |
tuple(self.meta_info.values()) + |
(str(self.current_id_origin), self.compound_info['inchikey_id'],) |
)" |
162,"def _parse_spectra_annotation(self, line): |
""""""Parse and store the spectral annotation details |
"""""" |
if re.match('^PK\$NUM_PEAK(.*)', line, re.IGNORECASE): |
self.start_spectra_annotation = False |
return |
saplist = line.split() |
sarow = ( |
self.current_id_spectra_annotation, |
float(saplist[self.spectra_annotation_indexes['m/z']]) if 'm/z' in self.spectra_annotation_indexes else None, |
saplist[self.spectra_annotation_indexes[ |
'tentative_formula']] if 'tentative_formula' in self.spectra_annotation_indexes else None, |
float(saplist[self.spectra_annotation_indexes[ |
'mass_error(ppm)']]) if 'mass_error(ppm)' in self.spectra_annotation_indexes else None, |
self.current_id_meta) |
self.spectra_annotation_all.append(sarow) |
self.current_id_spectra_annotation += 1" |
163,"def _parse_spectra(self, line): |
""""""Parse and store the spectral details |
"""""" |
if line in ['\n', '\r\n', '//\n', '//\r\n', '', '//']: |
self.start_spectra = False |
self.current_id_meta += 1 |
self.collect_meta = True |
return |
splist = line.split() |
if len(splist) > 2 and not self.ignore_additional_spectra_info: |
additional_info = ''.join(map(str, splist[2:len(splist)])) |
else: |
additional_info = '' |
srow = ( |
self.current_id_spectra, float(splist[0]), float(splist[1]), additional_info, |
self.current_id_meta) |
self.spectra_all.append(srow) |
self.current_id_spectra += 1" |
164,"def _set_inchi_pcc(self, in_str, pcp_type, elem): |
""""""Check pubchem compounds via API for both an inchikey and any available compound details |
"""""" |
if not in_str: |
return 0 |
try: |
pccs = pcp.get_compounds(in_str, pcp_type) |
except pcp.BadRequestError as e: |
print(e) |
return 0 |
except pcp.TimeoutError as e: |
print(e) |
return 0 |
except pcp.ServerError as e: |
print(e) |
return 0 |
except URLError as e: |
print(e) |
return 0 |
except BadStatusLine as e: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.