Skip to content

Commit

Permalink
structure table: include InChi in new col
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Nov 7, 2024
1 parent c1ec130 commit 07c34c1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
7 changes: 4 additions & 3 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~ '.*@.*'),
Expand All @@ -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):
Expand Down
22 changes: 15 additions & 7 deletions omnipath_metabo/schema/_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand All @@ -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)'])
}

Expand All @@ -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) )
}

Expand All @@ -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])
}

0 comments on commit 07c34c1

Please sign in to comment.