Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hetionet does not work #502

Open
chaxor opened this issue Jul 20, 2023 · 1 comment
Open

hetionet does not work #502

chaxor opened this issue Jul 20, 2023 · 1 comment

Comments

@chaxor
Copy link

chaxor commented Jul 20, 2023

The function get_hetionet() in pybel.io.hetionet no longer works, due to the use of the key "source" in the annotations dictionary.

Here is a stacktrace:

----> 1 hetio = pybel.get_hetionet()

File /usr/local/lib/python3.10/dist-packages/pybel/io/hetionet/hetionet.py:44, in get_hetionet()
     42 """Get Hetionet from GitHub, cache, and convert to BEL."""
     43 path = pystow.ensure("bio2bel", "hetionet", url=JSON_BZ2_URL)
---> 44 return from_hetionet_gz(path.as_posix())

File /usr/local/lib/python3.10/dist-packages/pybel/io/hetionet/hetionet.py:51, in from_hetionet_gz(path)
     49 logger.info("opening %s", path)
     50 with bz2.open(path) as file:
---> 51     return from_hetionet_file(file)

File /usr/local/lib/python3.10/dist-packages/pybel/io/hetionet/hetionet.py:59, in from_hetionet_file(file)
     57 j = json.load(file)
     58 logger.info("converting hetionet dict to BEL")
---> 59 return from_hetionet_json(j)

File /usr/local/lib/python3.10/dist-packages/pybel/io/hetionet/hetionet.py:86, in from_hetionet_json(hetionet_dict, use_tqdm)
     83     it_logger = logger.info
     85 for edge in edges:
---> 86     _add_edge(graph, edge, kind_identifier_to_name, it_logger)
     88 return graph

File /usr/local/lib/python3.10/dist-packages/pybel/io/hetionet/hetionet.py:159, in _add_edge(graph, edge, kind_identifier_to_name, it_logger)
    157 rv = set()
    158 for citation in citations:
--> 159     key = f(
    160         graph,
    161         h_dsl(namespace=source_ns, identifier=source_identifier, name=source_name),
    162         t_dsl(namespace=target_ns, identifier=target_identifier, name=target_name),
    163         citation=citation,
    164         evidence="",
    165         annotations=annotations,
    166     )
    167     rv.add(key)
    168 return rv

File /usr/lib/python3.10/functools.py:388, in partialmethod._make_unbound_method.<locals>._method(cls_or_self, *args, **keywords)
    386 def _method(cls_or_self, /, *args, **keywords):
    387     keywords = {**self.keywords, **keywords}
--> 388     return self.func(cls_or_self, *self.args, *args, **keywords)

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:543, in BELGraph._add_two_way_qualified_edge(self, source, target, *args, **kwargs)
    541 def _add_two_way_qualified_edge(self, source: BaseEntity, target: BaseEntity, *args, **kwargs) -> str:
    542     """Add an qualified edge both ways."""
--> 543     self.add_qualified_edge(source=target, target=source, *args, **kwargs)
    544     return self.add_qualified_edge(source=source, target=target, *args, **kwargs)

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:609, in BELGraph.add_qualified_edge(self, source, target, relation, evidence, citation, annotations, source_modifier, target_modifier, **attr)
    606     warnings.warn("object_modifier has been renamed to target_modifier")
    607     target_modifier = attr.pop("object_modifier")
--> 609 attr = self._build_attr(
    610     relation=relation,
    611     evidence=evidence,
    612     citation=citation,
    613     annotations=annotations,
    614     source_modifier=source_modifier,
    615     target_modifier=target_modifier,
    616     **attr,
    617 )
    618 return self._help_add_edge(source=source, target=target, attr=attr)

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:639, in BELGraph._build_attr(self, relation, evidence, citation, annotations, source_modifier, target_modifier, **attr)
    630 attr.update(
    631     {
    632         RELATION: relation,
   (...)
    635     }
    636 )
    638 if annotations:  # clean up annotations
--> 639     attr[ANNOTATIONS] = self._clean_annotations(annotations)
    641 if source_modifier:
    642     attr[SOURCE_MODIFIER] = _handle_modifier(source_modifier)

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:1011, in BELGraph._clean_annotations(self, annotations_dict)
    994 def _clean_annotations(self, annotations_dict: AnnotationsHint) -> AnnotationsDict:
    995     """Fix the formatting of annotation dict.
    996 
    997     .. seealso:: https://github.com/vtoure/bep/blob/master/docs/published/BEP-0013.md
   (...)
   1009        ``{'ECO': dict(namespace='ECO', identifier='0007682', name='reporter gene assay...')}``
   1010     """
-> 1011     return {
   1012         key: sorted(
   1013             self._clean_value(key, values),
   1014             key=lambda e: (e.namespace, e.identifier, e.name),
   1015         )
   1016         for key, values in annotations_dict.items()
   1017     }

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:1013, in <dictcomp>(.0)
    994 def _clean_annotations(self, annotations_dict: AnnotationsHint) -> AnnotationsDict:
    995     """Fix the formatting of annotation dict.
    996 
    997     .. seealso:: https://github.com/vtoure/bep/blob/master/docs/published/BEP-0013.md
   (...)
   1009        ``{'ECO': dict(namespace='ECO', identifier='0007682', name='reporter gene assay...')}``
   1010     """
   1011     return {
   1012         key: sorted(
-> 1013             self._clean_value(key, values),
   1014             key=lambda e: (e.namespace, e.identifier, e.name),
   1015         )
   1016         for key, values in annotations_dict.items()
   1017     }

File /usr/local/lib/python3.10/dist-packages/pybel/struct/graph.py:1052, in BELGraph._clean_value(self, key, values)
   1049     return self._clean_value_helper(key=key, namespace=key, values=values)
   1051 if self.raise_on_missing_annotations:
-> 1052     raise NotImplementedError(f"where is key {key}?")
   1054 return self._clean_value_helper(key=key, namespace=key, values=values)

NotImplementedError: where is key source?
@cthoyt
Copy link
Member

cthoyt commented Jul 20, 2023

what version of PyBEL are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants