partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
cmdclass
Build nbextension cmdclass dict for the setuptools.setup method. Parameters ---------- path: str Directory relative to the setup file that the nbextension code lives in. enable: [str=None] Extension to "enable". Enabling an extension causes it to be loaded automatically...
jupyterpip/__init__.py
def cmdclass(path, enable=None, user=None): """Build nbextension cmdclass dict for the setuptools.setup method. Parameters ---------- path: str Directory relative to the setup file that the nbextension code lives in. enable: [str=None] Extension to "enable". Enabling an ext...
def cmdclass(path, enable=None, user=None): """Build nbextension cmdclass dict for the setuptools.setup method. Parameters ---------- path: str Directory relative to the setup file that the nbextension code lives in. enable: [str=None] Extension to "enable". Enabling an ext...
[ "Build", "nbextension", "cmdclass", "dict", "for", "the", "setuptools", ".", "setup", "method", "." ]
jdfreder/jupyter-pip
python
https://github.com/jdfreder/jupyter-pip/blob/9f04c6096f1169b08aeaf6221616a5fb48111044/jupyterpip/__init__.py#L12-L113
[ "def", "cmdclass", "(", "path", ",", "enable", "=", "None", ",", "user", "=", "None", ")", ":", "import", "warnings", "from", "setuptools", ".", "command", ".", "install", "import", "install", "from", "setuptools", ".", "command", ".", "develop", "import",...
9f04c6096f1169b08aeaf6221616a5fb48111044
valid
count_subgraph_sizes
Count the number of nodes in each subgraph induced by an annotation. :param annotation: The annotation to group by and compare. Defaults to 'Subgraph' :return: A dictionary from {annotation value: number of nodes}
src/pybel_tools/summary/subgraph_summary.py
def count_subgraph_sizes(graph: BELGraph, annotation: str = 'Subgraph') -> Counter[int]: """Count the number of nodes in each subgraph induced by an annotation. :param annotation: The annotation to group by and compare. Defaults to 'Subgraph' :return: A dictionary from {annotation value: number of nodes} ...
def count_subgraph_sizes(graph: BELGraph, annotation: str = 'Subgraph') -> Counter[int]: """Count the number of nodes in each subgraph induced by an annotation. :param annotation: The annotation to group by and compare. Defaults to 'Subgraph' :return: A dictionary from {annotation value: number of nodes} ...
[ "Count", "the", "number", "of", "nodes", "in", "each", "subgraph", "induced", "by", "an", "annotation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/subgraph_summary.py#L27-L33
[ "def", "count_subgraph_sizes", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", "->", "Counter", "[", "int", "]", ":", "return", "count_dict_values", "(", "group_nodes_by_annotation", "(", "graph", ",", "annotation", ")", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_subgraph_edge_overlap
Build a DatafFame to show the overlap between different sub-graphs. Options: 1. Total number of edges overlap (intersection) 2. Percentage overlap (tanimoto similarity) :param graph: A BEL graph :param annotation: The annotation to group by and compare. Defaults to 'Subgraph' :return: {subgrap...
src/pybel_tools/summary/subgraph_summary.py
def calculate_subgraph_edge_overlap( graph: BELGraph, annotation: str = 'Subgraph' ) -> Tuple[ Mapping[str, EdgeSet], Mapping[str, Mapping[str, EdgeSet]], Mapping[str, Mapping[str, EdgeSet]], Mapping[str, Mapping[str, float]], ]: """Build a DatafFame to show the overlap between diffe...
def calculate_subgraph_edge_overlap( graph: BELGraph, annotation: str = 'Subgraph' ) -> Tuple[ Mapping[str, EdgeSet], Mapping[str, Mapping[str, EdgeSet]], Mapping[str, Mapping[str, EdgeSet]], Mapping[str, Mapping[str, float]], ]: """Build a DatafFame to show the overlap between diffe...
[ "Build", "a", "DatafFame", "to", "show", "the", "overlap", "between", "different", "sub", "-", "graphs", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/subgraph_summary.py#L39-L75
[ "def", "calculate_subgraph_edge_overlap", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", "->", "Tuple", "[", "Mapping", "[", "str", ",", "EdgeSet", "]", ",", "Mapping", "[", "str", ",", "Mapping", "[", "str", ",", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
summarize_subgraph_edge_overlap
Return a similarity matrix between all subgraphs (or other given annotation). :param annotation: The annotation to group by and compare. Defaults to :code:`"Subgraph"` :return: A similarity matrix in a dict of dicts :rtype: dict
src/pybel_tools/summary/subgraph_summary.py
def summarize_subgraph_edge_overlap(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, Mapping[str, float]]: """Return a similarity matrix between all subgraphs (or other given annotation). :param annotation: The annotation to group by and compare. Defaults to :code:`"Subgraph"` :return: A simi...
def summarize_subgraph_edge_overlap(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, Mapping[str, float]]: """Return a similarity matrix between all subgraphs (or other given annotation). :param annotation: The annotation to group by and compare. Defaults to :code:`"Subgraph"` :return: A simi...
[ "Return", "a", "similarity", "matrix", "between", "all", "subgraphs", "(", "or", "other", "given", "annotation", ")", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/subgraph_summary.py#L78-L86
[ "def", "summarize_subgraph_edge_overlap", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", "->", "Mapping", "[", "str", ",", "Mapping", "[", "str", ",", "float", "]", "]", ":", "_", ",", "_", ",", "_", ",", "subgrap...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
summarize_subgraph_node_overlap
Calculate the subgraph similarity tanimoto similarity in nodes passing the given filter. Provides an alternate view on subgraph similarity, from a more node-centric view
src/pybel_tools/summary/subgraph_summary.py
def summarize_subgraph_node_overlap(graph: BELGraph, node_predicates=None, annotation: str = 'Subgraph'): """Calculate the subgraph similarity tanimoto similarity in nodes passing the given filter. Provides an alternate view on subgraph similarity, from a more node-centric view """ r1 = group_nodes_by_...
def summarize_subgraph_node_overlap(graph: BELGraph, node_predicates=None, annotation: str = 'Subgraph'): """Calculate the subgraph similarity tanimoto similarity in nodes passing the given filter. Provides an alternate view on subgraph similarity, from a more node-centric view """ r1 = group_nodes_by_...
[ "Calculate", "the", "subgraph", "similarity", "tanimoto", "similarity", "in", "nodes", "passing", "the", "given", "filter", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/subgraph_summary.py#L89-L95
[ "def", "summarize_subgraph_node_overlap", "(", "graph", ":", "BELGraph", ",", "node_predicates", "=", "None", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", ":", "r1", "=", "group_nodes_by_annotation_filtered", "(", "graph", ",", "node_predicates", "=", "n...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
rank_subgraph_by_node_filter
Rank sub-graphs by which have the most nodes matching an given filter. A use case for this function would be to identify which subgraphs contain the most differentially expressed genes. >>> from pybel import from_pickle >>> from pybel.constants import GENE >>> from pybel_tools.integration import o...
src/pybel_tools/summary/subgraph_summary.py
def rank_subgraph_by_node_filter(graph: BELGraph, node_predicates: Union[NodePredicate, Iterable[NodePredicate]], annotation: str = 'Subgraph', reverse: bool = True, ) -> List[Tuple[str, i...
def rank_subgraph_by_node_filter(graph: BELGraph, node_predicates: Union[NodePredicate, Iterable[NodePredicate]], annotation: str = 'Subgraph', reverse: bool = True, ) -> List[Tuple[str, i...
[ "Rank", "sub", "-", "graphs", "by", "which", "have", "the", "most", "nodes", "matching", "an", "given", "filter", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/subgraph_summary.py#L98-L122
[ "def", "rank_subgraph_by_node_filter", "(", "graph", ":", "BELGraph", ",", "node_predicates", ":", "Union", "[", "NodePredicate", ",", "Iterable", "[", "NodePredicate", "]", "]", ",", "annotation", ":", "str", "=", "'Subgraph'", ",", "reverse", ":", "bool", "=...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
to_jupyter
Render the graph as JavaScript in a Jupyter Notebook.
src/pybel_tools/assembler/ideogram/assembler.py
def to_jupyter(graph: BELGraph, chart: Optional[str] = None) -> Javascript: """Render the graph as JavaScript in a Jupyter Notebook.""" with open(os.path.join(HERE, 'render_with_javascript.js'), 'rt') as f: js_template = Template(f.read()) return Javascript(js_template.render(**_get_context(graph, ...
def to_jupyter(graph: BELGraph, chart: Optional[str] = None) -> Javascript: """Render the graph as JavaScript in a Jupyter Notebook.""" with open(os.path.join(HERE, 'render_with_javascript.js'), 'rt') as f: js_template = Template(f.read()) return Javascript(js_template.render(**_get_context(graph, ...
[ "Render", "the", "graph", "as", "JavaScript", "in", "a", "Jupyter", "Notebook", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/ideogram/assembler.py#L29-L34
[ "def", "to_jupyter", "(", "graph", ":", "BELGraph", ",", "chart", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Javascript", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "HERE", ",", "'render_with_javascript.js'", ")", ",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
to_html
Render the graph as an HTML string. Common usage may involve writing to a file like: >>> from pybel.examples import sialic_acid_graph >>> with open('ideogram_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), file=file)
src/pybel_tools/assembler/ideogram/assembler.py
def to_html(graph: BELGraph, chart: Optional[str] = None) -> str: """Render the graph as an HTML string. Common usage may involve writing to a file like: >>> from pybel.examples import sialic_acid_graph >>> with open('ideogram_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), f...
def to_html(graph: BELGraph, chart: Optional[str] = None) -> str: """Render the graph as an HTML string. Common usage may involve writing to a file like: >>> from pybel.examples import sialic_acid_graph >>> with open('ideogram_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), f...
[ "Render", "the", "graph", "as", "an", "HTML", "string", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/ideogram/assembler.py#L37-L49
[ "def", "to_html", "(", "graph", ":", "BELGraph", ",", "chart", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "HERE", ",", "'index.html'", ")", ",", "'rt'", ")", "as...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
prerender
Generate the annotations JSON for Ideogram.
src/pybel_tools/assembler/ideogram/assembler.py
def prerender(graph: BELGraph) -> Mapping[str, Mapping[str, Any]]: """Generate the annotations JSON for Ideogram.""" import bio2bel_hgnc from bio2bel_hgnc.models import HumanGene graph: BELGraph = graph.copy() enrich_protein_and_rna_origins(graph) collapse_all_variants(graph) genes: Set[Gen...
def prerender(graph: BELGraph) -> Mapping[str, Mapping[str, Any]]: """Generate the annotations JSON for Ideogram.""" import bio2bel_hgnc from bio2bel_hgnc.models import HumanGene graph: BELGraph = graph.copy() enrich_protein_and_rna_origins(graph) collapse_all_variants(graph) genes: Set[Gen...
[ "Generate", "the", "annotations", "JSON", "for", "Ideogram", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/ideogram/assembler.py#L66-L106
[ "def", "prerender", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Mapping", "[", "str", ",", "Any", "]", "]", ":", "import", "bio2bel_hgnc", "from", "bio2bel_hgnc", ".", "models", "import", "HumanGene", "graph", ":", "BELGraph", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
plot_summary_axes
Plots your graph summary statistics on the given axes. After, you should run :func:`plt.tight_layout` and you must run :func:`plt.show` to view. Shows: 1. Count of nodes, grouped by function type 2. Count of edges, grouped by relation type :param pybel.BELGraph graph: A BEL graph :param lax: ...
src/pybel_tools/summary/export.py
def plot_summary_axes(graph: BELGraph, lax, rax, logx=True): """Plots your graph summary statistics on the given axes. After, you should run :func:`plt.tight_layout` and you must run :func:`plt.show` to view. Shows: 1. Count of nodes, grouped by function type 2. Count of edges, grouped by relation...
def plot_summary_axes(graph: BELGraph, lax, rax, logx=True): """Plots your graph summary statistics on the given axes. After, you should run :func:`plt.tight_layout` and you must run :func:`plt.show` to view. Shows: 1. Count of nodes, grouped by function type 2. Count of edges, grouped by relation...
[ "Plots", "your", "graph", "summary", "statistics", "on", "the", "given", "axes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/export.py#L24-L58
[ "def", "plot_summary_axes", "(", "graph", ":", "BELGraph", ",", "lax", ",", "rax", ",", "logx", "=", "True", ")", ":", "ntc", "=", "count_functions", "(", "graph", ")", "etc", "=", "count_relations", "(", "graph", ")", "df", "=", "pd", ".", "DataFrame"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
plot_summary
Plots your graph summary statistics. This function is a thin wrapper around :func:`plot_summary_axis`. It automatically takes care of building figures given matplotlib's pyplot module as an argument. After, you need to run :func:`plt.show`. :code:`plt` is given as an argument to avoid needing matplotlib as...
src/pybel_tools/summary/export.py
def plot_summary(graph: BELGraph, plt, logx=True, **kwargs): """Plots your graph summary statistics. This function is a thin wrapper around :func:`plot_summary_axis`. It automatically takes care of building figures given matplotlib's pyplot module as an argument. After, you need to run :func:`plt.show`. ...
def plot_summary(graph: BELGraph, plt, logx=True, **kwargs): """Plots your graph summary statistics. This function is a thin wrapper around :func:`plot_summary_axis`. It automatically takes care of building figures given matplotlib's pyplot module as an argument. After, you need to run :func:`plt.show`. ...
[ "Plots", "your", "graph", "summary", "statistics", ".", "This", "function", "is", "a", "thin", "wrapper", "around", ":", "func", ":", "plot_summary_axis", ".", "It", "automatically", "takes", "care", "of", "building", "figures", "given", "matplotlib", "s", "py...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/export.py#L61-L92
[ "def", "plot_summary", "(", "graph", ":", "BELGraph", ",", "plt", ",", "logx", "=", "True", ",", "*", "*", "kwargs", ")", ":", "fig", ",", "axes", "=", "plt", ".", "subplots", "(", "1", ",", "2", ",", "*", "*", "kwargs", ")", "lax", "=", "axes"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_nodes_by_function_namespace
Remove nodes with the given function and namespace. This might be useful to exclude information learned about distant species, such as excluding all information from MGI and RGD in diseases where mice and rats don't give much insight to the human disease mechanism.
src/pybel_tools/filters/node_deletion.py
def remove_nodes_by_function_namespace(graph: BELGraph, func: str, namespace: Strings) -> None: """Remove nodes with the given function and namespace. This might be useful to exclude information learned about distant species, such as excluding all information from MGI and RGD in diseases where mice and rat...
def remove_nodes_by_function_namespace(graph: BELGraph, func: str, namespace: Strings) -> None: """Remove nodes with the given function and namespace. This might be useful to exclude information learned about distant species, such as excluding all information from MGI and RGD in diseases where mice and rat...
[ "Remove", "nodes", "with", "the", "given", "function", "and", "namespace", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/filters/node_deletion.py#L54-L60
[ "def", "remove_nodes_by_function_namespace", "(", "graph", ":", "BELGraph", ",", "func", ":", "str", ",", "namespace", ":", "Strings", ")", "->", "None", ":", "remove_filtered_nodes", "(", "graph", ",", "function_namespace_inclusion_builder", "(", "func", ",", "na...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
preprocessing_excel
Preprocess the excel sheet :param filepath: filepath of the excel data :return: df: pandas dataframe with excel data :rtype: pandas.DataFrame
src/pybel_tools/analysis/neurommsig/export.py
def preprocessing_excel(path): """Preprocess the excel sheet :param filepath: filepath of the excel data :return: df: pandas dataframe with excel data :rtype: pandas.DataFrame """ if not os.path.exists(path): raise ValueError("Error: %s file not found" % path) # Import Models from ...
def preprocessing_excel(path): """Preprocess the excel sheet :param filepath: filepath of the excel data :return: df: pandas dataframe with excel data :rtype: pandas.DataFrame """ if not os.path.exists(path): raise ValueError("Error: %s file not found" % path) # Import Models from ...
[ "Preprocess", "the", "excel", "sheet" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/export.py#L37-L74
[ "def", "preprocessing_excel", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "ValueError", "(", "\"Error: %s file not found\"", "%", "path", ")", "# Import Models from Excel sheet, independent for AD and PD", "d...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
preprocessing_br_projection_excel
Preprocess the excel file. Parameters ---------- path : Filepath of the excel sheet
src/pybel_tools/analysis/neurommsig/export.py
def preprocessing_br_projection_excel(path: str) -> pd.DataFrame: """Preprocess the excel file. Parameters ---------- path : Filepath of the excel sheet """ if not os.path.exists(path): raise ValueError("Error: %s file not found" % path) return pd.read_excel(path, sheetname=0, head...
def preprocessing_br_projection_excel(path: str) -> pd.DataFrame: """Preprocess the excel file. Parameters ---------- path : Filepath of the excel sheet """ if not os.path.exists(path): raise ValueError("Error: %s file not found" % path) return pd.read_excel(path, sheetname=0, head...
[ "Preprocess", "the", "excel", "file", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/export.py#L98-L108
[ "def", "preprocessing_br_projection_excel", "(", "path", ":", "str", ")", "->", "pd", ".", "DataFrame", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "ValueError", "(", "\"Error: %s file not found\"", "%", "path", ")", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_nift_values
Extract the list of NIFT names from the BEL resource and builds a dictionary mapping from the lowercased version to the uppercase version.
src/pybel_tools/analysis/neurommsig/export.py
def get_nift_values() -> Mapping[str, str]: """Extract the list of NIFT names from the BEL resource and builds a dictionary mapping from the lowercased version to the uppercase version. """ r = get_bel_resource(NIFT) return { name.lower(): name for name in r['Values'] }
def get_nift_values() -> Mapping[str, str]: """Extract the list of NIFT names from the BEL resource and builds a dictionary mapping from the lowercased version to the uppercase version. """ r = get_bel_resource(NIFT) return { name.lower(): name for name in r['Values'] }
[ "Extract", "the", "list", "of", "NIFT", "names", "from", "the", "BEL", "resource", "and", "builds", "a", "dictionary", "mapping", "from", "the", "lowercased", "version", "to", "the", "uppercase", "version", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/export.py#L148-L156
[ "def", "get_nift_values", "(", ")", "->", "Mapping", "[", "str", ",", "str", "]", ":", "r", "=", "get_bel_resource", "(", "NIFT", ")", "return", "{", "name", ".", "lower", "(", ")", ":", "name", "for", "name", "in", "r", "[", "'Values'", "]", "}" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
write_neurommsig_bel
Writes the NeuroMMSigDB excel sheet to BEL :param file: a file or file-like that can be writen to :param df: :param disease: :param nift_values: a dictionary of lowercased to normal names in NIFT
src/pybel_tools/analysis/neurommsig/export.py
def write_neurommsig_bel(file, df: pd.DataFrame, disease: str, nift_values: Mapping[str, str], ): """Writes the NeuroMMSigDB excel sheet to BEL :param file: a file or file-like that can be writen to :param d...
def write_neurommsig_bel(file, df: pd.DataFrame, disease: str, nift_values: Mapping[str, str], ): """Writes the NeuroMMSigDB excel sheet to BEL :param file: a file or file-like that can be writen to :param d...
[ "Writes", "the", "NeuroMMSigDB", "excel", "sheet", "to", "BEL" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/export.py#L187-L275
[ "def", "write_neurommsig_bel", "(", "file", ",", "df", ":", "pd", ".", "DataFrame", ",", "disease", ":", "str", ",", "nift_values", ":", "Mapping", "[", "str", ",", "str", "]", ",", ")", ":", "write_neurommsig_biolerplate", "(", "disease", ",", "file", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_contradiction_summary
Yield triplets of (source node, target node, set of relations) for (source node, target node) pairs that have multiple, contradictory relations.
src/pybel_tools/analysis/stability.py
def get_contradiction_summary(graph: BELGraph) -> Iterable[Tuple[BaseEntity, BaseEntity, str]]: """Yield triplets of (source node, target node, set of relations) for (source node, target node) pairs that have multiple, contradictory relations. """ for u, v in set(graph.edges()): relations = {dat...
def get_contradiction_summary(graph: BELGraph) -> Iterable[Tuple[BaseEntity, BaseEntity, str]]: """Yield triplets of (source node, target node, set of relations) for (source node, target node) pairs that have multiple, contradictory relations. """ for u, v in set(graph.edges()): relations = {dat...
[ "Yield", "triplets", "of", "(", "source", "node", "target", "node", "set", "of", "relations", ")", "for", "(", "source", "node", "target", "node", ")", "pairs", "that", "have", "multiple", "contradictory", "relations", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L48-L55
[ "def", "get_contradiction_summary", "(", "graph", ":", "BELGraph", ")", "->", "Iterable", "[", "Tuple", "[", "BaseEntity", ",", "BaseEntity", ",", "str", "]", "]", ":", "for", "u", ",", "v", "in", "set", "(", "graph", ".", "edges", "(", ")", ")", ":"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_regulatory_pairs
Find pairs of nodes that have mutual causal edges that are regulating each other such that ``A -> B`` and ``B -| A``. :return: A set of pairs of nodes with mutual causal edges
src/pybel_tools/analysis/stability.py
def get_regulatory_pairs(graph: BELGraph) -> Set[NodePair]: """Find pairs of nodes that have mutual causal edges that are regulating each other such that ``A -> B`` and ``B -| A``. :return: A set of pairs of nodes with mutual causal edges """ cg = get_causal_subgraph(graph) results = set() ...
def get_regulatory_pairs(graph: BELGraph) -> Set[NodePair]: """Find pairs of nodes that have mutual causal edges that are regulating each other such that ``A -> B`` and ``B -| A``. :return: A set of pairs of nodes with mutual causal edges """ cg = get_causal_subgraph(graph) results = set() ...
[ "Find", "pairs", "of", "nodes", "that", "have", "mutual", "causal", "edges", "that", "are", "regulating", "each", "other", "such", "that", "A", "-", ">", "B", "and", "B", "-", "|", "A", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L58-L75
[ "def", "get_regulatory_pairs", "(", "graph", ":", "BELGraph", ")", "->", "Set", "[", "NodePair", "]", ":", "cg", "=", "get_causal_subgraph", "(", "graph", ")", "results", "=", "set", "(", ")", "for", "u", ",", "v", ",", "d", "in", "cg", ".", "edges",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_chaotic_pairs
Find pairs of nodes that have mutual causal edges that are increasing each other such that ``A -> B`` and ``B -> A``. :return: A set of pairs of nodes with mutual causal edges
src/pybel_tools/analysis/stability.py
def get_chaotic_pairs(graph: BELGraph) -> SetOfNodePairs: """Find pairs of nodes that have mutual causal edges that are increasing each other such that ``A -> B`` and ``B -> A``. :return: A set of pairs of nodes with mutual causal edges """ cg = get_causal_subgraph(graph) results = set() ...
def get_chaotic_pairs(graph: BELGraph) -> SetOfNodePairs: """Find pairs of nodes that have mutual causal edges that are increasing each other such that ``A -> B`` and ``B -> A``. :return: A set of pairs of nodes with mutual causal edges """ cg = get_causal_subgraph(graph) results = set() ...
[ "Find", "pairs", "of", "nodes", "that", "have", "mutual", "causal", "edges", "that", "are", "increasing", "each", "other", "such", "that", "A", "-", ">", "B", "and", "B", "-", ">", "A", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L78-L95
[ "def", "get_chaotic_pairs", "(", "graph", ":", "BELGraph", ")", "->", "SetOfNodePairs", ":", "cg", "=", "get_causal_subgraph", "(", "graph", ")", "results", "=", "set", "(", ")", "for", "u", ",", "v", ",", "d", "in", "cg", ".", "edges", "(", "data", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_correlation_graph
Extract an undirected graph of only correlative relationships.
src/pybel_tools/analysis/stability.py
def get_correlation_graph(graph: BELGraph) -> Graph: """Extract an undirected graph of only correlative relationships.""" result = Graph() for u, v, d in graph.edges(data=True): if d[RELATION] not in CORRELATIVE_RELATIONS: continue if not result.has_edge(u, v): resu...
def get_correlation_graph(graph: BELGraph) -> Graph: """Extract an undirected graph of only correlative relationships.""" result = Graph() for u, v, d in graph.edges(data=True): if d[RELATION] not in CORRELATIVE_RELATIONS: continue if not result.has_edge(u, v): resu...
[ "Extract", "an", "undirected", "graph", "of", "only", "correlative", "relationships", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L118-L134
[ "def", "get_correlation_graph", "(", "graph", ":", "BELGraph", ")", "->", "Graph", ":", "result", "=", "Graph", "(", ")", "for", "u", ",", "v", ",", "d", "in", "graph", ".", "edges", "(", "data", "=", "True", ")", ":", "if", "d", "[", "RELATION", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_correlation_triangles
Return a set of all triangles pointed by the given node.
src/pybel_tools/analysis/stability.py
def get_correlation_triangles(graph: BELGraph) -> SetOfNodeTriples: """Return a set of all triangles pointed by the given node.""" return { tuple(sorted([n, u, v], key=str)) for n in graph for u, v in itt.combinations(graph[n], 2) if graph.has_edge(u, v) }
def get_correlation_triangles(graph: BELGraph) -> SetOfNodeTriples: """Return a set of all triangles pointed by the given node.""" return { tuple(sorted([n, u, v], key=str)) for n in graph for u, v in itt.combinations(graph[n], 2) if graph.has_edge(u, v) }
[ "Return", "a", "set", "of", "all", "triangles", "pointed", "by", "the", "given", "node", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L137-L144
[ "def", "get_correlation_triangles", "(", "graph", ":", "BELGraph", ")", "->", "SetOfNodeTriples", ":", "return", "{", "tuple", "(", "sorted", "(", "[", "n", ",", "u", ",", "v", "]", ",", "key", "=", "str", ")", ")", "for", "n", "in", "graph", "for", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_triangles
Get a set of triples representing the 3-cycles from a directional graph. Each 3-cycle is returned once, with nodes in sorted order.
src/pybel_tools/analysis/stability.py
def get_triangles(graph: DiGraph) -> SetOfNodeTriples: """Get a set of triples representing the 3-cycles from a directional graph. Each 3-cycle is returned once, with nodes in sorted order. """ return { tuple(sorted([a, b, c], key=str)) for a, b in graph.edges() for c in graph.s...
def get_triangles(graph: DiGraph) -> SetOfNodeTriples: """Get a set of triples representing the 3-cycles from a directional graph. Each 3-cycle is returned once, with nodes in sorted order. """ return { tuple(sorted([a, b, c], key=str)) for a, b in graph.edges() for c in graph.s...
[ "Get", "a", "set", "of", "triples", "representing", "the", "3", "-", "cycles", "from", "a", "directional", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L147-L157
[ "def", "get_triangles", "(", "graph", ":", "DiGraph", ")", "->", "SetOfNodeTriples", ":", "return", "{", "tuple", "(", "sorted", "(", "[", "a", ",", "b", ",", "c", "]", ",", "key", "=", "str", ")", ")", "for", "a", ",", "b", "in", "graph", ".", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_separate_unstable_correlation_triples
Yield all triples of nodes A, B, C such that ``A pos B``, ``A pos C``, and ``B neg C``. :return: An iterator over triples of unstable graphs, where the second two are negative
src/pybel_tools/analysis/stability.py
def get_separate_unstable_correlation_triples(graph: BELGraph) -> Iterable[NodeTriple]: """Yield all triples of nodes A, B, C such that ``A pos B``, ``A pos C``, and ``B neg C``. :return: An iterator over triples of unstable graphs, where the second two are negative """ cg = get_correlation_graph(graph...
def get_separate_unstable_correlation_triples(graph: BELGraph) -> Iterable[NodeTriple]: """Yield all triples of nodes A, B, C such that ``A pos B``, ``A pos C``, and ``B neg C``. :return: An iterator over triples of unstable graphs, where the second two are negative """ cg = get_correlation_graph(graph...
[ "Yield", "all", "triples", "of", "nodes", "A", "B", "C", "such", "that", "A", "pos", "B", "A", "pos", "C", "and", "B", "neg", "C", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L160-L176
[ "def", "get_separate_unstable_correlation_triples", "(", "graph", ":", "BELGraph", ")", "->", "Iterable", "[", "NodeTriple", "]", ":", "cg", "=", "get_correlation_graph", "(", "graph", ")", "for", "a", ",", "b", ",", "c", "in", "get_correlation_triangles", "(", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_mutually_unstable_correlation_triples
Yield triples of nodes (A, B, C) such that ``A neg B``, ``B neg C``, and ``C neg A``.
src/pybel_tools/analysis/stability.py
def get_mutually_unstable_correlation_triples(graph: BELGraph) -> Iterable[NodeTriple]: """Yield triples of nodes (A, B, C) such that ``A neg B``, ``B neg C``, and ``C neg A``.""" cg = get_correlation_graph(graph) for a, b, c in get_correlation_triangles(cg): if all(NEGATIVE_CORRELATION in x for x ...
def get_mutually_unstable_correlation_triples(graph: BELGraph) -> Iterable[NodeTriple]: """Yield triples of nodes (A, B, C) such that ``A neg B``, ``B neg C``, and ``C neg A``.""" cg = get_correlation_graph(graph) for a, b, c in get_correlation_triangles(cg): if all(NEGATIVE_CORRELATION in x for x ...
[ "Yield", "triples", "of", "nodes", "(", "A", "B", "C", ")", "such", "that", "A", "neg", "B", "B", "neg", "C", "and", "C", "neg", "A", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L179-L185
[ "def", "get_mutually_unstable_correlation_triples", "(", "graph", ":", "BELGraph", ")", "->", "Iterable", "[", "NodeTriple", "]", ":", "cg", "=", "get_correlation_graph", "(", "graph", ")", "for", "a", ",", "b", ",", "c", "in", "get_correlation_triangles", "(", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
jens_transformation_alpha
Apply Jens' transformation (Type 1) to the graph. 1. Induce a sub-graph over causal + correlative edges 2. Transform edges by the following rules: - increases => increases - decreases => backwards increases - positive correlation => two way increases - negative correlation => de...
src/pybel_tools/analysis/stability.py
def jens_transformation_alpha(graph: BELGraph) -> DiGraph: """Apply Jens' transformation (Type 1) to the graph. 1. Induce a sub-graph over causal + correlative edges 2. Transform edges by the following rules: - increases => increases - decreases => backwards increases - positive cor...
def jens_transformation_alpha(graph: BELGraph) -> DiGraph: """Apply Jens' transformation (Type 1) to the graph. 1. Induce a sub-graph over causal + correlative edges 2. Transform edges by the following rules: - increases => increases - decreases => backwards increases - positive cor...
[ "Apply", "Jens", "transformation", "(", "Type", "1", ")", "to", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L188-L216
[ "def", "jens_transformation_alpha", "(", "graph", ":", "BELGraph", ")", "->", "DiGraph", ":", "result", "=", "DiGraph", "(", ")", "for", "u", ",", "v", ",", "d", "in", "graph", ".", "edges", "(", "data", "=", "True", ")", ":", "relation", "=", "d", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
jens_transformation_beta
Apply Jens' Transformation (Type 2) to the graph. 1. Induce a sub-graph over causal and correlative relations 2. Transform edges with the following rules: - increases => backwards decreases - decreases => decreases - positive correlation => delete - negative correlation => two w...
src/pybel_tools/analysis/stability.py
def jens_transformation_beta(graph: BELGraph) -> DiGraph: """Apply Jens' Transformation (Type 2) to the graph. 1. Induce a sub-graph over causal and correlative relations 2. Transform edges with the following rules: - increases => backwards decreases - decreases => decreases - posit...
def jens_transformation_beta(graph: BELGraph) -> DiGraph: """Apply Jens' Transformation (Type 2) to the graph. 1. Induce a sub-graph over causal and correlative relations 2. Transform edges with the following rules: - increases => backwards decreases - decreases => decreases - posit...
[ "Apply", "Jens", "Transformation", "(", "Type", "2", ")", "to", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L219-L247
[ "def", "jens_transformation_beta", "(", "graph", ":", "BELGraph", ")", "->", "DiGraph", ":", "result", "=", "DiGraph", "(", ")", "for", "u", ",", "v", ",", "d", "in", "graph", ".", "edges", "(", "data", "=", "True", ")", ":", "relation", "=", "d", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_jens_unstable
Yield triples of nodes (A, B, C) where ``A -> B``, ``A -| C``, and ``C positiveCorrelation A``. Calculated efficiently using the Jens Transformation.
src/pybel_tools/analysis/stability.py
def get_jens_unstable(graph: BELGraph) -> Iterable[NodeTriple]: """Yield triples of nodes (A, B, C) where ``A -> B``, ``A -| C``, and ``C positiveCorrelation A``. Calculated efficiently using the Jens Transformation. """ r = jens_transformation_alpha(graph) return get_triangles(r)
def get_jens_unstable(graph: BELGraph) -> Iterable[NodeTriple]: """Yield triples of nodes (A, B, C) where ``A -> B``, ``A -| C``, and ``C positiveCorrelation A``. Calculated efficiently using the Jens Transformation. """ r = jens_transformation_alpha(graph) return get_triangles(r)
[ "Yield", "triples", "of", "nodes", "(", "A", "B", "C", ")", "where", "A", "-", ">", "B", "A", "-", "|", "C", "and", "C", "positiveCorrelation", "A", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L250-L256
[ "def", "get_jens_unstable", "(", "graph", ":", "BELGraph", ")", "->", "Iterable", "[", "NodeTriple", "]", ":", "r", "=", "jens_transformation_alpha", "(", "graph", ")", "return", "get_triangles", "(", "r", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
summarize_stability
Summarize the stability of the graph.
src/pybel_tools/analysis/stability.py
def summarize_stability(graph: BELGraph) -> Mapping[str, int]: """Summarize the stability of the graph.""" regulatory_pairs = get_regulatory_pairs(graph) chaotic_pairs = get_chaotic_pairs(graph) dampened_pairs = get_dampened_pairs(graph) contraditory_pairs = get_contradiction_summary(graph) sepa...
def summarize_stability(graph: BELGraph) -> Mapping[str, int]: """Summarize the stability of the graph.""" regulatory_pairs = get_regulatory_pairs(graph) chaotic_pairs = get_chaotic_pairs(graph) dampened_pairs = get_dampened_pairs(graph) contraditory_pairs = get_contradiction_summary(graph) sepa...
[ "Summarize", "the", "stability", "of", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/stability.py#L314-L340
[ "def", "summarize_stability", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "int", "]", ":", "regulatory_pairs", "=", "get_regulatory_pairs", "(", "graph", ")", "chaotic_pairs", "=", "get_chaotic_pairs", "(", "graph", ")", "dampened_pairs...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
flatten_list_abundance
Flattens the complex or composite abundance.
src/pybel_tools/node_utils.py
def flatten_list_abundance(node: ListAbundance) -> ListAbundance: """Flattens the complex or composite abundance.""" return node.__class__(list(chain.from_iterable( ( flatten_list_abundance(member).members if isinstance(member, ListAbundance) else [member] ) ...
def flatten_list_abundance(node: ListAbundance) -> ListAbundance: """Flattens the complex or composite abundance.""" return node.__class__(list(chain.from_iterable( ( flatten_list_abundance(member).members if isinstance(member, ListAbundance) else [member] ) ...
[ "Flattens", "the", "complex", "or", "composite", "abundance", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L24-L33
[ "def", "flatten_list_abundance", "(", "node", ":", "ListAbundance", ")", "->", "ListAbundance", ":", "return", "node", ".", "__class__", "(", "list", "(", "chain", ".", "from_iterable", "(", "(", "flatten_list_abundance", "(", "member", ")", ".", "members", "i...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
list_abundance_expansion
Flatten list abundances.
src/pybel_tools/node_utils.py
def list_abundance_expansion(graph: BELGraph) -> None: """Flatten list abundances.""" mapping = { node: flatten_list_abundance(node) for node in graph if isinstance(node, ListAbundance) } relabel_nodes(graph, mapping, copy=False)
def list_abundance_expansion(graph: BELGraph) -> None: """Flatten list abundances.""" mapping = { node: flatten_list_abundance(node) for node in graph if isinstance(node, ListAbundance) } relabel_nodes(graph, mapping, copy=False)
[ "Flatten", "list", "abundances", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L36-L43
[ "def", "list_abundance_expansion", "(", "graph", ":", "BELGraph", ")", "->", "None", ":", "mapping", "=", "{", "node", ":", "flatten_list_abundance", "(", "node", ")", "for", "node", "in", "graph", "if", "isinstance", "(", "node", ",", "ListAbundance", ")", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
list_abundance_cartesian_expansion
Expand all list abundances to simple subject-predicate-object networks.
src/pybel_tools/node_utils.py
def list_abundance_cartesian_expansion(graph: BELGraph) -> None: """Expand all list abundances to simple subject-predicate-object networks.""" for u, v, k, d in list(graph.edges(keys=True, data=True)): if CITATION not in d: continue if isinstance(u, ListAbundance) and isinstance(v, ...
def list_abundance_cartesian_expansion(graph: BELGraph) -> None: """Expand all list abundances to simple subject-predicate-object networks.""" for u, v, k, d in list(graph.edges(keys=True, data=True)): if CITATION not in d: continue if isinstance(u, ListAbundance) and isinstance(v, ...
[ "Expand", "all", "list", "abundances", "to", "simple", "subject", "-", "predicate", "-", "object", "networks", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L46-L82
[ "def", "list_abundance_cartesian_expansion", "(", "graph", ":", "BELGraph", ")", "->", "None", ":", "for", "u", ",", "v", ",", "k", ",", "d", "in", "list", "(", "graph", ".", "edges", "(", "keys", "=", "True", ",", "data", "=", "True", ")", ")", ":...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_reaction_cartesion_expansion_unqualified_helper
Helper to deal with cartension expansion in unqualified edges.
src/pybel_tools/node_utils.py
def _reaction_cartesion_expansion_unqualified_helper( graph: BELGraph, u: BaseEntity, v: BaseEntity, d: dict, ) -> None: """Helper to deal with cartension expansion in unqualified edges.""" if isinstance(u, Reaction) and isinstance(v, Reaction): enzymes = _get_catalysts_i...
def _reaction_cartesion_expansion_unqualified_helper( graph: BELGraph, u: BaseEntity, v: BaseEntity, d: dict, ) -> None: """Helper to deal with cartension expansion in unqualified edges.""" if isinstance(u, Reaction) and isinstance(v, Reaction): enzymes = _get_catalysts_i...
[ "Helper", "to", "deal", "with", "cartension", "expansion", "in", "unqualified", "edges", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L85-L152
[ "def", "_reaction_cartesion_expansion_unqualified_helper", "(", "graph", ":", "BELGraph", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "d", ":", "dict", ",", ")", "->", "None", ":", "if", "isinstance", "(", "u", ",", "Reaction", ")", "and...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_get_catalysts_in_reaction
Return nodes that are both in reactants and reactions in a reaction.
src/pybel_tools/node_utils.py
def _get_catalysts_in_reaction(reaction: Reaction) -> Set[BaseAbundance]: """Return nodes that are both in reactants and reactions in a reaction.""" return { reactant for reactant in reaction.reactants if reactant in reaction.products }
def _get_catalysts_in_reaction(reaction: Reaction) -> Set[BaseAbundance]: """Return nodes that are both in reactants and reactions in a reaction.""" return { reactant for reactant in reaction.reactants if reactant in reaction.products }
[ "Return", "nodes", "that", "are", "both", "in", "reactants", "and", "reactions", "in", "a", "reaction", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L155-L161
[ "def", "_get_catalysts_in_reaction", "(", "reaction", ":", "Reaction", ")", "->", "Set", "[", "BaseAbundance", "]", ":", "return", "{", "reactant", "for", "reactant", "in", "reaction", ".", "reactants", "if", "reactant", "in", "reaction", ".", "products", "}" ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
reaction_cartesian_expansion
Expand all reactions to simple subject-predicate-object networks.
src/pybel_tools/node_utils.py
def reaction_cartesian_expansion(graph: BELGraph, accept_unqualified_edges: bool = True) -> None: """Expand all reactions to simple subject-predicate-object networks.""" for u, v, d in list(graph.edges(data=True)): # Deal with unqualified edges if CITATION not in d and accept_unqualified_edges: ...
def reaction_cartesian_expansion(graph: BELGraph, accept_unqualified_edges: bool = True) -> None: """Expand all reactions to simple subject-predicate-object networks.""" for u, v, d in list(graph.edges(data=True)): # Deal with unqualified edges if CITATION not in d and accept_unqualified_edges: ...
[ "Expand", "all", "reactions", "to", "simple", "subject", "-", "predicate", "-", "object", "networks", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/node_utils.py#L164-L248
[ "def", "reaction_cartesian_expansion", "(", "graph", ":", "BELGraph", ",", "accept_unqualified_edges", ":", "bool", "=", "True", ")", "->", "None", ":", "for", "u", ",", "v", ",", "d", "in", "list", "(", "graph", ".", "edges", "(", "data", "=", "True", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
DictManager.insert_graph
Insert a graph and return the resulting ORM object (mocked).
src/pybel_tools/dict_manager.py
def insert_graph(self, graph: BELGraph, **_kwargs) -> Network: """Insert a graph and return the resulting ORM object (mocked).""" result = _Namespace() result.id = len(self.networks) self.networks[result.id] = graph return result
def insert_graph(self, graph: BELGraph, **_kwargs) -> Network: """Insert a graph and return the resulting ORM object (mocked).""" result = _Namespace() result.id = len(self.networks) self.networks[result.id] = graph return result
[ "Insert", "a", "graph", "and", "return", "the", "resulting", "ORM", "object", "(", "mocked", ")", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/dict_manager.py#L26-L33
[ "def", "insert_graph", "(", "self", ",", "graph", ":", "BELGraph", ",", "*", "*", "_kwargs", ")", "->", "Network", ":", "result", "=", "_Namespace", "(", ")", "result", ".", "id", "=", "len", "(", "self", ".", "networks", ")", "self", ".", "networks"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
DictManager.get_graphs_by_ids
Get several graphs by their identifiers.
src/pybel_tools/dict_manager.py
def get_graphs_by_ids(self, network_ids: Iterable[int]) -> List[BELGraph]: """Get several graphs by their identifiers.""" return [ self.networks[network_id] for network_id in network_ids ]
def get_graphs_by_ids(self, network_ids: Iterable[int]) -> List[BELGraph]: """Get several graphs by their identifiers.""" return [ self.networks[network_id] for network_id in network_ids ]
[ "Get", "several", "graphs", "by", "their", "identifiers", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/dict_manager.py#L39-L44
[ "def", "get_graphs_by_ids", "(", "self", ",", "network_ids", ":", "Iterable", "[", "int", "]", ")", "->", "List", "[", "BELGraph", "]", ":", "return", "[", "self", ".", "networks", "[", "network_id", "]", "for", "network_id", "in", "network_ids", "]" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_generate_citation_dict
Prepare a citation data dictionary from a graph. :return: A dictionary of dictionaries {citation type: {(source, target): citation reference}
src/pybel_tools/summary/provenance.py
def _generate_citation_dict(graph: BELGraph) -> Mapping[str, Mapping[Tuple[BaseEntity, BaseEntity], str]]: """Prepare a citation data dictionary from a graph. :return: A dictionary of dictionaries {citation type: {(source, target): citation reference} """ results = defaultdict(lambda: defaultdict(set))...
def _generate_citation_dict(graph: BELGraph) -> Mapping[str, Mapping[Tuple[BaseEntity, BaseEntity], str]]: """Prepare a citation data dictionary from a graph. :return: A dictionary of dictionaries {citation type: {(source, target): citation reference} """ results = defaultdict(lambda: defaultdict(set))...
[ "Prepare", "a", "citation", "data", "dictionary", "from", "a", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L43-L55
[ "def", "_generate_citation_dict", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Mapping", "[", "Tuple", "[", "BaseEntity", ",", "BaseEntity", "]", ",", "str", "]", "]", ":", "results", "=", "defaultdict", "(", "lambda", ":", "def...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_pmid_by_keyword
Get the set of PubMed identifiers beginning with the given keyword string. :param keyword: The beginning of a PubMed identifier :param graph: A BEL graph :param pubmed_identifiers: A set of pre-cached PubMed identifiers :return: A set of PubMed identifiers starting with the given string
src/pybel_tools/summary/provenance.py
def get_pmid_by_keyword(keyword: str, graph: Optional[BELGraph] = None, pubmed_identifiers: Optional[Set[str]] = None, ) -> Set[str]: """Get the set of PubMed identifiers beginning with the given keyword string. :param keyword: The beg...
def get_pmid_by_keyword(keyword: str, graph: Optional[BELGraph] = None, pubmed_identifiers: Optional[Set[str]] = None, ) -> Set[str]: """Get the set of PubMed identifiers beginning with the given keyword string. :param keyword: The beg...
[ "Get", "the", "set", "of", "PubMed", "identifiers", "beginning", "with", "the", "given", "keyword", "string", ".", ":", "param", "keyword", ":", "The", "beginning", "of", "a", "PubMed", "identifier", ":", "param", "graph", ":", "A", "BEL", "graph", ":", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L58-L83
[ "def", "get_pmid_by_keyword", "(", "keyword", ":", "str", ",", "graph", ":", "Optional", "[", "BELGraph", "]", "=", "None", ",", "pubmed_identifiers", ":", "Optional", "[", "Set", "[", "str", "]", "]", "=", "None", ",", ")", "->", "Set", "[", "str", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_citations
Counts the citations in a graph based on a given filter :param graph: A BEL graph :param dict annotations: The annotation filters to use :return: A counter from {(citation type, citation reference): frequency}
src/pybel_tools/summary/provenance.py
def count_citations(graph: BELGraph, **annotations) -> Counter: """Counts the citations in a graph based on a given filter :param graph: A BEL graph :param dict annotations: The annotation filters to use :return: A counter from {(citation type, citation reference): frequency} """ citations = de...
def count_citations(graph: BELGraph, **annotations) -> Counter: """Counts the citations in a graph based on a given filter :param graph: A BEL graph :param dict annotations: The annotation filters to use :return: A counter from {(citation type, citation reference): frequency} """ citations = de...
[ "Counts", "the", "citations", "in", "a", "graph", "based", "on", "a", "given", "filter" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L94-L111
[ "def", "count_citations", "(", "graph", ":", "BELGraph", ",", "*", "*", "annotations", ")", "->", "Counter", ":", "citations", "=", "defaultdict", "(", "set", ")", "annotation_dict_filter", "=", "build_edge_data_filter", "(", "annotations", ")", "for", "u", ",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_citations_by_annotation
Group the citation counters by subgraphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Counters {subgraph name: Counter from {citation: frequency}}
src/pybel_tools/summary/provenance.py
def count_citations_by_annotation(graph: BELGraph, annotation: str) -> Mapping[str, typing.Counter[str]]: """Group the citation counters by subgraphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Counters {subgr...
def count_citations_by_annotation(graph: BELGraph, annotation: str) -> Mapping[str, typing.Counter[str]]: """Group the citation counters by subgraphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Counters {subgr...
[ "Group", "the", "citation", "counters", "by", "subgraphs", "induced", "by", "the", "annotation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L114-L130
[ "def", "count_citations_by_annotation", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", ")", "->", "Mapping", "[", "str", ",", "typing", ".", "Counter", "[", "str", "]", "]", ":", "citations", "=", "defaultdict", "(", "lambda", ":", "defaultd...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_author_publications
Count the number of publications of each author to the given graph.
src/pybel_tools/summary/provenance.py
def count_author_publications(graph: BELGraph) -> typing.Counter[str]: """Count the number of publications of each author to the given graph.""" authors = group_as_dict(_iter_author_publiations(graph)) return Counter(count_dict_values(count_defaultdict(authors)))
def count_author_publications(graph: BELGraph) -> typing.Counter[str]: """Count the number of publications of each author to the given graph.""" authors = group_as_dict(_iter_author_publiations(graph)) return Counter(count_dict_values(count_defaultdict(authors)))
[ "Count", "the", "number", "of", "publications", "of", "each", "author", "to", "the", "given", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L138-L141
[ "def", "count_author_publications", "(", "graph", ":", "BELGraph", ")", "->", "typing", ".", "Counter", "[", "str", "]", ":", "authors", "=", "group_as_dict", "(", "_iter_author_publiations", "(", "graph", ")", ")", "return", "Counter", "(", "count_dict_values",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_authors_by_keyword
Get authors for whom the search term is a substring. :param pybel.BELGraph graph: A BEL graph :param keyword: The keyword to search the author strings for :param set[str] authors: An optional set of pre-cached authors calculated from the graph :return: A set of authors with the keyword as a substri...
src/pybel_tools/summary/provenance.py
def get_authors_by_keyword(keyword: str, graph=None, authors=None) -> Set[str]: """Get authors for whom the search term is a substring. :param pybel.BELGraph graph: A BEL graph :param keyword: The keyword to search the author strings for :param set[str] authors: An optional set of pre-cached author...
def get_authors_by_keyword(keyword: str, graph=None, authors=None) -> Set[str]: """Get authors for whom the search term is a substring. :param pybel.BELGraph graph: A BEL graph :param keyword: The keyword to search the author strings for :param set[str] authors: An optional set of pre-cached author...
[ "Get", "authors", "for", "whom", "the", "search", "term", "is", "a", "substring", ".", ":", "param", "pybel", ".", "BELGraph", "graph", ":", "A", "BEL", "graph", ":", "param", "keyword", ":", "The", "keyword", "to", "search", "the", "author", "strings", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L160-L184
[ "def", "get_authors_by_keyword", "(", "keyword", ":", "str", ",", "graph", "=", "None", ",", "authors", "=", "None", ")", "->", "Set", "[", "str", "]", ":", "keyword_lower", "=", "keyword", ".", "lower", "(", ")", "if", "authors", "is", "not", "None", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_authors_by_annotation
Group the author counters by sub-graphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Counters {subgraph name: Counter from {author: frequency}}
src/pybel_tools/summary/provenance.py
def count_authors_by_annotation(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, typing.Counter[str]]: """Group the author counters by sub-graphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Count...
def count_authors_by_annotation(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, typing.Counter[str]]: """Group the author counters by sub-graphs induced by the annotation. :param graph: A BEL graph :param annotation: The annotation to use to group the graph :return: A dictionary of Count...
[ "Group", "the", "author", "counters", "by", "sub", "-", "graphs", "induced", "by", "the", "annotation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L187-L195
[ "def", "count_authors_by_annotation", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", "->", "Mapping", "[", "str", ",", "typing", ".", "Counter", "[", "str", "]", "]", ":", "authors", "=", "group_as_dict", "(", "_iter_...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_evidences_by_pmid
Get a dictionary from the given PubMed identifiers to the sets of all evidence strings associated with each in the graph. :param graph: A BEL graph :param pmids: An iterable of PubMed identifiers, as strings. Is consumed and converted to a set. :return: A dictionary of {pmid: set of all evidence string...
src/pybel_tools/summary/provenance.py
def get_evidences_by_pmid(graph: BELGraph, pmids: Union[str, Iterable[str]]): """Get a dictionary from the given PubMed identifiers to the sets of all evidence strings associated with each in the graph. :param graph: A BEL graph :param pmids: An iterable of PubMed identifiers, as strings. Is consumed a...
def get_evidences_by_pmid(graph: BELGraph, pmids: Union[str, Iterable[str]]): """Get a dictionary from the given PubMed identifiers to the sets of all evidence strings associated with each in the graph. :param graph: A BEL graph :param pmids: An iterable of PubMed identifiers, as strings. Is consumed a...
[ "Get", "a", "dictionary", "from", "the", "given", "PubMed", "identifiers", "to", "the", "sets", "of", "all", "evidence", "strings", "associated", "with", "each", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L206-L220
[ "def", "get_evidences_by_pmid", "(", "graph", ":", "BELGraph", ",", "pmids", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ")", ":", "result", "=", "defaultdict", "(", "set", ")", "for", "_", ",", "_", ",", "_", ",", "data", "in"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_citation_years
Count the number of citations from each year.
src/pybel_tools/summary/provenance.py
def count_citation_years(graph: BELGraph) -> typing.Counter[int]: """Count the number of citations from each year.""" result = defaultdict(set) for _, _, data in graph.edges(data=True): if CITATION not in data or CITATION_DATE not in data[CITATION]: continue try: dt...
def count_citation_years(graph: BELGraph) -> typing.Counter[int]: """Count the number of citations from each year.""" result = defaultdict(set) for _, _, data in graph.edges(data=True): if CITATION not in data or CITATION_DATE not in data[CITATION]: continue try: dt...
[ "Count", "the", "number", "of", "citations", "from", "each", "year", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L224-L238
[ "def", "count_citation_years", "(", "graph", ":", "BELGraph", ")", "->", "typing", ".", "Counter", "[", "int", "]", ":", "result", "=", "defaultdict", "(", "set", ")", "for", "_", ",", "_", ",", "data", "in", "graph", ".", "edges", "(", "data", "=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_citation_years
Create a citation timeline counter from the graph.
src/pybel_tools/summary/provenance.py
def get_citation_years(graph: BELGraph) -> List[Tuple[int, int]]: """Create a citation timeline counter from the graph.""" return create_timeline(count_citation_years(graph))
def get_citation_years(graph: BELGraph) -> List[Tuple[int, int]]: """Create a citation timeline counter from the graph.""" return create_timeline(count_citation_years(graph))
[ "Create", "a", "citation", "timeline", "counter", "from", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L251-L253
[ "def", "get_citation_years", "(", "graph", ":", "BELGraph", ")", "->", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "return", "create_timeline", "(", "count_citation_years", "(", "graph", ")", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
create_timeline
Complete the Counter timeline. :param Counter year_counter: counter dict for each year :return: complete timeline
src/pybel_tools/summary/provenance.py
def create_timeline(year_counter: typing.Counter[int]) -> List[Tuple[int, int]]: """Complete the Counter timeline. :param Counter year_counter: counter dict for each year :return: complete timeline """ if not year_counter: return [] from_year = min(year_counter) - 1 until_year = da...
def create_timeline(year_counter: typing.Counter[int]) -> List[Tuple[int, int]]: """Complete the Counter timeline. :param Counter year_counter: counter dict for each year :return: complete timeline """ if not year_counter: return [] from_year = min(year_counter) - 1 until_year = da...
[ "Complete", "the", "Counter", "timeline", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L256-L271
[ "def", "create_timeline", "(", "year_counter", ":", "typing", ".", "Counter", "[", "int", "]", ")", "->", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ":", "if", "not", "year_counter", ":", "return", "[", "]", "from_year", "=", "min", "(",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_confidences
Count the confidences in the graph.
src/pybel_tools/summary/provenance.py
def count_confidences(graph: BELGraph) -> typing.Counter[str]: """Count the confidences in the graph.""" return Counter( ( 'None' if ANNOTATIONS not in data or 'Confidence' not in data[ANNOTATIONS] else list(data[ANNOTATIONS]['Confidence'])[0] ) for _,...
def count_confidences(graph: BELGraph) -> typing.Counter[str]: """Count the confidences in the graph.""" return Counter( ( 'None' if ANNOTATIONS not in data or 'Confidence' not in data[ANNOTATIONS] else list(data[ANNOTATIONS]['Confidence'])[0] ) for _,...
[ "Count", "the", "confidences", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/provenance.py#L274-L284
[ "def", "count_confidences", "(", "graph", ":", "BELGraph", ")", "->", "typing", ".", "Counter", "[", "str", "]", ":", "return", "Counter", "(", "(", "'None'", "if", "ANNOTATIONS", "not", "in", "data", "or", "'Confidence'", "not", "in", "data", "[", "ANNO...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_pubmed_citations
Overwrite all PubMed citations with values from NCBI's eUtils lookup service. :return: A set of PMIDs for which the eUtils service crashed
src/pybel_tools/mutation/metadata.py
def enrich_pubmed_citations(graph: BELGraph, manager: Manager) -> Set[str]: """Overwrite all PubMed citations with values from NCBI's eUtils lookup service. :return: A set of PMIDs for which the eUtils service crashed """ pmids = get_pubmed_identifiers(graph) pmid_data, errors = get_citations_by_pm...
def enrich_pubmed_citations(graph: BELGraph, manager: Manager) -> Set[str]: """Overwrite all PubMed citations with values from NCBI's eUtils lookup service. :return: A set of PMIDs for which the eUtils service crashed """ pmids = get_pubmed_identifiers(graph) pmid_data, errors = get_citations_by_pm...
[ "Overwrite", "all", "PubMed", "citations", "with", "values", "from", "NCBI", "s", "eUtils", "lookup", "service", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/metadata.py#L23-L41
[ "def", "enrich_pubmed_citations", "(", "graph", ":", "BELGraph", ",", "manager", ":", "Manager", ")", "->", "Set", "[", "str", "]", ":", "pmids", "=", "get_pubmed_identifiers", "(", "graph", ")", "pmid_data", ",", "errors", "=", "get_citations_by_pmids", "(", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
update_context
Update the context of a subgraph from the universe of all knowledge.
src/pybel_tools/mutation/metadata.py
def update_context(universe: BELGraph, graph: BELGraph): """Update the context of a subgraph from the universe of all knowledge.""" for namespace in get_namespaces(graph): if namespace in universe.namespace_url: graph.namespace_url[namespace] = universe.namespace_url[namespace] elif ...
def update_context(universe: BELGraph, graph: BELGraph): """Update the context of a subgraph from the universe of all knowledge.""" for namespace in get_namespaces(graph): if namespace in universe.namespace_url: graph.namespace_url[namespace] = universe.namespace_url[namespace] elif ...
[ "Update", "the", "context", "of", "a", "subgraph", "from", "the", "universe", "of", "all", "knowledge", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/metadata.py#L45-L63
[ "def", "update_context", "(", "universe", ":", "BELGraph", ",", "graph", ":", "BELGraph", ")", ":", "for", "namespace", "in", "get_namespaces", "(", "graph", ")", ":", "if", "namespace", "in", "universe", ".", "namespace_url", ":", "graph", ".", "namespace_u...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
highlight_nodes
Adds a highlight tag to the given nodes. :param graph: A BEL graph :param nodes: The nodes to add a highlight tag on :param color: The color to highlight (use something that works with CSS)
src/pybel_tools/mutation/highlight.py
def highlight_nodes(graph: BELGraph, nodes: Optional[Iterable[BaseEntity]] = None, color: Optional[str]=None): """Adds a highlight tag to the given nodes. :param graph: A BEL graph :param nodes: The nodes to add a highlight tag on :param color: The color to highlight (use something that works with CSS)...
def highlight_nodes(graph: BELGraph, nodes: Optional[Iterable[BaseEntity]] = None, color: Optional[str]=None): """Adds a highlight tag to the given nodes. :param graph: A BEL graph :param nodes: The nodes to add a highlight tag on :param color: The color to highlight (use something that works with CSS)...
[ "Adds", "a", "highlight", "tag", "to", "the", "given", "nodes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L29-L38
[ "def", "highlight_nodes", "(", "graph", ":", "BELGraph", ",", "nodes", ":", "Optional", "[", "Iterable", "[", "BaseEntity", "]", "]", "=", "None", ",", "color", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "color", "=", "color", "or", "NO...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
is_node_highlighted
Returns if the given node is highlighted. :param graph: A BEL graph :param node: A BEL node :type node: tuple :return: Does the node contain highlight information? :rtype: bool
src/pybel_tools/mutation/highlight.py
def is_node_highlighted(graph: BELGraph, node: BaseEntity) -> bool: """Returns if the given node is highlighted. :param graph: A BEL graph :param node: A BEL node :type node: tuple :return: Does the node contain highlight information? :rtype: bool """ return NODE_HIGHLIGHT in graph.node...
def is_node_highlighted(graph: BELGraph, node: BaseEntity) -> bool: """Returns if the given node is highlighted. :param graph: A BEL graph :param node: A BEL node :type node: tuple :return: Does the node contain highlight information? :rtype: bool """ return NODE_HIGHLIGHT in graph.node...
[ "Returns", "if", "the", "given", "node", "is", "highlighted", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L41-L50
[ "def", "is_node_highlighted", "(", "graph", ":", "BELGraph", ",", "node", ":", "BaseEntity", ")", "->", "bool", ":", "return", "NODE_HIGHLIGHT", "in", "graph", ".", "node", "[", "node", "]" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_highlight_nodes
Removes the highlight from the given nodes, or all nodes if none given. :param graph: A BEL graph :param nodes: The list of nodes to un-highlight
src/pybel_tools/mutation/highlight.py
def remove_highlight_nodes(graph: BELGraph, nodes: Optional[Iterable[BaseEntity]]=None) -> None: """Removes the highlight from the given nodes, or all nodes if none given. :param graph: A BEL graph :param nodes: The list of nodes to un-highlight """ for node in graph if nodes is None else nodes: ...
def remove_highlight_nodes(graph: BELGraph, nodes: Optional[Iterable[BaseEntity]]=None) -> None: """Removes the highlight from the given nodes, or all nodes if none given. :param graph: A BEL graph :param nodes: The list of nodes to un-highlight """ for node in graph if nodes is None else nodes: ...
[ "Removes", "the", "highlight", "from", "the", "given", "nodes", "or", "all", "nodes", "if", "none", "given", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L54-L62
[ "def", "remove_highlight_nodes", "(", "graph", ":", "BELGraph", ",", "nodes", ":", "Optional", "[", "Iterable", "[", "BaseEntity", "]", "]", "=", "None", ")", "->", "None", ":", "for", "node", "in", "graph", "if", "nodes", "is", "None", "else", "nodes", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
highlight_edges
Adds a highlight tag to the given edges. :param graph: A BEL graph :param edges: The edges (4-tuples of u, v, k, d) to add a highlight tag on :type edges: iter[tuple] :param str color: The color to highlight (use something that works with CSS)
src/pybel_tools/mutation/highlight.py
def highlight_edges(graph: BELGraph, edges=None, color: Optional[str]=None) -> None: """Adds a highlight tag to the given edges. :param graph: A BEL graph :param edges: The edges (4-tuples of u, v, k, d) to add a highlight tag on :type edges: iter[tuple] :param str color: The color to highlight (us...
def highlight_edges(graph: BELGraph, edges=None, color: Optional[str]=None) -> None: """Adds a highlight tag to the given edges. :param graph: A BEL graph :param edges: The edges (4-tuples of u, v, k, d) to add a highlight tag on :type edges: iter[tuple] :param str color: The color to highlight (us...
[ "Adds", "a", "highlight", "tag", "to", "the", "given", "edges", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L66-L76
[ "def", "highlight_edges", "(", "graph", ":", "BELGraph", ",", "edges", "=", "None", ",", "color", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "color", "=", "color", "or", "EDGE_HIGHLIGHT_DEFAULT_COLOR", "for", "u", ",", "v", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
is_edge_highlighted
Returns if the given edge is highlighted. :param graph: A BEL graph :return: Does the edge contain highlight information? :rtype: bool
src/pybel_tools/mutation/highlight.py
def is_edge_highlighted(graph: BELGraph, u, v, k) -> bool: """Returns if the given edge is highlighted. :param graph: A BEL graph :return: Does the edge contain highlight information? :rtype: bool """ return EDGE_HIGHLIGHT in graph[u][v][k]
def is_edge_highlighted(graph: BELGraph, u, v, k) -> bool: """Returns if the given edge is highlighted. :param graph: A BEL graph :return: Does the edge contain highlight information? :rtype: bool """ return EDGE_HIGHLIGHT in graph[u][v][k]
[ "Returns", "if", "the", "given", "edge", "is", "highlighted", ".", ":", "param", "graph", ":", "A", "BEL", "graph", ":", "return", ":", "Does", "the", "edge", "contain", "highlight", "information?", ":", "rtype", ":", "bool" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L79-L86
[ "def", "is_edge_highlighted", "(", "graph", ":", "BELGraph", ",", "u", ",", "v", ",", "k", ")", "->", "bool", ":", "return", "EDGE_HIGHLIGHT", "in", "graph", "[", "u", "]", "[", "v", "]", "[", "k", "]" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_highlight_edges
Remove the highlight from the given edges, or all edges if none given. :param graph: A BEL graph :param edges: The edges (4-tuple of u,v,k,d) to remove the highlight from) :type edges: iter[tuple]
src/pybel_tools/mutation/highlight.py
def remove_highlight_edges(graph: BELGraph, edges=None): """Remove the highlight from the given edges, or all edges if none given. :param graph: A BEL graph :param edges: The edges (4-tuple of u,v,k,d) to remove the highlight from) :type edges: iter[tuple] """ for u, v, k, _ in graph.edges(keys...
def remove_highlight_edges(graph: BELGraph, edges=None): """Remove the highlight from the given edges, or all edges if none given. :param graph: A BEL graph :param edges: The edges (4-tuple of u,v,k,d) to remove the highlight from) :type edges: iter[tuple] """ for u, v, k, _ in graph.edges(keys...
[ "Remove", "the", "highlight", "from", "the", "given", "edges", "or", "all", "edges", "if", "none", "given", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L90-L99
[ "def", "remove_highlight_edges", "(", "graph", ":", "BELGraph", ",", "edges", "=", "None", ")", ":", "for", "u", ",", "v", ",", "k", ",", "_", "in", "graph", ".", "edges", "(", "keys", "=", "True", ",", "data", "=", "True", ")", "if", "edges", "i...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
highlight_subgraph
Highlight all nodes/edges in the universe that in the given graph. :param universe: The universe of knowledge :param graph: The BEL graph to mutate
src/pybel_tools/mutation/highlight.py
def highlight_subgraph(universe: BELGraph, graph: BELGraph): """Highlight all nodes/edges in the universe that in the given graph. :param universe: The universe of knowledge :param graph: The BEL graph to mutate """ highlight_nodes(universe, graph) highlight_edges(universe, graph.edges())
def highlight_subgraph(universe: BELGraph, graph: BELGraph): """Highlight all nodes/edges in the universe that in the given graph. :param universe: The universe of knowledge :param graph: The BEL graph to mutate """ highlight_nodes(universe, graph) highlight_edges(universe, graph.edges())
[ "Highlight", "all", "nodes", "/", "edges", "in", "the", "universe", "that", "in", "the", "given", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L103-L110
[ "def", "highlight_subgraph", "(", "universe", ":", "BELGraph", ",", "graph", ":", "BELGraph", ")", ":", "highlight_nodes", "(", "universe", ",", "graph", ")", "highlight_edges", "(", "universe", ",", "graph", ".", "edges", "(", ")", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_highlight_subgraph
Remove the highlight from all nodes/edges in the graph that are in the subgraph. :param graph: The BEL graph to mutate :param subgraph: The subgraph from which to remove the highlighting
src/pybel_tools/mutation/highlight.py
def remove_highlight_subgraph(graph: BELGraph, subgraph: BELGraph): """Remove the highlight from all nodes/edges in the graph that are in the subgraph. :param graph: The BEL graph to mutate :param subgraph: The subgraph from which to remove the highlighting """ remove_highlight_nodes(graph, subgrap...
def remove_highlight_subgraph(graph: BELGraph, subgraph: BELGraph): """Remove the highlight from all nodes/edges in the graph that are in the subgraph. :param graph: The BEL graph to mutate :param subgraph: The subgraph from which to remove the highlighting """ remove_highlight_nodes(graph, subgrap...
[ "Remove", "the", "highlight", "from", "all", "nodes", "/", "edges", "in", "the", "graph", "that", "are", "in", "the", "subgraph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/highlight.py#L114-L121
[ "def", "remove_highlight_subgraph", "(", "graph", ":", "BELGraph", ",", "subgraph", ":", "BELGraph", ")", ":", "remove_highlight_nodes", "(", "graph", ",", "subgraph", ".", "nodes", "(", ")", ")", "remove_highlight_edges", "(", "graph", ",", "subgraph", ".", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_causal_out_edges
Get the out-edges to the given node that are causal. :return: A set of (source, target) pairs where the source is the given node
src/pybel_tools/summary/node_properties.py
def get_causal_out_edges( graph: BELGraph, nbunch: Union[BaseEntity, Iterable[BaseEntity]], ) -> Set[Tuple[BaseEntity, BaseEntity]]: """Get the out-edges to the given node that are causal. :return: A set of (source, target) pairs where the source is the given node """ return { (...
def get_causal_out_edges( graph: BELGraph, nbunch: Union[BaseEntity, Iterable[BaseEntity]], ) -> Set[Tuple[BaseEntity, BaseEntity]]: """Get the out-edges to the given node that are causal. :return: A set of (source, target) pairs where the source is the given node """ return { (...
[ "Get", "the", "out", "-", "edges", "to", "the", "given", "node", "that", "are", "causal", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L37-L49
[ "def", "get_causal_out_edges", "(", "graph", ":", "BELGraph", ",", "nbunch", ":", "Union", "[", "BaseEntity", ",", "Iterable", "[", "BaseEntity", "]", "]", ",", ")", "->", "Set", "[", "Tuple", "[", "BaseEntity", ",", "BaseEntity", "]", "]", ":", "return"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_causal_source_nodes
Return a set of all nodes that have an in-degree of 0. This likely means that it is an external perturbagen and is not known to have any causal origin from within the biological system. These nodes are useful to identify because they generally don't provide any mechanistic insight.
src/pybel_tools/summary/node_properties.py
def get_causal_source_nodes(graph: BELGraph, func: str) -> Set[BaseEntity]: """Return a set of all nodes that have an in-degree of 0. This likely means that it is an external perturbagen and is not known to have any causal origin from within the biological system. These nodes are useful to identify because...
def get_causal_source_nodes(graph: BELGraph, func: str) -> Set[BaseEntity]: """Return a set of all nodes that have an in-degree of 0. This likely means that it is an external perturbagen and is not known to have any causal origin from within the biological system. These nodes are useful to identify because...
[ "Return", "a", "set", "of", "all", "nodes", "that", "have", "an", "in", "-", "degree", "of", "0", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L67-L77
[ "def", "get_causal_source_nodes", "(", "graph", ":", "BELGraph", ",", "func", ":", "str", ")", "->", "Set", "[", "BaseEntity", "]", ":", "return", "{", "node", "for", "node", "in", "graph", "if", "node", ".", "function", "==", "func", "and", "is_causal_s...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_causal_central_nodes
Return a set of all nodes that have both an in-degree > 0 and out-degree > 0. This means that they are an integral part of a pathway, since they are both produced and consumed.
src/pybel_tools/summary/node_properties.py
def get_causal_central_nodes(graph: BELGraph, func: str) -> Set[BaseEntity]: """Return a set of all nodes that have both an in-degree > 0 and out-degree > 0. This means that they are an integral part of a pathway, since they are both produced and consumed. """ return { node for node in ...
def get_causal_central_nodes(graph: BELGraph, func: str) -> Set[BaseEntity]: """Return a set of all nodes that have both an in-degree > 0 and out-degree > 0. This means that they are an integral part of a pathway, since they are both produced and consumed. """ return { node for node in ...
[ "Return", "a", "set", "of", "all", "nodes", "that", "have", "both", "an", "in", "-", "degree", ">", "0", "and", "out", "-", "degree", ">", "0", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L80-L89
[ "def", "get_causal_central_nodes", "(", "graph", ":", "BELGraph", ",", "func", ":", "str", ")", "->", "Set", "[", "BaseEntity", "]", ":", "return", "{", "node", "for", "node", "in", "graph", "if", "node", ".", "function", "==", "func", "and", "is_causal_...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_causal_sink_nodes
Returns a set of all ABUNDANCE nodes that have an causal out-degree of 0. This likely means that the knowledge assembly is incomplete, or there is a curation error.
src/pybel_tools/summary/node_properties.py
def get_causal_sink_nodes(graph: BELGraph, func) -> Set[BaseEntity]: """Returns a set of all ABUNDANCE nodes that have an causal out-degree of 0. This likely means that the knowledge assembly is incomplete, or there is a curation error. """ return { node for node in graph if nod...
def get_causal_sink_nodes(graph: BELGraph, func) -> Set[BaseEntity]: """Returns a set of all ABUNDANCE nodes that have an causal out-degree of 0. This likely means that the knowledge assembly is incomplete, or there is a curation error. """ return { node for node in graph if nod...
[ "Returns", "a", "set", "of", "all", "ABUNDANCE", "nodes", "that", "have", "an", "causal", "out", "-", "degree", "of", "0", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L92-L101
[ "def", "get_causal_sink_nodes", "(", "graph", ":", "BELGraph", ",", "func", ")", "->", "Set", "[", "BaseEntity", "]", ":", "return", "{", "node", "for", "node", "in", "graph", "if", "node", ".", "function", "==", "func", "and", "is_causal_sink", "(", "gr...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_top_centrality
Get top centrality dictionary.
src/pybel_tools/summary/node_properties.py
def count_top_centrality(graph: BELGraph, number: Optional[int] = 30) -> Mapping[BaseEntity, int]: """Get top centrality dictionary.""" dd = nx.betweenness_centrality(graph) dc = Counter(dd) return dict(dc.most_common(number))
def count_top_centrality(graph: BELGraph, number: Optional[int] = 30) -> Mapping[BaseEntity, int]: """Get top centrality dictionary.""" dd = nx.betweenness_centrality(graph) dc = Counter(dd) return dict(dc.most_common(number))
[ "Get", "top", "centrality", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L125-L129
[ "def", "count_top_centrality", "(", "graph", ":", "BELGraph", ",", "number", ":", "Optional", "[", "int", "]", "=", "30", ")", "->", "Mapping", "[", "BaseEntity", ",", "int", "]", ":", "dd", "=", "nx", ".", "betweenness_centrality", "(", "graph", ")", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_modifications_count
Get a modifications count dictionary.
src/pybel_tools/summary/node_properties.py
def get_modifications_count(graph: BELGraph) -> Mapping[str, int]: """Get a modifications count dictionary.""" return remove_falsy_values({ 'Translocations': len(get_translocated(graph)), 'Degradations': len(get_degradations(graph)), 'Molecular Activities': len(get_activities(graph)), ...
def get_modifications_count(graph: BELGraph) -> Mapping[str, int]: """Get a modifications count dictionary.""" return remove_falsy_values({ 'Translocations': len(get_translocated(graph)), 'Degradations': len(get_degradations(graph)), 'Molecular Activities': len(get_activities(graph)), ...
[ "Get", "a", "modifications", "count", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L132-L138
[ "def", "get_modifications_count", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "int", "]", ":", "return", "remove_falsy_values", "(", "{", "'Translocations'", ":", "len", "(", "get_translocated", "(", "graph", ")", ")", ",", "'Degrad...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_falsy_values
Remove all values that are zero.
src/pybel_tools/summary/node_properties.py
def remove_falsy_values(counter: Mapping[Any, int]) -> Mapping[Any, int]: """Remove all values that are zero.""" return { label: count for label, count in counter.items() if count }
def remove_falsy_values(counter: Mapping[Any, int]) -> Mapping[Any, int]: """Remove all values that are zero.""" return { label: count for label, count in counter.items() if count }
[ "Remove", "all", "values", "that", "are", "zero", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/node_properties.py#L141-L147
[ "def", "remove_falsy_values", "(", "counter", ":", "Mapping", "[", "Any", ",", "int", "]", ")", "->", "Mapping", "[", "Any", ",", "int", "]", ":", "return", "{", "label", ":", "count", "for", "label", ",", "count", "in", "counter", ".", "items", "(",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_collapse_variants_by_function
Collapse all of the given functions' variants' edges to their parents, in-place.
src/pybel_tools/mutation/collapse.py
def _collapse_variants_by_function(graph: BELGraph, func: str) -> None: """Collapse all of the given functions' variants' edges to their parents, in-place.""" for parent_node, variant_node, data in graph.edges(data=True): if data[RELATION] == HAS_VARIANT and parent_node.function == func: col...
def _collapse_variants_by_function(graph: BELGraph, func: str) -> None: """Collapse all of the given functions' variants' edges to their parents, in-place.""" for parent_node, variant_node, data in graph.edges(data=True): if data[RELATION] == HAS_VARIANT and parent_node.function == func: col...
[ "Collapse", "all", "of", "the", "given", "functions", "variants", "edges", "to", "their", "parents", "in", "-", "place", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L50-L54
[ "def", "_collapse_variants_by_function", "(", "graph", ":", "BELGraph", ",", "func", ":", "str", ")", "->", "None", ":", "for", "parent_node", ",", "variant_node", ",", "data", "in", "graph", ".", "edges", "(", "data", "=", "True", ")", ":", "if", "data"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
rewire_variants_to_genes
Find all protein variants that are pointing to a gene and not a protein and fixes them by changing their function to be :data:`pybel.constants.GENE`, in place A use case is after running :func:`collapse_to_genes`.
src/pybel_tools/mutation/collapse.py
def rewire_variants_to_genes(graph: BELGraph) -> None: """Find all protein variants that are pointing to a gene and not a protein and fixes them by changing their function to be :data:`pybel.constants.GENE`, in place A use case is after running :func:`collapse_to_genes`. """ mapping = {} for n...
def rewire_variants_to_genes(graph: BELGraph) -> None: """Find all protein variants that are pointing to a gene and not a protein and fixes them by changing their function to be :data:`pybel.constants.GENE`, in place A use case is after running :func:`collapse_to_genes`. """ mapping = {} for n...
[ "Find", "all", "protein", "variants", "that", "are", "pointing", "to", "a", "gene", "and", "not", "a", "protein", "and", "fixes", "them", "by", "changing", "their", "function", "to", "be", ":", "data", ":", "pybel", ".", "constants", ".", "GENE", "in", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L58-L77
[ "def", "rewire_variants_to_genes", "(", "graph", ":", "BELGraph", ")", "->", "None", ":", "mapping", "=", "{", "}", "for", "node", "in", "graph", ":", "if", "not", "isinstance", "(", "node", ",", "Protein", ")", "or", "not", "node", ".", "variants", ":...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_collapse_edge_passing_predicates
Collapse all edges passing the given edge predicates.
src/pybel_tools/mutation/collapse.py
def _collapse_edge_passing_predicates(graph: BELGraph, edge_predicates: EdgePredicates = None) -> None: """Collapse all edges passing the given edge predicates.""" for u, v, _ in filter_edges(graph, edge_predicates=edge_predicates): collapse_pair(graph, survivor=u, victim=v)
def _collapse_edge_passing_predicates(graph: BELGraph, edge_predicates: EdgePredicates = None) -> None: """Collapse all edges passing the given edge predicates.""" for u, v, _ in filter_edges(graph, edge_predicates=edge_predicates): collapse_pair(graph, survivor=u, victim=v)
[ "Collapse", "all", "edges", "passing", "the", "given", "edge", "predicates", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L80-L83
[ "def", "_collapse_edge_passing_predicates", "(", "graph", ":", "BELGraph", ",", "edge_predicates", ":", "EdgePredicates", "=", "None", ")", "->", "None", ":", "for", "u", ",", "v", ",", "_", "in", "filter_edges", "(", "graph", ",", "edge_predicates", "=", "e...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
_collapse_edge_by_namespace
Collapse pairs of nodes with the given namespaces that have the given relationship. :param graph: A BEL Graph :param victim_namespaces: The namespace(s) of the node to collapse :param survivor_namespaces: The namespace of the node to keep :param relations: The relation(s) to search
src/pybel_tools/mutation/collapse.py
def _collapse_edge_by_namespace(graph: BELGraph, victim_namespaces: Strings, survivor_namespaces: str, relations: Strings) -> None: """Collapse pairs of nodes with the given namespaces that have the given relationship. ...
def _collapse_edge_by_namespace(graph: BELGraph, victim_namespaces: Strings, survivor_namespaces: str, relations: Strings) -> None: """Collapse pairs of nodes with the given namespaces that have the given relationship. ...
[ "Collapse", "pairs", "of", "nodes", "with", "the", "given", "namespaces", "that", "have", "the", "given", "relationship", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L86-L107
[ "def", "_collapse_edge_by_namespace", "(", "graph", ":", "BELGraph", ",", "victim_namespaces", ":", "Strings", ",", "survivor_namespaces", ":", "str", ",", "relations", ":", "Strings", ")", "->", "None", ":", "relation_filter", "=", "build_relation_predicate", "(", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_equivalencies_by_namespace
Collapse pairs of nodes with the given namespaces that have equivalence relationships. :param graph: A BEL graph :param victim_namespace: The namespace(s) of the node to collapse :param survivor_namespace: The namespace of the node to keep To convert all ChEBI names to InChI keys, assuming there a...
src/pybel_tools/mutation/collapse.py
def collapse_equivalencies_by_namespace(graph: BELGraph, victim_namespace: Strings, survivor_namespace: str) -> None: """Collapse pairs of nodes with the given namespaces that have equivalence relationships. :param graph: A BEL graph :param victim_namespace: The namespace(s) of the node to collapse ...
def collapse_equivalencies_by_namespace(graph: BELGraph, victim_namespace: Strings, survivor_namespace: str) -> None: """Collapse pairs of nodes with the given namespaces that have equivalence relationships. :param graph: A BEL graph :param victim_namespace: The namespace(s) of the node to collapse ...
[ "Collapse", "pairs", "of", "nodes", "with", "the", "given", "namespaces", "that", "have", "equivalence", "relationships", ".", ":", "param", "graph", ":", "A", "BEL", "graph", ":", "param", "victim_namespace", ":", "The", "namespace", "(", "s", ")", "of", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L111-L124
[ "def", "collapse_equivalencies_by_namespace", "(", "graph", ":", "BELGraph", ",", "victim_namespace", ":", "Strings", ",", "survivor_namespace", ":", "str", ")", "->", "None", ":", "_collapse_edge_by_namespace", "(", "graph", ",", "victim_namespace", ",", "survivor_na...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_orthologies_by_namespace
Collapse pairs of nodes with the given namespaces that have orthology relationships. :param graph: A BEL Graph :param victim_namespace: The namespace(s) of the node to collapse :param survivor_namespace: The namespace of the node to keep To collapse all MGI nodes to their HGNC orthologs, use: >>> ...
src/pybel_tools/mutation/collapse.py
def collapse_orthologies_by_namespace(graph: BELGraph, victim_namespace: Strings, survivor_namespace: str) -> None: """Collapse pairs of nodes with the given namespaces that have orthology relationships. :param graph: A BEL Graph :param victim_namespace: The namespace(s) of the node to collapse :param ...
def collapse_orthologies_by_namespace(graph: BELGraph, victim_namespace: Strings, survivor_namespace: str) -> None: """Collapse pairs of nodes with the given namespaces that have orthology relationships. :param graph: A BEL Graph :param victim_namespace: The namespace(s) of the node to collapse :param ...
[ "Collapse", "pairs", "of", "nodes", "with", "the", "given", "namespaces", "that", "have", "orthology", "relationships", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L128-L142
[ "def", "collapse_orthologies_by_namespace", "(", "graph", ":", "BELGraph", ",", "victim_namespace", ":", "Strings", ",", "survivor_namespace", ":", "str", ")", "->", "None", ":", "_collapse_edge_by_namespace", "(", "graph", ",", "victim_namespace", ",", "survivor_name...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_entrez_equivalencies
Collapse all equivalence edges away from Entrez. Assumes well formed, 2-way equivalencies.
src/pybel_tools/mutation/collapse.py
def collapse_entrez_equivalencies(graph: BELGraph): """Collapse all equivalence edges away from Entrez. Assumes well formed, 2-way equivalencies.""" relation_filter = build_relation_predicate(EQUIVALENT_TO) source_namespace_filter = build_source_namespace_filter(['EGID', 'EG', 'ENTREZ']) edge_predicate...
def collapse_entrez_equivalencies(graph: BELGraph): """Collapse all equivalence edges away from Entrez. Assumes well formed, 2-way equivalencies.""" relation_filter = build_relation_predicate(EQUIVALENT_TO) source_namespace_filter = build_source_namespace_filter(['EGID', 'EG', 'ENTREZ']) edge_predicate...
[ "Collapse", "all", "equivalence", "edges", "away", "from", "Entrez", ".", "Assumes", "well", "formed", "2", "-", "way", "equivalencies", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L170-L180
[ "def", "collapse_entrez_equivalencies", "(", "graph", ":", "BELGraph", ")", ":", "relation_filter", "=", "build_relation_predicate", "(", "EQUIVALENT_TO", ")", "source_namespace_filter", "=", "build_source_namespace_filter", "(", "[", "'EGID'", ",", "'EG'", ",", "'ENTRE...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_consistent_edges
Collapse consistent edges together. .. warning:: This operation doesn't preserve evidences or other annotations
src/pybel_tools/mutation/collapse.py
def collapse_consistent_edges(graph: BELGraph): """Collapse consistent edges together. .. warning:: This operation doesn't preserve evidences or other annotations """ for u, v in graph.edges(): relation = pair_is_consistent(graph, u, v) if not relation: continue ed...
def collapse_consistent_edges(graph: BELGraph): """Collapse consistent edges together. .. warning:: This operation doesn't preserve evidences or other annotations """ for u, v in graph.edges(): relation = pair_is_consistent(graph, u, v) if not relation: continue ed...
[ "Collapse", "consistent", "edges", "together", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L184-L197
[ "def", "collapse_consistent_edges", "(", "graph", ":", "BELGraph", ")", ":", "for", "u", ",", "v", "in", "graph", ".", "edges", "(", ")", ":", "relation", "=", "pair_is_consistent", "(", "graph", ",", "u", ",", "v", ")", "if", "not", "relation", ":", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_to_protein_interactions
Collapse to a graph made of only causal gene/protein edges.
src/pybel_tools/mutation/collapse.py
def collapse_to_protein_interactions(graph: BELGraph) -> BELGraph: """Collapse to a graph made of only causal gene/protein edges.""" rv: BELGraph = graph.copy() collapse_to_genes(rv) def is_edge_ppi(_: BELGraph, u: BaseEntity, v: BaseEntity, __: str) -> bool: """Check if an edge is a PPI.""" ...
def collapse_to_protein_interactions(graph: BELGraph) -> BELGraph: """Collapse to a graph made of only causal gene/protein edges.""" rv: BELGraph = graph.copy() collapse_to_genes(rv) def is_edge_ppi(_: BELGraph, u: BaseEntity, v: BaseEntity, __: str) -> bool: """Check if an edge is a PPI.""" ...
[ "Collapse", "to", "a", "graph", "made", "of", "only", "causal", "gene", "/", "protein", "edges", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L201-L211
[ "def", "collapse_to_protein_interactions", "(", "graph", ":", "BELGraph", ")", "->", "BELGraph", ":", "rv", ":", "BELGraph", "=", "graph", ".", "copy", "(", ")", "collapse_to_genes", "(", "rv", ")", "def", "is_edge_ppi", "(", "_", ":", "BELGraph", ",", "u"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
collapse_nodes_with_same_names
Collapse all nodes with the same name, merging namespaces by picking first alphabetical one.
src/pybel_tools/mutation/collapse.py
def collapse_nodes_with_same_names(graph: BELGraph) -> None: """Collapse all nodes with the same name, merging namespaces by picking first alphabetical one.""" survivor_mapping = defaultdict(set) # Collapse mapping dict victims = set() # Things already mapped while iterating it = tqdm(itt.combinations(...
def collapse_nodes_with_same_names(graph: BELGraph) -> None: """Collapse all nodes with the same name, merging namespaces by picking first alphabetical one.""" survivor_mapping = defaultdict(set) # Collapse mapping dict victims = set() # Things already mapped while iterating it = tqdm(itt.combinations(...
[ "Collapse", "all", "nodes", "with", "the", "same", "name", "merging", "namespaces", "by", "picking", "first", "alphabetical", "one", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L215-L241
[ "def", "collapse_nodes_with_same_names", "(", "graph", ":", "BELGraph", ")", "->", "None", ":", "survivor_mapping", "=", "defaultdict", "(", "set", ")", "# Collapse mapping dict", "victims", "=", "set", "(", ")", "# Things already mapped while iterating", "it", "=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
main
Output the HBP knowledge graph to the desktop
src/pybel_tools/assembler/ideogram/__main__.py
def main(output): """Output the HBP knowledge graph to the desktop""" from hbp_knowledge import get_graph graph = get_graph() text = to_html(graph) print(text, file=output)
def main(output): """Output the HBP knowledge graph to the desktop""" from hbp_knowledge import get_graph graph = get_graph() text = to_html(graph) print(text, file=output)
[ "Output", "the", "HBP", "knowledge", "graph", "to", "the", "desktop" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/ideogram/__main__.py#L12-L17
[ "def", "main", "(", "output", ")", ":", "from", "hbp_knowledge", "import", "get_graph", "graph", "=", "get_graph", "(", ")", "text", "=", "to_html", "(", "graph", ")", "print", "(", "text", ",", "file", "=", "output", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
node_is_upstream_leaf
Return if the node is an upstream leaf. An upstream leaf is defined as a node that has no in-edges, and exactly 1 out-edge.
src/pybel_tools/generation.py
def node_is_upstream_leaf(graph: BELGraph, node: BaseEntity) -> bool: """Return if the node is an upstream leaf. An upstream leaf is defined as a node that has no in-edges, and exactly 1 out-edge. """ return 0 == len(graph.predecessors(node)) and 1 == len(graph.successors(node))
def node_is_upstream_leaf(graph: BELGraph, node: BaseEntity) -> bool: """Return if the node is an upstream leaf. An upstream leaf is defined as a node that has no in-edges, and exactly 1 out-edge. """ return 0 == len(graph.predecessors(node)) and 1 == len(graph.successors(node))
[ "Return", "if", "the", "node", "is", "an", "upstream", "leaf", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L44-L49
[ "def", "node_is_upstream_leaf", "(", "graph", ":", "BELGraph", ",", "node", ":", "BaseEntity", ")", "->", "bool", ":", "return", "0", "==", "len", "(", "graph", ".", "predecessors", "(", "node", ")", ")", "and", "1", "==", "len", "(", "graph", ".", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_unweighted_upstream_leaves
Get nodes with no incoming edges, one outgoing edge, and without the given key in its data dictionary. .. seealso :: :func:`data_does_not_contain_key_builder` :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.c...
src/pybel_tools/generation.py
def get_unweighted_upstream_leaves(graph: BELGraph, key: Optional[str] = None) -> Iterable[BaseEntity]: """Get nodes with no incoming edges, one outgoing edge, and without the given key in its data dictionary. .. seealso :: :func:`data_does_not_contain_key_builder` :param graph: A BEL graph :param key...
def get_unweighted_upstream_leaves(graph: BELGraph, key: Optional[str] = None) -> Iterable[BaseEntity]: """Get nodes with no incoming edges, one outgoing edge, and without the given key in its data dictionary. .. seealso :: :func:`data_does_not_contain_key_builder` :param graph: A BEL graph :param key...
[ "Get", "nodes", "with", "no", "incoming", "edges", "one", "outgoing", "edge", "and", "without", "the", "given", "key", "in", "its", "data", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L60-L73
[ "def", "get_unweighted_upstream_leaves", "(", "graph", ":", "BELGraph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Iterable", "[", "BaseEntity", "]", ":", "if", "key", "is", "None", ":", "key", "=", "WEIGHT", "return", "filter...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_unweighted_leaves
Remove nodes that are leaves and that don't have a weight (or other key) attribute set. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.constants.WEIGHT`.
src/pybel_tools/generation.py
def remove_unweighted_leaves(graph: BELGraph, key: Optional[str] = None) -> None: """Remove nodes that are leaves and that don't have a weight (or other key) attribute set. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`...
def remove_unweighted_leaves(graph: BELGraph, key: Optional[str] = None) -> None: """Remove nodes that are leaves and that don't have a weight (or other key) attribute set. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`...
[ "Remove", "nodes", "that", "are", "leaves", "and", "that", "don", "t", "have", "a", "weight", "(", "or", "other", "key", ")", "attribute", "set", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L77-L85
[ "def", "remove_unweighted_leaves", "(", "graph", ":", "BELGraph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "unweighted_leaves", "=", "list", "(", "get_unweighted_upstream_leaves", "(", "graph", ",", "key", "=", "key"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
is_unweighted_source
Check if the node is both a source and also has an annotation. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data
src/pybel_tools/generation.py
def is_unweighted_source(graph: BELGraph, node: BaseEntity, key: str) -> bool: """Check if the node is both a source and also has an annotation. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data """ return graph....
def is_unweighted_source(graph: BELGraph, node: BaseEntity, key: str) -> bool: """Check if the node is both a source and also has an annotation. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data """ return graph....
[ "Check", "if", "the", "node", "is", "both", "a", "source", "and", "also", "has", "an", "annotation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L88-L95
[ "def", "is_unweighted_source", "(", "graph", ":", "BELGraph", ",", "node", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "bool", ":", "return", "graph", ".", "in_degree", "(", "node", ")", "==", "0", "and", "key", "not", "in", "graph", ".", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_unweighted_sources
Get nodes on the periphery of the sub-graph that do not have a annotation for the given key. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data :return: An iterator over BEL nodes that are unannotated and on the periphery of this subgraph
src/pybel_tools/generation.py
def get_unweighted_sources(graph: BELGraph, key: Optional[str] = None) -> Iterable[BaseEntity]: """Get nodes on the periphery of the sub-graph that do not have a annotation for the given key. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data :r...
def get_unweighted_sources(graph: BELGraph, key: Optional[str] = None) -> Iterable[BaseEntity]: """Get nodes on the periphery of the sub-graph that do not have a annotation for the given key. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data :r...
[ "Get", "nodes", "on", "the", "periphery", "of", "the", "sub", "-", "graph", "that", "do", "not", "have", "a", "annotation", "for", "the", "given", "key", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L98-L110
[ "def", "get_unweighted_sources", "(", "graph", ":", "BELGraph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Iterable", "[", "BaseEntity", "]", ":", "if", "key", "is", "None", ":", "key", "=", "WEIGHT", "for", "node", "in", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
remove_unweighted_sources
Prune unannotated nodes on the periphery of the sub-graph. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.constants.WEIGHT`.
src/pybel_tools/generation.py
def remove_unweighted_sources(graph: BELGraph, key: Optional[str] = None) -> None: """Prune unannotated nodes on the periphery of the sub-graph. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.constants.WEIGHT...
def remove_unweighted_sources(graph: BELGraph, key: Optional[str] = None) -> None: """Prune unannotated nodes on the periphery of the sub-graph. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.constants.WEIGHT...
[ "Prune", "unannotated", "nodes", "on", "the", "periphery", "of", "the", "sub", "-", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L114-L122
[ "def", "remove_unweighted_sources", "(", "graph", ":", "BELGraph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "nodes", "=", "list", "(", "get_unweighted_sources", "(", "graph", ",", "key", "=", "key", ")", ")", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
prune_mechanism_by_data
Remove all leaves and source nodes that don't have weights. Is a thin wrapper around :func:`remove_unweighted_leaves` and :func:`remove_unweighted_sources` :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data. Defaults to :data:`pybel_tools.con...
src/pybel_tools/generation.py
def prune_mechanism_by_data(graph, key: Optional[str] = None) -> None: """Remove all leaves and source nodes that don't have weights. Is a thin wrapper around :func:`remove_unweighted_leaves` and :func:`remove_unweighted_sources` :param graph: A BEL graph :param key: The key in the node data dictiona...
def prune_mechanism_by_data(graph, key: Optional[str] = None) -> None: """Remove all leaves and source nodes that don't have weights. Is a thin wrapper around :func:`remove_unweighted_leaves` and :func:`remove_unweighted_sources` :param graph: A BEL graph :param key: The key in the node data dictiona...
[ "Remove", "all", "leaves", "and", "source", "nodes", "that", "don", "t", "have", "weights", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L126-L141
[ "def", "prune_mechanism_by_data", "(", "graph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "remove_unweighted_leaves", "(", "graph", ",", "key", "=", "key", ")", "remove_unweighted_sources", "(", "graph", ",", "key", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
generate_mechanism
Generate a mechanistic sub-graph upstream of the given node. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data. :return: A sub-graph grown around the target BEL node
src/pybel_tools/generation.py
def generate_mechanism(graph: BELGraph, node: BaseEntity, key: Optional[str] = None) -> BELGraph: """Generate a mechanistic sub-graph upstream of the given node. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data. :re...
def generate_mechanism(graph: BELGraph, node: BaseEntity, key: Optional[str] = None) -> BELGraph: """Generate a mechanistic sub-graph upstream of the given node. :param graph: A BEL graph :param node: A BEL node :param key: The key in the node data dictionary representing the experimental data. :re...
[ "Generate", "a", "mechanistic", "sub", "-", "graph", "upstream", "of", "the", "given", "node", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L145-L161
[ "def", "generate_mechanism", "(", "graph", ":", "BELGraph", ",", "node", ":", "BaseEntity", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "BELGraph", ":", "subgraph", "=", "get_upstream_causal_subgraph", "(", "graph", ",", "node", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
generate_bioprocess_mechanisms
Generate a mechanistic sub-graph for each biological process in the graph using :func:`generate_mechanism`. :param graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data.
src/pybel_tools/generation.py
def generate_bioprocess_mechanisms(graph, key: Optional[str] = None) -> Mapping[BiologicalProcess, BELGraph]: """Generate a mechanistic sub-graph for each biological process in the graph using :func:`generate_mechanism`. :param graph: A BEL graph :param key: The key in the node data dictionary representing...
def generate_bioprocess_mechanisms(graph, key: Optional[str] = None) -> Mapping[BiologicalProcess, BELGraph]: """Generate a mechanistic sub-graph for each biological process in the graph using :func:`generate_mechanism`. :param graph: A BEL graph :param key: The key in the node data dictionary representing...
[ "Generate", "a", "mechanistic", "sub", "-", "graph", "for", "each", "biological", "process", "in", "the", "graph", "using", ":", "func", ":", "generate_mechanism", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/generation.py#L164-L173
[ "def", "generate_bioprocess_mechanisms", "(", "graph", ",", "key", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Mapping", "[", "BiologicalProcess", ",", "BELGraph", "]", ":", "return", "{", "biological_process", ":", "generate_mechanism", "(", "g...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_neurommsig_scores
Preprocess the graph, stratify by the given annotation, then run the NeuroMMSig algorithm on each. :param graph: A BEL graph :param genes: A list of gene nodes :param annotation: The annotation to use to stratify the graph to subgraphs :param ora_weight: The relative weight of the over-enrichment analy...
src/pybel_tools/analysis/neurommsig/algorithm.py
def get_neurommsig_scores(graph: BELGraph, genes: List[Gene], annotation: str = 'Subgraph', ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, top_percent: Optional[floa...
def get_neurommsig_scores(graph: BELGraph, genes: List[Gene], annotation: str = 'Subgraph', ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, top_percent: Optional[floa...
[ "Preprocess", "the", "graph", "stratify", "by", "the", "given", "annotation", "then", "run", "the", "NeuroMMSig", "algorithm", "on", "each", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L39-L85
[ "def", "get_neurommsig_scores", "(", "graph", ":", "BELGraph", ",", "genes", ":", "List", "[", "Gene", "]", ",", "annotation", ":", "str", "=", "'Subgraph'", ",", "ora_weight", ":", "Optional", "[", "float", "]", "=", "None", ",", "hub_weight", ":", "Opt...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_neurommsig_scores_prestratified
Takes a graph stratification and runs neurommsig on each :param subgraphs: A pre-stratified set of graphs :param genes: A list of gene nodes :param ora_weight: The relative weight of the over-enrichment analysis score from :py:func:`neurommsig_gene_ora`. Defaults to 1.0. :param hub_weight: The rel...
src/pybel_tools/analysis/neurommsig/algorithm.py
def get_neurommsig_scores_prestratified(subgraphs: Mapping[str, BELGraph], genes: List[Gene], ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, ...
def get_neurommsig_scores_prestratified(subgraphs: Mapping[str, BELGraph], genes: List[Gene], ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, ...
[ "Takes", "a", "graph", "stratification", "and", "runs", "neurommsig", "on", "each" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L88-L124
[ "def", "get_neurommsig_scores_prestratified", "(", "subgraphs", ":", "Mapping", "[", "str", ",", "BELGraph", "]", ",", "genes", ":", "List", "[", "Gene", "]", ",", "ora_weight", ":", "Optional", "[", "float", "]", "=", "None", ",", "hub_weight", ":", "Opti...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_neurommsig_score
Calculate the composite NeuroMMSig Score for a given list of genes. :param graph: A BEL graph :param genes: A list of gene nodes :param ora_weight: The relative weight of the over-enrichment analysis score from :py:func:`neurommsig_gene_ora`. Defaults to 1.0. :param hub_weight: The relative weight...
src/pybel_tools/analysis/neurommsig/algorithm.py
def get_neurommsig_score(graph: BELGraph, genes: List[Gene], ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, top_percent: Optional[float] = None, topology_weight: Optional...
def get_neurommsig_score(graph: BELGraph, genes: List[Gene], ora_weight: Optional[float] = None, hub_weight: Optional[float] = None, top_percent: Optional[float] = None, topology_weight: Optional...
[ "Calculate", "the", "composite", "NeuroMMSig", "Score", "for", "a", "given", "list", "of", "genes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L127-L163
[ "def", "get_neurommsig_score", "(", "graph", ":", "BELGraph", ",", "genes", ":", "List", "[", "Gene", "]", ",", "ora_weight", ":", "Optional", "[", "float", "]", "=", "None", ",", "hub_weight", ":", "Optional", "[", "float", "]", "=", "None", ",", "top...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
neurommsig_gene_ora
Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants
src/pybel_tools/analysis/neurommsig/algorithm.py
def neurommsig_gene_ora(graph: BELGraph, genes: List[Gene]) -> float: """Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants """ graph_genes = set(get_nodes_by_function(graph, GENE)) return len(graph_genes...
def neurommsig_gene_ora(graph: BELGraph, genes: List[Gene]) -> float: """Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants """ graph_genes = set(get_nodes_by_function(graph, GENE)) return len(graph_genes...
[ "Calculate", "the", "percentage", "of", "target", "genes", "mappable", "to", "the", "graph", ".", "Assume", ":", "graph", "central", "dogma", "inferred", "collapsed", "to", "genes", "collapsed", "variants" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L166-L172
[ "def", "neurommsig_gene_ora", "(", "graph", ":", "BELGraph", ",", "genes", ":", "List", "[", "Gene", "]", ")", "->", "float", ":", "graph_genes", "=", "set", "(", "get_nodes_by_function", "(", "graph", ",", "GENE", ")", ")", "return", "len", "(", "graph_...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
neurommsig_hubs
Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants, graph has more than 20 nodes :param graph: A BEL graph :param genes: A list of nodes :param top_percent: The percentage of top genes to use as hubs. Def...
src/pybel_tools/analysis/neurommsig/algorithm.py
def neurommsig_hubs(graph: BELGraph, genes: List[Gene], top_percent: Optional[float] = None) -> float: """Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants, graph has more than 20 nodes :param graph: A BEL g...
def neurommsig_hubs(graph: BELGraph, genes: List[Gene], top_percent: Optional[float] = None) -> float: """Calculate the percentage of target genes mappable to the graph. Assume: graph central dogma inferred, collapsed to genes, collapsed variants, graph has more than 20 nodes :param graph: A BEL g...
[ "Calculate", "the", "percentage", "of", "target", "genes", "mappable", "to", "the", "graph", ".", "Assume", ":", "graph", "central", "dogma", "inferred", "collapsed", "to", "genes", "collapsed", "variants", "graph", "has", "more", "than", "20", "nodes", ":", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L175-L209
[ "def", "neurommsig_hubs", "(", "graph", ":", "BELGraph", ",", "genes", ":", "List", "[", "Gene", "]", ",", "top_percent", ":", "Optional", "[", "float", "]", "=", "None", ")", "->", "float", ":", "top_percent", "=", "top_percent", "or", "0.05", "if", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
neurommsig_topology
Calculate the node neighbor score for a given list of nodes. - Doesn't consider self loops .. math:: \frac{\sum_i^n N_G[i]}{n*(n-1)}
src/pybel_tools/analysis/neurommsig/algorithm.py
def neurommsig_topology(graph: BELGraph, nodes: List[BaseEntity]) -> float: """Calculate the node neighbor score for a given list of nodes. - Doesn't consider self loops .. math:: \frac{\sum_i^n N_G[i]}{n*(n-1)} """ nodes = list(nodes) number_nodes = len(nodes) if n...
def neurommsig_topology(graph: BELGraph, nodes: List[BaseEntity]) -> float: """Calculate the node neighbor score for a given list of nodes. - Doesn't consider self loops .. math:: \frac{\sum_i^n N_G[i]}{n*(n-1)} """ nodes = list(nodes) number_nodes = len(nodes) if n...
[ "Calculate", "the", "node", "neighbor", "score", "for", "a", "given", "list", "of", "nodes", ".", "-", "Doesn", "t", "consider", "self", "loops" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/neurommsig/algorithm.py#L212-L234
[ "def", "neurommsig_topology", "(", "graph", ":", "BELGraph", ",", "nodes", ":", "List", "[", "BaseEntity", "]", ")", "->", "float", ":", "nodes", "=", "list", "(", "nodes", ")", "number_nodes", "=", "len", "(", "nodes", ")", "if", "number_nodes", "<=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
bond_run
Perform a single run (realization) over all microstates and return the canonical cluster statistics
percolate/share/jugfile.py
def bond_run(perc_graph_result, seed, ps, convolution_factors_tasks): """ Perform a single run (realization) over all microstates and return the canonical cluster statistics """ microcanonical_statistics = percolate.hpc.bond_microcanonical_statistics( seed=seed, **perc_graph_result ) ...
def bond_run(perc_graph_result, seed, ps, convolution_factors_tasks): """ Perform a single run (realization) over all microstates and return the canonical cluster statistics """ microcanonical_statistics = percolate.hpc.bond_microcanonical_statistics( seed=seed, **perc_graph_result ) ...
[ "Perform", "a", "single", "run", "(", "realization", ")", "over", "all", "microstates", "and", "return", "the", "canonical", "cluster", "statistics" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/share/jugfile.py#L57-L103
[ "def", "bond_run", "(", "perc_graph_result", ",", "seed", ",", "ps", ",", "convolution_factors_tasks", ")", ":", "microcanonical_statistics", "=", "percolate", ".", "hpc", ".", "bond_microcanonical_statistics", "(", "seed", "=", "seed", ",", "*", "*", "perc_graph_...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
bond_task
Perform a number of runs The number of runs is the number of seeds convolution_factors_tasks_iterator needs to be an iterator We shield the convolution factors tasks from jug value/result mechanism by supplying an iterator to the list of tasks for lazy evaluation http://github.com/luispedro/jug/b...
percolate/share/jugfile.py
def bond_task( perc_graph_result, seeds, ps, convolution_factors_tasks_iterator ): """ Perform a number of runs The number of runs is the number of seeds convolution_factors_tasks_iterator needs to be an iterator We shield the convolution factors tasks from jug value/result mechanism by s...
def bond_task( perc_graph_result, seeds, ps, convolution_factors_tasks_iterator ): """ Perform a number of runs The number of runs is the number of seeds convolution_factors_tasks_iterator needs to be an iterator We shield the convolution factors tasks from jug value/result mechanism by s...
[ "Perform", "a", "number", "of", "runs" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/share/jugfile.py#L107-L135
[ "def", "bond_task", "(", "perc_graph_result", ",", "seeds", ",", "ps", ",", "convolution_factors_tasks_iterator", ")", ":", "# restore the list of convolution factors tasks", "convolution_factors_tasks", "=", "list", "(", "convolution_factors_tasks_iterator", ")", "return", "...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
get_leaves_by_type
Returns an iterable over all nodes in graph (in-place) with only a connection to one node. Useful for gene and RNA. Allows for optional filter by function type. :param pybel.BELGraph graph: A BEL graph :param func: If set, filters by the node's function from :mod:`pybel.constants` like ...
src/pybel_tools/selection/utils.py
def get_leaves_by_type(graph, func=None, prune_threshold=1): """Returns an iterable over all nodes in graph (in-place) with only a connection to one node. Useful for gene and RNA. Allows for optional filter by function type. :param pybel.BELGraph graph: A BEL graph :param func: If set, filters by the ...
def get_leaves_by_type(graph, func=None, prune_threshold=1): """Returns an iterable over all nodes in graph (in-place) with only a connection to one node. Useful for gene and RNA. Allows for optional filter by function type. :param pybel.BELGraph graph: A BEL graph :param func: If set, filters by the ...
[ "Returns", "an", "iterable", "over", "all", "nodes", "in", "graph", "(", "in", "-", "place", ")", "with", "only", "a", "connection", "to", "one", "node", ".", "Useful", "for", "gene", "and", "RNA", ".", "Allows", "for", "optional", "filter", "by", "fun...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/utils.py#L10-L29
[ "def", "get_leaves_by_type", "(", "graph", ",", "func", "=", "None", ",", "prune_threshold", "=", "1", ")", ":", "for", "node", ",", "data", "in", "graph", ".", "nodes", "(", "data", "=", "True", ")", ":", "if", "func", "and", "func", "!=", "data", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_peripheral_successor_edges
Get the set of possible successor edges peripheral to the sub-graph. The source nodes in this iterable are all inside the sub-graph, while the targets are outside.
src/pybel_tools/mutation/expansion.py
def get_peripheral_successor_edges(graph: BELGraph, subgraph: BELGraph) -> EdgeIterator: """Get the set of possible successor edges peripheral to the sub-graph. The source nodes in this iterable are all inside the sub-graph, while the targets are outside. """ for u in subgraph: for _, v, k in g...
def get_peripheral_successor_edges(graph: BELGraph, subgraph: BELGraph) -> EdgeIterator: """Get the set of possible successor edges peripheral to the sub-graph. The source nodes in this iterable are all inside the sub-graph, while the targets are outside. """ for u in subgraph: for _, v, k in g...
[ "Get", "the", "set", "of", "possible", "successor", "edges", "peripheral", "to", "the", "sub", "-", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L43-L51
[ "def", "get_peripheral_successor_edges", "(", "graph", ":", "BELGraph", ",", "subgraph", ":", "BELGraph", ")", "->", "EdgeIterator", ":", "for", "u", "in", "subgraph", ":", "for", "_", ",", "v", ",", "k", "in", "graph", ".", "out_edges", "(", "u", ",", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_peripheral_predecessor_edges
Get the set of possible predecessor edges peripheral to the sub-graph. The target nodes in this iterable are all inside the sub-graph, while the sources are outside.
src/pybel_tools/mutation/expansion.py
def get_peripheral_predecessor_edges(graph: BELGraph, subgraph: BELGraph) -> EdgeIterator: """Get the set of possible predecessor edges peripheral to the sub-graph. The target nodes in this iterable are all inside the sub-graph, while the sources are outside. """ for v in subgraph: for u, _, k ...
def get_peripheral_predecessor_edges(graph: BELGraph, subgraph: BELGraph) -> EdgeIterator: """Get the set of possible predecessor edges peripheral to the sub-graph. The target nodes in this iterable are all inside the sub-graph, while the sources are outside. """ for v in subgraph: for u, _, k ...
[ "Get", "the", "set", "of", "possible", "predecessor", "edges", "peripheral", "to", "the", "sub", "-", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L54-L62
[ "def", "get_peripheral_predecessor_edges", "(", "graph", ":", "BELGraph", ",", "subgraph", ":", "BELGraph", ")", "->", "EdgeIterator", ":", "for", "v", "in", "subgraph", ":", "for", "u", ",", "_", ",", "k", "in", "graph", ".", "in_edges", "(", "v", ",", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_sources
Count the source nodes in an edge iterator with keys and data. :return: A counter of source nodes in the iterable
src/pybel_tools/mutation/expansion.py
def count_sources(edge_iter: EdgeIterator) -> Counter: """Count the source nodes in an edge iterator with keys and data. :return: A counter of source nodes in the iterable """ return Counter(u for u, _, _ in edge_iter)
def count_sources(edge_iter: EdgeIterator) -> Counter: """Count the source nodes in an edge iterator with keys and data. :return: A counter of source nodes in the iterable """ return Counter(u for u, _, _ in edge_iter)
[ "Count", "the", "source", "nodes", "in", "an", "edge", "iterator", "with", "keys", "and", "data", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L65-L70
[ "def", "count_sources", "(", "edge_iter", ":", "EdgeIterator", ")", "->", "Counter", ":", "return", "Counter", "(", "u", "for", "u", ",", "_", ",", "_", "in", "edge_iter", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_targets
Count the target nodes in an edge iterator with keys and data. :return: A counter of target nodes in the iterable
src/pybel_tools/mutation/expansion.py
def count_targets(edge_iter: EdgeIterator) -> Counter: """Count the target nodes in an edge iterator with keys and data. :return: A counter of target nodes in the iterable """ return Counter(v for _, v, _ in edge_iter)
def count_targets(edge_iter: EdgeIterator) -> Counter: """Count the target nodes in an edge iterator with keys and data. :return: A counter of target nodes in the iterable """ return Counter(v for _, v, _ in edge_iter)
[ "Count", "the", "target", "nodes", "in", "an", "edge", "iterator", "with", "keys", "and", "data", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L73-L78
[ "def", "count_targets", "(", "edge_iter", ":", "EdgeIterator", ")", "->", "Counter", ":", "return", "Counter", "(", "v", "for", "_", ",", "v", ",", "_", "in", "edge_iter", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_subgraph_edges
Gets all edges from a given subgraph whose source and target nodes pass all of the given filters :param pybel.BELGraph graph: A BEL graph :param str annotation: The annotation to search :param str value: The annotation value to search by :param source_filter: Optional filter for source nodes (graph, n...
src/pybel_tools/mutation/expansion.py
def get_subgraph_edges(graph: BELGraph, annotation: str, value: str, source_filter=None, target_filter=None, ): """Gets all edges from a given subgraph whose source and target nodes pass all of the giv...
def get_subgraph_edges(graph: BELGraph, annotation: str, value: str, source_filter=None, target_filter=None, ): """Gets all edges from a given subgraph whose source and target nodes pass all of the giv...
[ "Gets", "all", "edges", "from", "a", "given", "subgraph", "whose", "source", "and", "target", "nodes", "pass", "all", "of", "the", "given", "filters" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L101-L128
[ "def", "get_subgraph_edges", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", ",", "value", ":", "str", ",", "source_filter", "=", "None", ",", "target_filter", "=", "None", ",", ")", ":", "if", "source_filter", "is", "None", ":", "source_filt...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_subgraph_peripheral_nodes
Get a summary dictionary of all peripheral nodes to a given sub-graph. :return: A dictionary of {external node: {'successor': {internal node: list of (key, dict)}, 'predecessor': {internal node: list of (key, dict)}}} :rtype: dict For example, it might be useful...
src/pybel_tools/mutation/expansion.py
def get_subgraph_peripheral_nodes(graph: BELGraph, subgraph: Iterable[BaseEntity], node_predicates: NodePredicates = None, edge_predicates: EdgePredicates = None, ): """Get a summa...
def get_subgraph_peripheral_nodes(graph: BELGraph, subgraph: Iterable[BaseEntity], node_predicates: NodePredicates = None, edge_predicates: EdgePredicates = None, ): """Get a summa...
[ "Get", "a", "summary", "dictionary", "of", "all", "peripheral", "nodes", "to", "a", "given", "sub", "-", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L131-L171
[ "def", "get_subgraph_peripheral_nodes", "(", "graph", ":", "BELGraph", ",", "subgraph", ":", "Iterable", "[", "BaseEntity", "]", ",", "node_predicates", ":", "NodePredicates", "=", "None", ",", "edge_predicates", ":", "EdgePredicates", "=", "None", ",", ")", ":"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c