Skip to content

Commit

Permalink
Add first part of metapath search
Browse files Browse the repository at this point in the history
References #101 and #102
  • Loading branch information
cthoyt committed Jul 16, 2017
1 parent 7018a57 commit c76da3e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/pybel_tools/selection/metapaths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-

"""
A metapath can be defined with two levels of granularity:
- Low: A list of BEL functions representing the types of entities in a given path
- High: An alternating list of BEL functions and BEL relations representing the types of entities in a given path and
their relations
"""

from pybel.constants import FUNCTION


def convert_path_to_metapath(graph, nodes):
"""Converts a list of nodes to their corresponding functions
:param list[tuple] nodes: A list of BEL node tuples
:rtype: list[str]
"""
return [
graph.node[node][FUNCTION]
for node in nodes
]

0 comments on commit c76da3e

Please sign in to comment.