From 36f6916ca42d4e77c803704ac9ae7c91bd6ae9c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Nov 2024 14:53:23 +0100 Subject: [PATCH] more work on RaMP identifiers insertion --- omnipath_metabo/schema/_main.py | 7 ++++--- omnipath_metabo/schema/_structure.py | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/omnipath_metabo/schema/_main.py b/omnipath_metabo/schema/_main.py index 7a123e2..f4aaa81 100644 --- a/omnipath_metabo/schema/_main.py +++ b/omnipath_metabo/schema/_main.py @@ -168,9 +168,10 @@ def load(self): ) psycopg2.extras.execute_values(cursor, query, cached_resource, page_size = 1000) + type(cached_resource) raw_con.commit() - _log("structures have been inserted") + _log("structures have been inserted", level = -1) return_ids = text("SELECT id, smiles FROM structures") inserted_str = { @@ -185,7 +186,7 @@ def load(self): #vself.update_mol_column() - _log('resource ids collected.') + _log('resource ids collected.', level = -1) insert_ids = ( (_id, strids[smiles], resource_key, i==0, resource_labels[i]) @@ -195,7 +196,7 @@ def load(self): for i, _id in enumerate(itertools.chain((name, ), cached_resource.cached['struct']['identifiers'])) ) - _log('inserting identifiers.') + _log('inserting identifiers.', level =-1) with raw_con.cursor() as cursor: query = """ INSERT INTO identifiers (identifier, structure_id, resource_id, authoritative, id_type) VALUES %s diff --git a/omnipath_metabo/schema/_structure.py b/omnipath_metabo/schema/_structure.py index 8507c9e..c5d89a7 100644 --- a/omnipath_metabo/schema/_structure.py +++ b/omnipath_metabo/schema/_structure.py @@ -189,7 +189,6 @@ def __iter__(self): class Ramp(ResourceBase): scheme = Structure name = 'RaMP' - id_fields = sorted(ramp.ramp_id_types()) def __iter__(self): @@ -201,9 +200,9 @@ def __iter__(self): 'identifiers': (row[2]) } - '''Alternative possibility + '''Alternative possibility without editing source_data = { - row[]:row[] for row in ramp.ramp_iter('source') + row[1]:row[0] for row in ramp.ramp_iter('source') } for chem_props_row in ramp.ramp_iter('chem_props'): source_row = source_data.get(chem_props_row[0])