text
stringlengths 0
828
|
---|
print(e) |
return 0 |
if pccs: |
pcc = pccs[elem] |
self.compound_info['inchikey_id'] = pcc.inchikey |
self.compound_info['pubchem_id'] = pcc.cid |
self.compound_info['molecular_formula'] = pcc.molecular_formula |
self.compound_info['molecular_weight'] = pcc.molecular_weight |
self.compound_info['exact_mass'] = pcc.exact_mass |
self.compound_info['smiles'] = pcc.canonical_smiles |
if len(pccs) > 1: |
print('WARNING, multiple compounds for ', self.compound_info)" |
165,"def _get_other_names(self, line): |
""""""Parse and extract any other names that might be recorded for the compound |
Args: |
line (str): line of the msp file |
"""""" |
m = re.search(self.compound_regex['other_names'][0], line, re.IGNORECASE) |
if m: |
self.other_names.append(m.group(1).strip())" |
166,"def _parse_meta_info(self, line): |
""""""Parse and extract all meta data by looping through the dictionary of meta_info regexs |
updates self.meta_info |
Args: |
line (str): line of the msp file |
"""""" |
if self.mslevel: |
self.meta_info['ms_level'] = self.mslevel |
if self.polarity: |
self.meta_info['polarity'] = self.polarity |
for k, regexes in six.iteritems(self.meta_regex): |
for reg in regexes: |
m = re.search(reg, line, re.IGNORECASE) |
if m: |
self.meta_info[k] = m.group(1).strip()" |
167,"def _parse_compound_info(self, line): |
""""""Parse and extract all compound data by looping through the dictionary of compound_info regexs |
updates self.compound_info |
Args: |
line (str): line of the msp file |
"""""" |
for k, regexes in six.iteritems(self.compound_regex): |
for reg in regexes: |
if self.compound_info[k]: |
continue |
m = re.search(reg, line, re.IGNORECASE) |
if m: |
self.compound_info[k] = m.group(1).strip() |
self._get_other_names(line)" |
168,"def insert_data(self, remove_data=False, db_type='sqlite'): |
""""""Insert data stored in the current chunk of parsing into the selected database |
Args: |
remove_data (boolean): Remove the data stored within the LibraryData object for the current chunk of |
processing |
db_type (str): The type of database to submit to |
either 'sqlite', 'mysql' or 'django_mysql' [default sqlite] |
"""""" |
if self.update_source: |
# print ""insert ref id"" |
import msp2db |
self.c.execute( |
""INSERT INTO library_spectra_source (id, name, parsing_software) VALUES"" |
"" ({a}, '{b}', 'msp2db-v{c}')"".format(a=self.current_id_origin, b=self.source, c=msp2db.__version__)) |
self.conn.commit() |
if self.compound_info_all: |
self.compound_info_all = _make_sql_compatible(self.compound_info_all) |
cn = ', '.join(self.compound_info.keys()) + ',created_at,updated_at' |
insert_query_m(self.compound_info_all, columns=cn, conn=self.conn, table='metab_compound', |
db_type=db_type) |
self.meta_info_all = _make_sql_compatible(self.meta_info_all) |
cn = 'id,' + ', '.join(self.meta_info.keys()) + ',library_spectra_source_id, inchikey_id' |
insert_query_m(self.meta_info_all, columns=cn, conn=self.conn, table='library_spectra_meta', |
db_type=db_type) |
cn = ""id, mz, i, other, library_spectra_meta_id"" |
insert_query_m(self.spectra_all, columns=cn, conn=self.conn, table='library_spectra', db_type=db_type) |
if self.spectra_annotation_all: |
cn = ""id, mz, tentative_formula, mass_error, library_spectra_meta_id"" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.