diff --git a/omnipath_metabo/schema/_main.py b/omnipath_metabo/schema/_main.py index c1d3c57..f9d901d 100644 --- a/omnipath_metabo/schema/_main.py +++ b/omnipath_metabo/schema/_main.py @@ -80,17 +80,17 @@ def load_all(self): if getattr(db,'scheme',None) is _structure.Structure: h = db self.load(h) - + self.chem_properties_populate() self.update_mol_column() -# Change the method for updating is_polymer to use InchI. +# Change the method for updating is_polymer to use InchI. def chem_properties_populate(self): _log('Querying mol structures', level=-1) query = text(r""" UPDATE identifiers - SET + SET is_polymer = (structures.smiles ~ '.*\)n.*'), has_conformation = (structures.smiles ~ '.*[\\/]=.*'), has_stereo = (structures.smiles ~ '.*@.*'), @@ -110,6 +110,7 @@ def update_mol_column(self): self.con.session.commit() _log('Finished creating mol column.', level =-1) + class Loader(): def __init__(self, resource, con): diff --git a/omnipath_metabo/schema/_structure.py b/omnipath_metabo/schema/_structure.py index d4cd80e..2d4bc71 100644 --- a/omnipath_metabo/schema/_structure.py +++ b/omnipath_metabo/schema/_structure.py @@ -12,9 +12,10 @@ def get_col_spec(self, **kw): class Structure(Base): __tablename__ = 'structures' - id = Column(Integer, primary_key=True) + id = Column(Integer, primary_key = True) name = Column(String) - smiles = Column(String, unique= True) + smiles = Column(String) + inchi = Column(String, unique = True) mol = Column(MolType) identifier = relationship( 'Identifier', @@ -102,13 +103,16 @@ def __iter__(self): 'smiles', 'average_molecular_weight', 'monisotopic_molecular_weight', - 'chemical_formula' + 'chemical_formula', + 'inchi', ): + yield { - 'structure':(met[0][0], met[0][1]), + 'structure':(met[0][0], met[0][1], met[0][5]), 'properties': (met[0][2], met[0][3], None, met[0][4]) } + class SwissLipids(): scheme = Structure name = 'SwissLipids' @@ -120,7 +124,11 @@ def __iter__(self): mass = met['Mass (pH7.3)'] yield { - 'structure':(met['Lipid ID'], met['SMILES (pH7.3)']), + 'structure': ( + met['Lipid ID'], + met['SMILES (pH7.3)'], + met['InChi (pH7.3)'], + ), 'properties':(mass, 0, met['Charge (pH7.3)'],met['Formula (pH7.3)']) } @@ -140,7 +148,7 @@ def __iter__(self): continue yield { - 'structure':(met['id'], smiles), + 'structure':(met['id'], smiles, met['name']['INCHI']), 'properties':(met['annot'].get('EXACT_MASS', None), None, None, met['name'].get('FORMULA', None) ) } @@ -152,6 +160,6 @@ def __iter__(self): for row in ramp.ramp_iter('chem_props'): yield { - 'structure': (row[0], row[3]), + 'structure': (row[0], row[3], row[6]), 'properties':(row[7], row[8], None, row[10]) }