Skip to content

Commit

Permalink
debugging of new load method
Browse files Browse the repository at this point in the history
  • Loading branch information
for-hyde committed Nov 1, 2024
1 parent 22edeb9 commit e2b3a8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
18 changes: 8 additions & 10 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def load(self):
with raw_con.cursor() as cursor:
query = """
INSERT INTO identifiers (identifier, structure_id, resource_id, authoritative, id_type) VALUES %s
ON CONFLICT DO NOTHING
"""
psycopg2.extras.execute_values(cursor, query, insert_ids, page_size = 1000)

Expand All @@ -169,36 +170,33 @@ def load(self):

return_ids = text(
"SELECT id, structure_id, identifier, resource_id, id_type "
f"FROM identifiers WHERE resource_id = {resid}")
strid_to_smile = {reversed(it) for it in strids.items()}
f"FROM identifiers WHERE resource_id = {resource_key}")
identifier_ids = {
rest: id
tuple(rest): id
for id, *rest in self.session.execute(return_ids)
}
inserted_str = {
(strid_to_smile[s[1]], s[2], s[3], s[4])
for s in cached_resource.cached['struct'])
print(list(identifier_ids.values())[10])

property_records = (
(
identifier_ids[
(record['structure'][0],
strids[record['structure'][1]],
resid,
resource_key,
True,
resid
resource_key
)
],
) + record['properties']

for record in cached_resource.cache['struct']
for record in cached_resource.cached['struct']
)

with raw_con.cursor() as cursor:
query = """
INSERT INTO properties (identifier_id, mw, monoiso_mass, charge, formula) VALUES %s
"""
psycopg2.extras.execute_values(cursor, query, inserted_str, page_size = 1000)
psycopg2.extras.execute_values(cursor, query, property_records, page_size = 1000)


#self.indexer()
Expand Down
3 changes: 2 additions & 1 deletion omnipath_metabo/schema/_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Identifier(Base):
id_type = Column(Integer, ForeignKey('resources.id'), nullable = False)
__table_args__ = (
Index(
name = 'identifers_unique','identifier',
'identifers_unique',
'identifier',
'structure_id',
'resource_id',
'id_type',
Expand Down

0 comments on commit e2b3a8e

Please sign in to comment.