Skip to content

Missing GO term in networkx Graph #4

@vizkidd

Description

@vizkidd

I get this error for some PDB files in a list

Traceback (most recent call last):
File "/home/vishvesh/DeepFRI/predict_fast.py", line 136, in <module>
predicted_goterms = explode_all_goterms(predicted_goterms)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vishvesh/DeepFRI/predict_fast.py", line 59, in explode_all_goterms
for parent in explode_goterm(goterm):
^^^^^^^^^^^^^^^^^^^^^^
File "/home/vishvesh/DeepFRI/predict_fast.py", line 49, in explode_goterm
tmp = list(networkx.predecessor(graph, goterm).keys())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<class 'networkx.utils.decorators.argmap'> compilation 4", line 3, in argmap_predecessor_1
File "/home/vishvesh/deepfri-env/lib/python3.11/site-packages/networkx/utils/backends.py", line 535, in _call_if_no_backends_installed
return self.orig_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vishvesh/deepfri-env/lib/python3.11/site-packages/networkx/algorithms/shortest_paths/unweighted.py", line 528, in predecessor
raise nx.NodeNotFound(f"Source {source} not in G")
networkx.exception.NodeNotFound: Source GO:0008022 not in G

I assume the missing GO terms to be at the tips.

Possible Solution:

To enclose the contents of explode_goterm() within a try-catch block and return and empty list for exceptions

def explode_goterm(goterm):
# get name of the GO term
try:
tmp = list(networkx.predecessor(graph, goterm).keys())
return tmp
except:
print(f"GO term {goterm} not found in the GO graph.")
return []

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions