diff --git a/src/pybel_tools/selection/metapaths.py b/src/pybel_tools/selection/metapaths.py new file mode 100644 index 00000000..3af6ea3c --- /dev/null +++ b/src/pybel_tools/selection/metapaths.py @@ -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 + ] +