Skip to content

Commit

Permalink
Updated processing of identifiers in loader.
Browse files Browse the repository at this point in the history
  • Loading branch information
for-hyde committed Nov 19, 2024
1 parent 885d251 commit 63b8d89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
9 changes: 5 additions & 4 deletions omnipath_metabo/schema/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ def load(self):

self.create()

resource_labels = [self.resource.name] + self.resource.id_types

insert_resource = (
insert(_structure.Resource).
values([{'name': l} for l in resource_labels]).
Expand Down Expand Up @@ -189,11 +187,14 @@ def load(self):
_log('resource ids collected.', level = -1)

insert_ids = (
(_id, strids[smiles], resource_key, i==0, resource_labels[i])
(_id, strids[smiles], resource_key, id_type == self.resource.name, resource.id_types.get(id_type, id_type)
for name, smiles, _ in (
r['structure'] for r in cached_resource.cached['struct']
)
for i, _id in enumerate(itertools.chain((name, ), cached_resource.cached['struct']['identifiers']))
for _id, id_type in itertools.chain(
(name, self.resource.name),
cached_resource.cached['struct']['identifiers']
)
)

_log('inserting identifiers.', level =-1)
Expand Down
5 changes: 1 addition & 4 deletions omnipath_metabo/schema/_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ def __init__(self):
@classmethod
def _resource_label(cls) -> str:

return [
_id_types().get(cls.name, {}).get(label, label)
for label in cls.id_fields
]
return _id_types().get(cls.name, {})



Expand Down

0 comments on commit 63b8d89

Please sign in to comment.