Skip to content

Commit

Permalink
Updating synteny code to load extant species correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-wave committed Nov 7, 2023
1 parent 04254e4 commit 14f1af8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions omadb/OMARestAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,30 +1678,35 @@ def _parse_graph(self, z):

if len(z.nodes) > 1:
# all nodes should be connected when we have more than 1 node in the list
df = pd.DataFrame(dict(x) for x in z.links)
edge_attr = list(set(df.columns) - {'source', 'target'})
G = nx.from_pandas_edgelist(
pd.DataFrame(dict(x) for x in z.links),
df,
source='source',
target='target',
edge_attr=['weight', 'evidence']
edge_attr=edge_attr,
)
else:
# add a single node graph
G = nx.Graph()
G.add_node(z.nodes[0].id)

# add other attribute information to the graph
attributes = set(z.nodes[0].keys()) - {'id'}
for k in attributes:
nx.set_node_attributes(G, values={x['id']: x[k] for x in z.nodes}, name=k)

# add ability to lazy call for information about the hog
# add ability to lazy call for information about the node (hog / protein)
nx.set_node_attributes(
G,
values={x['id']:
ClientRequest(
self._client,
(
self._client.endpoint +
self._client._get_request_uri(action='hog', subject=x['id'])[0])
(self._client._get_request_uri(action='hog', subject=x['id'])[0] if
x['id'].lower().startswith('hog:') else
self._client._get_request_uri(action='protein', subject=x['id'])[0]))
)
for x in z.nodes
},
Expand Down Expand Up @@ -1787,6 +1792,9 @@ def window(self, id, level, n=2):
:rtype: ClientResponse
'''
G = self.neighbourhood(id, level, context=n)
# check that the ID we searched for is in the graph
# else we need to update to the "correct" ID. e.g. WHEAT100 -> WHEAT00100
G.adj.get(id, None)

hog_order = deque([id])

Expand Down
2 changes: 1 addition & 1 deletion omadb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
from .OMARestAPI import Client, CoronaClient, OMAStageClient


__version__ = '2.2.1'
__version__ = '2.2.2'

0 comments on commit 14f1af8

Please sign in to comment.