Skip to content

Commit

Permalink
moved properties to structures table
Browse files Browse the repository at this point in the history
  • Loading branch information
for-hyde committed Nov 22, 2024
1 parent 9184864 commit 7894e03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 6 additions & 8 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create(con):
Base.metadata.create_all(con.engine)


TABLES = {'structures', 'identifiers', 'resources'}
TABLES = {'structures', 'identifiers', 'resources', 'properties'}


class Database:
Expand Down Expand Up @@ -90,14 +90,12 @@ def load_all(self):
def chem_properties_populate(self):
_log('Querying mol structures', level=-1)
query = text(r"""
UPDATE identifiers
UPDATE structures
SET
is_polymer = (structures.inchi ~ '.*\\p.*'),
has_conformation = (structures.smiles ~ '.*[\\/]=.*'),
has_stereo = (structures.smiles ~ '.*@.*'),
complete_formula = NOT (structures.smiles ~ '.*\*.*')
FROM structures
WHERE identifiers.structure_id = structures.id;
is_polymer = (inchi ~ '.*\\p.*'),
has_conformation = (smiles ~ '.*[\\/]=.*'),
has_stereo = (smiles ~ '.*@.*'),
complete_formula = NOT (smiles ~ '.*\*.*')
""")
self.con.session.execute(query)
self.con.session.commit()
Expand Down
8 changes: 4 additions & 4 deletions omnipath_metabo/schema/_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class Structure(Base):
smiles = Column(String, unique= True)
inchi = Column(String(4096))
mol = Column(MolType)
is_polymer = Column(Boolean)
has_stereo = Column(Boolean)
has_conformation = Column(Boolean)
complete_formula = Column(Boolean)
identifier = relationship(
'Identifier',
backref='structure',
Expand All @@ -55,10 +59,6 @@ class Identifier(Base):
Integer,
ForeignKey('resources.id'),
nullable = False)
is_polymer = Column(Boolean)
has_stereo = Column(Boolean)
has_conformation = Column(Boolean)
complete_formula = Column(Boolean)
__table_args__ = (
Index(
'identifers_unique',
Expand Down

0 comments on commit 7894e03

Please sign in to comment.