Skip to content

Commit

Permalink
Print out that the cycles are hierarchical
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaris committed Jan 12, 2024
1 parent 4f2d40c commit aec1b47
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions indra/tools/analyze_ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def print_cycle(cycle):
)
)


if __name__ == '__main__':
# First, find strongly connected components in the xref graph where
# a given namespace appears more than once.
Expand Down Expand Up @@ -52,13 +53,15 @@ def print_cycle(cycle):
for ns, problems_ns in problems_by_ns.items():
print(ns, len(problems_ns))


# Next, find cycles in the isa/partof subgraph meaning circular
# hierarchical relationships.
hierarchy = [(e[0], e[1]) for e in bio_ontology.edges(data=True) if
e[2]['type'] in {'isa', 'partof'}]
hierarchyg = bio_ontology.edge_subgraph(hierarchy)
cycles = networkx.simple_cycles(hierarchyg)
for cycle in cycles:
if cycles:
print('---')
print_cycle(cycle)
print('Hierarchical cycles')
for cycle in cycles:
print('---')
print_cycle(cycle)

0 comments on commit aec1b47

Please sign in to comment.