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
expand_periphery
Iterates over all possible edges, peripheral to a given subgraph, that could be added from the given graph. Edges could be added if they go to nodes that are involved in relationships that occur with more than the threshold (default 2) number of nodes in the subgraph. :param universe: The universe of BEL k...
src/pybel_tools/mutation/expansion.py
def expand_periphery(universe: BELGraph, graph: BELGraph, node_predicates: NodePredicates = None, edge_predicates: EdgePredicates = None, threshold: int = 2, ) -> None: """Iterates over all possible edges, perip...
def expand_periphery(universe: BELGraph, graph: BELGraph, node_predicates: NodePredicates = None, edge_predicates: EdgePredicates = None, threshold: int = 2, ) -> None: """Iterates over all possible edges, perip...
[ "Iterates", "over", "all", "possible", "edges", "peripheral", "to", "a", "given", "subgraph", "that", "could", "be", "added", "from", "the", "given", "graph", ".", "Edges", "could", "be", "added", "if", "they", "go", "to", "nodes", "that", "are", "involved...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L175-L212
[ "def", "expand_periphery", "(", "universe", ":", "BELGraph", ",", "graph", ":", "BELGraph", ",", "node_predicates", ":", "NodePredicates", "=", "None", ",", "edge_predicates", ":", "EdgePredicates", "=", "None", ",", "threshold", ":", "int", "=", "2", ",", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_complexes
Add all of the members of the complex abundances to the graph.
src/pybel_tools/mutation/expansion.py
def enrich_complexes(graph: BELGraph) -> None: """Add all of the members of the complex abundances to the graph.""" nodes = list(get_nodes_by_function(graph, COMPLEX)) for u in nodes: for v in u.members: graph.add_has_component(u, v)
def enrich_complexes(graph: BELGraph) -> None: """Add all of the members of the complex abundances to the graph.""" nodes = list(get_nodes_by_function(graph, COMPLEX)) for u in nodes: for v in u.members: graph.add_has_component(u, v)
[ "Add", "all", "of", "the", "members", "of", "the", "complex", "abundances", "to", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L216-L221
[ "def", "enrich_complexes", "(", "graph", ":", "BELGraph", ")", "->", "None", ":", "nodes", "=", "list", "(", "get_nodes_by_function", "(", "graph", ",", "COMPLEX", ")", ")", "for", "u", "in", "nodes", ":", "for", "v", "in", "u", ".", "members", ":", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_composites
Adds all of the members of the composite abundances to the graph.
src/pybel_tools/mutation/expansion.py
def enrich_composites(graph: BELGraph): """Adds all of the members of the composite abundances to the graph.""" nodes = list(get_nodes_by_function(graph, COMPOSITE)) for u in nodes: for v in u.members: graph.add_has_component(u, v)
def enrich_composites(graph: BELGraph): """Adds all of the members of the composite abundances to the graph.""" nodes = list(get_nodes_by_function(graph, COMPOSITE)) for u in nodes: for v in u.members: graph.add_has_component(u, v)
[ "Adds", "all", "of", "the", "members", "of", "the", "composite", "abundances", "to", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L225-L230
[ "def", "enrich_composites", "(", "graph", ":", "BELGraph", ")", ":", "nodes", "=", "list", "(", "get_nodes_by_function", "(", "graph", ",", "COMPOSITE", ")", ")", "for", "u", "in", "nodes", ":", "for", "v", "in", "u", ".", "members", ":", "graph", ".",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_reactions
Adds all of the reactants and products of reactions to the graph.
src/pybel_tools/mutation/expansion.py
def enrich_reactions(graph: BELGraph): """Adds all of the reactants and products of reactions to the graph.""" nodes = list(get_nodes_by_function(graph, REACTION)) for u in nodes: for v in u.reactants: graph.add_has_reactant(u, v) for v in u.products: graph.add_has_p...
def enrich_reactions(graph: BELGraph): """Adds all of the reactants and products of reactions to the graph.""" nodes = list(get_nodes_by_function(graph, REACTION)) for u in nodes: for v in u.reactants: graph.add_has_reactant(u, v) for v in u.products: graph.add_has_p...
[ "Adds", "all", "of", "the", "reactants", "and", "products", "of", "reactions", "to", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L234-L242
[ "def", "enrich_reactions", "(", "graph", ":", "BELGraph", ")", ":", "nodes", "=", "list", "(", "get_nodes_by_function", "(", "graph", ",", "REACTION", ")", ")", "for", "u", "in", "nodes", ":", "for", "v", "in", "u", ".", "reactants", ":", "graph", ".",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_variants
Add the reference nodes for all variants of the given function. :param graph: The target BEL graph to enrich :param func: The function by which the subject of each triple is filtered. Defaults to the set of protein, rna, mirna, and gene.
src/pybel_tools/mutation/expansion.py
def enrich_variants(graph: BELGraph, func: Union[None, str, Iterable[str]] = None): """Add the reference nodes for all variants of the given function. :param graph: The target BEL graph to enrich :param func: The function by which the subject of each triple is filtered. Defaults to the set of protein, rna,...
def enrich_variants(graph: BELGraph, func: Union[None, str, Iterable[str]] = None): """Add the reference nodes for all variants of the given function. :param graph: The target BEL graph to enrich :param func: The function by which the subject of each triple is filtered. Defaults to the set of protein, rna,...
[ "Add", "the", "reference", "nodes", "for", "all", "variants", "of", "the", "given", "function", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L246-L264
[ "def", "enrich_variants", "(", "graph", ":", "BELGraph", ",", "func", ":", "Union", "[", "None", ",", "str", ",", "Iterable", "[", "str", "]", "]", "=", "None", ")", ":", "if", "func", "is", "None", ":", "func", "=", "{", "PROTEIN", ",", "RNA", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
enrich_unqualified
Enrich the sub-graph with the unqualified edges from the graph. The reason you might want to do this is you induce a sub-graph from the original graph based on an annotation filter, but the unqualified edges that don't have annotations that most likely connect elements within your graph are not included. ...
src/pybel_tools/mutation/expansion.py
def enrich_unqualified(graph: BELGraph): """Enrich the sub-graph with the unqualified edges from the graph. The reason you might want to do this is you induce a sub-graph from the original graph based on an annotation filter, but the unqualified edges that don't have annotations that most likely connect el...
def enrich_unqualified(graph: BELGraph): """Enrich the sub-graph with the unqualified edges from the graph. The reason you might want to do this is you induce a sub-graph from the original graph based on an annotation filter, but the unqualified edges that don't have annotations that most likely connect el...
[ "Enrich", "the", "sub", "-", "graph", "with", "the", "unqualified", "edges", "from", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L268-L294
[ "def", "enrich_unqualified", "(", "graph", ":", "BELGraph", ")", ":", "enrich_complexes", "(", "graph", ")", "enrich_composites", "(", "graph", ")", "enrich_reactions", "(", "graph", ")", "enrich_variants", "(", "graph", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
expand_internal
Edges between entities in the sub-graph that pass the given filters. :param universe: The full graph :param graph: A sub-graph to find the upstream information :param edge_predicates: Optional list of edge filter functions (graph, node, node, key, data) -> bool
src/pybel_tools/mutation/expansion.py
def expand_internal(universe: BELGraph, graph: BELGraph, edge_predicates: EdgePredicates = None) -> None: """Edges between entities in the sub-graph that pass the given filters. :param universe: The full graph :param graph: A sub-graph to find the upstream information :param edge_predicates: Optional l...
def expand_internal(universe: BELGraph, graph: BELGraph, edge_predicates: EdgePredicates = None) -> None: """Edges between entities in the sub-graph that pass the given filters. :param universe: The full graph :param graph: A sub-graph to find the upstream information :param edge_predicates: Optional l...
[ "Edges", "between", "entities", "in", "the", "sub", "-", "graph", "that", "pass", "the", "given", "filters", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L299-L324
[ "def", "expand_internal", "(", "universe", ":", "BELGraph", ",", "graph", ":", "BELGraph", ",", "edge_predicates", ":", "EdgePredicates", "=", "None", ")", "->", "None", ":", "edge_filter", "=", "and_edge_predicates", "(", "edge_predicates", ")", "for", "u", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
expand_internal_causal
Add causal edges between entities in the sub-graph. Is an extremely thin wrapper around :func:`expand_internal`. :param universe: A BEL graph representing the universe of all knowledge :param graph: The target BEL graph to enrich with causal relations between contained nodes Equivalent to: >>> f...
src/pybel_tools/mutation/expansion.py
def expand_internal_causal(universe: BELGraph, graph: BELGraph) -> None: """Add causal edges between entities in the sub-graph. Is an extremely thin wrapper around :func:`expand_internal`. :param universe: A BEL graph representing the universe of all knowledge :param graph: The target BEL graph to enr...
def expand_internal_causal(universe: BELGraph, graph: BELGraph) -> None: """Add causal edges between entities in the sub-graph. Is an extremely thin wrapper around :func:`expand_internal`. :param universe: A BEL graph representing the universe of all knowledge :param graph: The target BEL graph to enr...
[ "Add", "causal", "edges", "between", "entities", "in", "the", "sub", "-", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/expansion.py#L328-L342
[ "def", "expand_internal_causal", "(", "universe", ":", "BELGraph", ",", "graph", ":", "BELGraph", ")", "->", "None", ":", "expand_internal", "(", "universe", ",", "graph", ",", "edge_predicates", "=", "is_causal_relation", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_namespaces_with_incorrect_names
Return the set of all namespaces with incorrect names in the graph.
src/pybel_tools/summary/error_summary.py
def get_namespaces_with_incorrect_names(graph: BELGraph) -> Set[str]: """Return the set of all namespaces with incorrect names in the graph.""" return { exc.namespace for _, exc, _ in graph.warnings if isinstance(exc, (MissingNamespaceNameWarning, MissingNamespaceRegexWarning)) }
def get_namespaces_with_incorrect_names(graph: BELGraph) -> Set[str]: """Return the set of all namespaces with incorrect names in the graph.""" return { exc.namespace for _, exc, _ in graph.warnings if isinstance(exc, (MissingNamespaceNameWarning, MissingNamespaceRegexWarning)) }
[ "Return", "the", "set", "of", "all", "namespaces", "with", "incorrect", "names", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L37-L43
[ "def", "get_namespaces_with_incorrect_names", "(", "graph", ":", "BELGraph", ")", "->", "Set", "[", "str", "]", ":", "return", "{", "exc", ".", "namespace", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings", "if", "isinstance", "(", "exc",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_undefined_namespaces
Get all namespaces that are used in the BEL graph aren't actually defined.
src/pybel_tools/summary/error_summary.py
def get_undefined_namespaces(graph: BELGraph) -> Set[str]: """Get all namespaces that are used in the BEL graph aren't actually defined.""" return { exc.namespace for _, exc, _ in graph.warnings if isinstance(exc, UndefinedNamespaceWarning) }
def get_undefined_namespaces(graph: BELGraph) -> Set[str]: """Get all namespaces that are used in the BEL graph aren't actually defined.""" return { exc.namespace for _, exc, _ in graph.warnings if isinstance(exc, UndefinedNamespaceWarning) }
[ "Get", "all", "namespaces", "that", "are", "used", "in", "the", "BEL", "graph", "aren", "t", "actually", "defined", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L46-L52
[ "def", "get_undefined_namespaces", "(", "graph", ":", "BELGraph", ")", "->", "Set", "[", "str", "]", ":", "return", "{", "exc", ".", "namespace", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings", "if", "isinstance", "(", "exc", ",", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_incorrect_names_by_namespace
Return the set of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph
src/pybel_tools/summary/error_summary.py
def get_incorrect_names_by_namespace(graph: BELGraph, namespace: str) -> Set[str]: """Return the set of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph """ return { exc.name for _, exc, _ in graph.w...
def get_incorrect_names_by_namespace(graph: BELGraph, namespace: str) -> Set[str]: """Return the set of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph """ return { exc.name for _, exc, _ in graph.w...
[ "Return", "the", "set", "of", "all", "incorrect", "names", "from", "the", "given", "namespace", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L55-L64
[ "def", "get_incorrect_names_by_namespace", "(", "graph", ":", "BELGraph", ",", "namespace", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "return", "{", "exc", ".", "name", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings", "if", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_undefined_namespace_names
Get the names from a namespace that wasn't actually defined. :return: The set of all names from the undefined namespace
src/pybel_tools/summary/error_summary.py
def get_undefined_namespace_names(graph: BELGraph, namespace: str) -> Set[str]: """Get the names from a namespace that wasn't actually defined. :return: The set of all names from the undefined namespace """ return { exc.name for _, exc, _ in graph.warnings if isinstance(exc, Und...
def get_undefined_namespace_names(graph: BELGraph, namespace: str) -> Set[str]: """Get the names from a namespace that wasn't actually defined. :return: The set of all names from the undefined namespace """ return { exc.name for _, exc, _ in graph.warnings if isinstance(exc, Und...
[ "Get", "the", "names", "from", "a", "namespace", "that", "wasn", "t", "actually", "defined", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L67-L76
[ "def", "get_undefined_namespace_names", "(", "graph", ":", "BELGraph", ",", "namespace", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "return", "{", "exc", ".", "name", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings", "if", "i...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_incorrect_names
Return the dict of the sets of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph
src/pybel_tools/summary/error_summary.py
def get_incorrect_names(graph: BELGraph) -> Mapping[str, Set[str]]: """Return the dict of the sets of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph """ return { namespace: get_incorrect_names_by_namespace...
def get_incorrect_names(graph: BELGraph) -> Mapping[str, Set[str]]: """Return the dict of the sets of all incorrect names from the given namespace in the graph. :return: The set of all incorrect names from the given namespace in the graph """ return { namespace: get_incorrect_names_by_namespace...
[ "Return", "the", "dict", "of", "the", "sets", "of", "all", "incorrect", "names", "from", "the", "given", "namespace", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L79-L87
[ "def", "get_incorrect_names", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Set", "[", "str", "]", "]", ":", "return", "{", "namespace", ":", "get_incorrect_names_by_namespace", "(", "graph", ",", "namespace", ")", "for", "namespace"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_undefined_annotations
Get all annotations that aren't actually defined. :return: The set of all undefined annotations
src/pybel_tools/summary/error_summary.py
def get_undefined_annotations(graph: BELGraph) -> Set[str]: """Get all annotations that aren't actually defined. :return: The set of all undefined annotations """ return { exc.annotation for _, exc, _ in graph.warnings if isinstance(exc, UndefinedAnnotationWarning) }
def get_undefined_annotations(graph: BELGraph) -> Set[str]: """Get all annotations that aren't actually defined. :return: The set of all undefined annotations """ return { exc.annotation for _, exc, _ in graph.warnings if isinstance(exc, UndefinedAnnotationWarning) }
[ "Get", "all", "annotations", "that", "aren", "t", "actually", "defined", ".", ":", "return", ":", "The", "set", "of", "all", "undefined", "annotations" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L90-L99
[ "def", "get_undefined_annotations", "(", "graph", ":", "BELGraph", ")", "->", "Set", "[", "str", "]", ":", "return", "{", "exc", ".", "annotation", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings", "if", "isinstance", "(", "exc", ",", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_incorrect_name_dict
Group all of the incorrect identifiers in a dict of {namespace: list of erroneous names}. :return: A dictionary of {namespace: list of erroneous names}
src/pybel_tools/summary/error_summary.py
def calculate_incorrect_name_dict(graph: BELGraph) -> Mapping[str, str]: """Group all of the incorrect identifiers in a dict of {namespace: list of erroneous names}. :return: A dictionary of {namespace: list of erroneous names} """ missing = defaultdict(list) for _, e, ctx in graph.warnings: ...
def calculate_incorrect_name_dict(graph: BELGraph) -> Mapping[str, str]: """Group all of the incorrect identifiers in a dict of {namespace: list of erroneous names}. :return: A dictionary of {namespace: list of erroneous names} """ missing = defaultdict(list) for _, e, ctx in graph.warnings: ...
[ "Group", "all", "of", "the", "incorrect", "identifiers", "in", "a", "dict", "of", "{", "namespace", ":", "list", "of", "erroneous", "names", "}", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L102-L114
[ "def", "calculate_incorrect_name_dict", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "str", "]", ":", "missing", "=", "defaultdict", "(", "list", ")", "for", "_", ",", "e", ",", "ctx", "in", "graph", ".", "warnings", ":", "if",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
group_errors
Group the errors together for analysis of the most frequent error. :return: A dictionary of {error string: list of line numbers}
src/pybel_tools/summary/error_summary.py
def group_errors(graph: BELGraph) -> Mapping[str, List[int]]: """Group the errors together for analysis of the most frequent error. :return: A dictionary of {error string: list of line numbers} """ warning_summary = defaultdict(list) for _, exc, _ in graph.warnings: warning_summary[str(exc...
def group_errors(graph: BELGraph) -> Mapping[str, List[int]]: """Group the errors together for analysis of the most frequent error. :return: A dictionary of {error string: list of line numbers} """ warning_summary = defaultdict(list) for _, exc, _ in graph.warnings: warning_summary[str(exc...
[ "Group", "the", "errors", "together", "for", "analysis", "of", "the", "most", "frequent", "error", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L139-L149
[ "def", "group_errors", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "List", "[", "int", "]", "]", ":", "warning_summary", "=", "defaultdict", "(", "list", ")", "for", "_", ",", "exc", ",", "_", "in", "graph", ".", "warnings",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_most_common_errors
Get the (n) most common errors in a graph.
src/pybel_tools/summary/error_summary.py
def get_most_common_errors(graph: BELGraph, n: Optional[int] = 20): """Get the (n) most common errors in a graph.""" return count_dict_values(group_errors(graph)).most_common(n)
def get_most_common_errors(graph: BELGraph, n: Optional[int] = 20): """Get the (n) most common errors in a graph.""" return count_dict_values(group_errors(graph)).most_common(n)
[ "Get", "the", "(", "n", ")", "most", "common", "errors", "in", "a", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L152-L154
[ "def", "get_most_common_errors", "(", "graph", ":", "BELGraph", ",", "n", ":", "Optional", "[", "int", "]", "=", "20", ")", ":", "return", "count_dict_values", "(", "group_errors", "(", "graph", ")", ")", ".", "most_common", "(", "n", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_names_including_errors_by_namespace
Takes the names from the graph in a given namespace (:func:`pybel.struct.summary.get_names_by_namespace`) and the erroneous names from the same namespace (:func:`get_incorrect_names_by_namespace`) and returns them together as a unioned set :return: The set of all correct and incorrect names from the given ...
src/pybel_tools/summary/error_summary.py
def get_names_including_errors_by_namespace(graph: BELGraph, namespace: str) -> Set[str]: """Takes the names from the graph in a given namespace (:func:`pybel.struct.summary.get_names_by_namespace`) and the erroneous names from the same namespace (:func:`get_incorrect_names_by_namespace`) and returns them toget...
def get_names_including_errors_by_namespace(graph: BELGraph, namespace: str) -> Set[str]: """Takes the names from the graph in a given namespace (:func:`pybel.struct.summary.get_names_by_namespace`) and the erroneous names from the same namespace (:func:`get_incorrect_names_by_namespace`) and returns them toget...
[ "Takes", "the", "names", "from", "the", "graph", "in", "a", "given", "namespace", "(", ":", "func", ":", "pybel", ".", "struct", ".", "summary", ".", "get_names_by_namespace", ")", "and", "the", "erroneous", "names", "from", "the", "same", "namespace", "("...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L157-L164
[ "def", "get_names_including_errors_by_namespace", "(", "graph", ":", "BELGraph", ",", "namespace", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "return", "get_names_by_namespace", "(", "graph", ",", "namespace", ")", "|", "get_incorrect_names_by_namespace", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_names_including_errors
Takes the names from the graph in a given namespace and the erroneous names from the same namespace and returns them together as a unioned set :return: The dict of the sets of all correct and incorrect names from the given namespace in the graph
src/pybel_tools/summary/error_summary.py
def get_names_including_errors(graph: BELGraph) -> Mapping[str, Set[str]]: """Takes the names from the graph in a given namespace and the erroneous names from the same namespace and returns them together as a unioned set :return: The dict of the sets of all correct and incorrect names from the given namesp...
def get_names_including_errors(graph: BELGraph) -> Mapping[str, Set[str]]: """Takes the names from the graph in a given namespace and the erroneous names from the same namespace and returns them together as a unioned set :return: The dict of the sets of all correct and incorrect names from the given namesp...
[ "Takes", "the", "names", "from", "the", "graph", "in", "a", "given", "namespace", "and", "the", "erroneous", "names", "from", "the", "same", "namespace", "and", "returns", "them", "together", "as", "a", "unioned", "set" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/error_summary.py#L167-L176
[ "def", "get_names_including_errors", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Set", "[", "str", "]", "]", ":", "return", "{", "namespace", ":", "get_names_including_errors_by_namespace", "(", "graph", ",", "namespace", ")", "for",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
pairwise
Iterate over pairs in list s -> (s0,s1), (s1,s2), (s2, s3), ...
src/pybel_tools/utils.py
def pairwise(iterable: Iterable[X]) -> Iterable[Tuple[X, X]]: """Iterate over pairs in list s -> (s0,s1), (s1,s2), (s2, s3), ...""" a, b = itt.tee(iterable) next(b, None) return zip(a, b)
def pairwise(iterable: Iterable[X]) -> Iterable[Tuple[X, X]]: """Iterate over pairs in list s -> (s0,s1), (s1,s2), (s2, s3), ...""" a, b = itt.tee(iterable) next(b, None) return zip(a, b)
[ "Iterate", "over", "pairs", "in", "list", "s", "-", ">", "(", "s0", "s1", ")", "(", "s1", "s2", ")", "(", "s2", "s3", ")", "..." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L26-L30
[ "def", "pairwise", "(", "iterable", ":", "Iterable", "[", "X", "]", ")", "->", "Iterable", "[", "Tuple", "[", "X", ",", "X", "]", "]", ":", "a", ",", "b", "=", "itt", ".", "tee", "(", "iterable", ")", "next", "(", "b", ",", "None", ")", "retu...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_defaultdict
Count the number of elements in each value of the dictionary.
src/pybel_tools/utils.py
def count_defaultdict(dict_of_lists: Mapping[X, List[Y]]) -> Mapping[X, typing.Counter[Y]]: """Count the number of elements in each value of the dictionary.""" return { k: Counter(v) for k, v in dict_of_lists.items() }
def count_defaultdict(dict_of_lists: Mapping[X, List[Y]]) -> Mapping[X, typing.Counter[Y]]: """Count the number of elements in each value of the dictionary.""" return { k: Counter(v) for k, v in dict_of_lists.items() }
[ "Count", "the", "number", "of", "elements", "in", "each", "value", "of", "the", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L40-L45
[ "def", "count_defaultdict", "(", "dict_of_lists", ":", "Mapping", "[", "X", ",", "List", "[", "Y", "]", "]", ")", "->", "Mapping", "[", "X", ",", "typing", ".", "Counter", "[", "Y", "]", "]", ":", "return", "{", "k", ":", "Counter", "(", "v", ")"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
count_dict_values
Count the number of elements in each value (can be list, Counter, etc). :param dict_of_counters: A dictionary of things whose lengths can be measured (lists, Counters, dicts) :return: A Counter with the same keys as the input but the count of the length of the values list/tuple/set/Counter
src/pybel_tools/utils.py
def count_dict_values(dict_of_counters: Mapping[X, Sized]) -> typing.Counter[X]: """Count the number of elements in each value (can be list, Counter, etc). :param dict_of_counters: A dictionary of things whose lengths can be measured (lists, Counters, dicts) :return: A Counter with the same keys as the inp...
def count_dict_values(dict_of_counters: Mapping[X, Sized]) -> typing.Counter[X]: """Count the number of elements in each value (can be list, Counter, etc). :param dict_of_counters: A dictionary of things whose lengths can be measured (lists, Counters, dicts) :return: A Counter with the same keys as the inp...
[ "Count", "the", "number", "of", "elements", "in", "each", "value", "(", "can", "be", "list", "Counter", "etc", ")", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L48-L57
[ "def", "count_dict_values", "(", "dict_of_counters", ":", "Mapping", "[", "X", ",", "Sized", "]", ")", "->", "typing", ".", "Counter", "[", "X", "]", ":", "return", "Counter", "(", "{", "k", ":", "len", "(", "v", ")", "for", "k", ",", "v", "in", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
set_percentage
What percentage of x is contained within y? :param set x: A set :param set y: Another set :return: The percentage of x contained within y
src/pybel_tools/utils.py
def set_percentage(x: Iterable[X], y: Iterable[X]) -> float: """What percentage of x is contained within y? :param set x: A set :param set y: Another set :return: The percentage of x contained within y """ a, b = set(x), set(y) if not a: return 0.0 return len(a & b) / len(a)
def set_percentage(x: Iterable[X], y: Iterable[X]) -> float: """What percentage of x is contained within y? :param set x: A set :param set y: Another set :return: The percentage of x contained within y """ a, b = set(x), set(y) if not a: return 0.0 return len(a & b) / len(a)
[ "What", "percentage", "of", "x", "is", "contained", "within", "y?" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L60-L72
[ "def", "set_percentage", "(", "x", ":", "Iterable", "[", "X", "]", ",", "y", ":", "Iterable", "[", "X", "]", ")", "->", "float", ":", "a", ",", "b", "=", "set", "(", "x", ")", ",", "set", "(", "y", ")", "if", "not", "a", ":", "return", "0.0...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
tanimoto_set_similarity
Calculate the tanimoto set similarity.
src/pybel_tools/utils.py
def tanimoto_set_similarity(x: Iterable[X], y: Iterable[X]) -> float: """Calculate the tanimoto set similarity.""" a, b = set(x), set(y) union = a | b if not union: return 0.0 return len(a & b) / len(union)
def tanimoto_set_similarity(x: Iterable[X], y: Iterable[X]) -> float: """Calculate the tanimoto set similarity.""" a, b = set(x), set(y) union = a | b if not union: return 0.0 return len(a & b) / len(union)
[ "Calculate", "the", "tanimoto", "set", "similarity", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L75-L83
[ "def", "tanimoto_set_similarity", "(", "x", ":", "Iterable", "[", "X", "]", ",", "y", ":", "Iterable", "[", "X", "]", ")", "->", "float", ":", "a", ",", "b", "=", "set", "(", "x", ")", ",", "set", "(", "y", ")", "union", "=", "a", "|", "b", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
min_tanimoto_set_similarity
Calculate the tanimoto set similarity using the minimum size. :param set x: A set :param set y: Another set :return: The similarity between
src/pybel_tools/utils.py
def min_tanimoto_set_similarity(x: Iterable[X], y: Iterable[X]) -> float: """Calculate the tanimoto set similarity using the minimum size. :param set x: A set :param set y: Another set :return: The similarity between """ a, b = set(x), set(y) if not a or not b: return 0.0 ...
def min_tanimoto_set_similarity(x: Iterable[X], y: Iterable[X]) -> float: """Calculate the tanimoto set similarity using the minimum size. :param set x: A set :param set y: Another set :return: The similarity between """ a, b = set(x), set(y) if not a or not b: return 0.0 ...
[ "Calculate", "the", "tanimoto", "set", "similarity", "using", "the", "minimum", "size", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L86-L98
[ "def", "min_tanimoto_set_similarity", "(", "x", ":", "Iterable", "[", "X", "]", ",", "y", ":", "Iterable", "[", "X", "]", ")", "->", "float", ":", "a", ",", "b", "=", "set", "(", "x", ")", ",", "set", "(", "y", ")", "if", "not", "a", "or", "n...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_single_tanimoto_set_distances
Return a dictionary of distances keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained :param set target: A set :param dict_of_sets: A dict of {x: set of y} :type dict_of_sets: dict :return: A similarity dicationary based on the s...
src/pybel_tools/utils.py
def calculate_single_tanimoto_set_distances(target: Iterable[X], dict_of_sets: Mapping[Y, Set[X]]) -> Mapping[Y, float]: """Return a dictionary of distances keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained :param set target: A set ...
def calculate_single_tanimoto_set_distances(target: Iterable[X], dict_of_sets: Mapping[Y, Set[X]]) -> Mapping[Y, float]: """Return a dictionary of distances keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained :param set target: A set ...
[ "Return", "a", "dictionary", "of", "distances", "keyed", "by", "the", "keys", "in", "the", "given", "dict", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L101-L118
[ "def", "calculate_single_tanimoto_set_distances", "(", "target", ":", "Iterable", "[", "X", "]", ",", "dict_of_sets", ":", "Mapping", "[", "Y", ",", "Set", "[", "X", "]", "]", ")", "->", "Mapping", "[", "Y", ",", "float", "]", ":", "target_set", "=", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_tanimoto_set_distances
Return a distance matrix keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained. :param dict_of_sets: A dict of {x: set of y} :return: A similarity matrix based on the set overlap (tanimoto) score between each x as a dict of dicts
src/pybel_tools/utils.py
def calculate_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]: """Return a distance matrix keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained. :param dict_of_sets: A dict of {x: set of y} :ret...
def calculate_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]: """Return a distance matrix keyed by the keys in the given dict. Distances are calculated based on pairwise tanimoto similarity of the sets contained. :param dict_of_sets: A dict of {x: set of y} :ret...
[ "Return", "a", "distance", "matrix", "keyed", "by", "the", "keys", "in", "the", "given", "dict", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L121-L137
[ "def", "calculate_tanimoto_set_distances", "(", "dict_of_sets", ":", "Mapping", "[", "X", ",", "Set", "]", ")", "->", "Mapping", "[", "X", ",", "Mapping", "[", "X", ",", "float", "]", "]", ":", "result", ":", "Dict", "[", "X", ",", "Dict", "[", "X", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_global_tanimoto_set_distances
r"""Calculate an alternative distance matrix based on the following equation. .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\| :param dict_of_sets: A dict of {x: set of y} :return: A similarity matrix based on the alternative tanimoto distance as a dict of dicts
src/pybel_tools/utils.py
def calculate_global_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]: r"""Calculate an alternative distance matrix based on the following equation. .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\| :param dict_of_sets: A dict of {x: set of y} :retu...
def calculate_global_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]: r"""Calculate an alternative distance matrix based on the following equation. .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\| :param dict_of_sets: A dict of {x: set of y} :retu...
[ "r", "Calculate", "an", "alternative", "distance", "matrix", "based", "on", "the", "following", "equation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L140-L159
[ "def", "calculate_global_tanimoto_set_distances", "(", "dict_of_sets", ":", "Mapping", "[", "X", ",", "Set", "]", ")", "->", "Mapping", "[", "X", ",", "Mapping", "[", "X", ",", "float", "]", "]", ":", "universe", "=", "set", "(", "itt", ".", "chain", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
barh
A convenience function for plotting a horizontal bar plot from a Counter
src/pybel_tools/utils.py
def barh(d, plt, title=None): """A convenience function for plotting a horizontal bar plot from a Counter""" labels = sorted(d, key=d.get) index = range(len(labels)) plt.yticks(index, labels) plt.barh(index, [d[v] for v in labels]) if title is not None: plt.title(title)
def barh(d, plt, title=None): """A convenience function for plotting a horizontal bar plot from a Counter""" labels = sorted(d, key=d.get) index = range(len(labels)) plt.yticks(index, labels) plt.barh(index, [d[v] for v in labels]) if title is not None: plt.title(title)
[ "A", "convenience", "function", "for", "plotting", "a", "horizontal", "bar", "plot", "from", "a", "Counter" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L162-L171
[ "def", "barh", "(", "d", ",", "plt", ",", "title", "=", "None", ")", ":", "labels", "=", "sorted", "(", "d", ",", "key", "=", "d", ".", "get", ")", "index", "=", "range", "(", "len", "(", "labels", ")", ")", "plt", ".", "yticks", "(", "index"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
barv
A convenience function for plotting a vertical bar plot from a Counter
src/pybel_tools/utils.py
def barv(d, plt, title=None, rotation='vertical'): """A convenience function for plotting a vertical bar plot from a Counter""" labels = sorted(d, key=d.get, reverse=True) index = range(len(labels)) plt.xticks(index, labels, rotation=rotation) plt.bar(index, [d[v] for v in labels]) if title is ...
def barv(d, plt, title=None, rotation='vertical'): """A convenience function for plotting a vertical bar plot from a Counter""" labels = sorted(d, key=d.get, reverse=True) index = range(len(labels)) plt.xticks(index, labels, rotation=rotation) plt.bar(index, [d[v] for v in labels]) if title is ...
[ "A", "convenience", "function", "for", "plotting", "a", "vertical", "bar", "plot", "from", "a", "Counter" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L174-L182
[ "def", "barv", "(", "d", ",", "plt", ",", "title", "=", "None", ",", "rotation", "=", "'vertical'", ")", ":", "labels", "=", "sorted", "(", "d", ",", "key", "=", "d", ".", "get", ",", "reverse", "=", "True", ")", "index", "=", "range", "(", "le...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
safe_add_edge
Adds an edge while preserving negative keys, and paying no respect to positive ones :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :param int key: The edge key. If less than zero, corresponds to an unqualified edge, else is disregarded ...
src/pybel_tools/utils.py
def safe_add_edge(graph, u, v, key, attr_dict, **attr): """Adds an edge while preserving negative keys, and paying no respect to positive ones :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :param int key: The edge key. If less than ...
def safe_add_edge(graph, u, v, key, attr_dict, **attr): """Adds an edge while preserving negative keys, and paying no respect to positive ones :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :param int key: The edge key. If less than ...
[ "Adds", "an", "edge", "while", "preserving", "negative", "keys", "and", "paying", "no", "respect", "to", "positive", "ones" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L185-L198
[ "def", "safe_add_edge", "(", "graph", ",", "u", ",", "v", ",", "key", ",", "attr_dict", ",", "*", "*", "attr", ")", ":", "if", "key", "<", "0", ":", "graph", ".", "add_edge", "(", "u", ",", "v", ",", "key", "=", "key", ",", "attr_dict", "=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
prepare_c3
Prepares C3 JSON for making a bar chart from a Counter :param data: A dictionary of {str: int} to display as bar chart :param y_axis_label: The Y axis label :param x_axis_label: X axis internal label. Should be left as default 'x') :return: A JSON dictionary for making a C3 bar chart
src/pybel_tools/utils.py
def prepare_c3(data: Union[List[Tuple[str, int]], Mapping[str, int]], y_axis_label: str = 'y', x_axis_label: str = 'x', ) -> str: """Prepares C3 JSON for making a bar chart from a Counter :param data: A dictionary of {str: int} to display as bar chart :param y_a...
def prepare_c3(data: Union[List[Tuple[str, int]], Mapping[str, int]], y_axis_label: str = 'y', x_axis_label: str = 'x', ) -> str: """Prepares C3 JSON for making a bar chart from a Counter :param data: A dictionary of {str: int} to display as bar chart :param y_a...
[ "Prepares", "C3", "JSON", "for", "making", "a", "bar", "chart", "from", "a", "Counter" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L201-L224
[ "def", "prepare_c3", "(", "data", ":", "Union", "[", "List", "[", "Tuple", "[", "str", ",", "int", "]", "]", ",", "Mapping", "[", "str", ",", "int", "]", "]", ",", "y_axis_label", ":", "str", "=", "'y'", ",", "x_axis_label", ":", "str", "=", "'x'...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
prepare_c3_time_series
Prepare C3 JSON string dump for a time series. :param data: A list of tuples [(year, count)] :param y_axis_label: The Y axis label :param x_axis_label: X axis internal label. Should be left as default 'x')
src/pybel_tools/utils.py
def prepare_c3_time_series(data: List[Tuple[int, int]], y_axis_label: str = 'y', x_axis_label: str = 'x') -> str: """Prepare C3 JSON string dump for a time series. :param data: A list of tuples [(year, count)] :param y_axis_label: The Y axis label :param x_axis_label: X axis internal label. Should be l...
def prepare_c3_time_series(data: List[Tuple[int, int]], y_axis_label: str = 'y', x_axis_label: str = 'x') -> str: """Prepare C3 JSON string dump for a time series. :param data: A list of tuples [(year, count)] :param y_axis_label: The Y axis label :param x_axis_label: X axis internal label. Should be l...
[ "Prepare", "C3", "JSON", "string", "dump", "for", "a", "time", "series", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L227-L244
[ "def", "prepare_c3_time_series", "(", "data", ":", "List", "[", "Tuple", "[", "int", ",", "int", "]", "]", ",", "y_axis_label", ":", "str", "=", "'y'", ",", "x_axis_label", ":", "str", "=", "'x'", ")", "->", "str", ":", "years", ",", "counter", "=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
calculate_betweenness_centality
Calculate the betweenness centrality over nodes in the graph. Tries to do it with a certain number of samples, but then tries a complete approach if it fails.
src/pybel_tools/utils.py
def calculate_betweenness_centality(graph: BELGraph, number_samples: int = CENTRALITY_SAMPLES) -> Counter: """Calculate the betweenness centrality over nodes in the graph. Tries to do it with a certain number of samples, but then tries a complete approach if it fails. """ try: res = nx.betweenn...
def calculate_betweenness_centality(graph: BELGraph, number_samples: int = CENTRALITY_SAMPLES) -> Counter: """Calculate the betweenness centrality over nodes in the graph. Tries to do it with a certain number of samples, but then tries a complete approach if it fails. """ try: res = nx.betweenn...
[ "Calculate", "the", "betweenness", "centrality", "over", "nodes", "in", "the", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L253-L262
[ "def", "calculate_betweenness_centality", "(", "graph", ":", "BELGraph", ",", "number_samples", ":", "int", "=", "CENTRALITY_SAMPLES", ")", "->", "Counter", ":", "try", ":", "res", "=", "nx", ".", "betweenness_centrality", "(", "graph", ",", "k", "=", "number_...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_circulations
Iterate over all possible circulations of an ordered collection (tuple or list). Example: >>> list(get_circulations([1, 2, 3])) [[1, 2, 3], [2, 3, 1], [3, 1, 2]]
src/pybel_tools/utils.py
def get_circulations(elements: T) -> Iterable[T]: """Iterate over all possible circulations of an ordered collection (tuple or list). Example: >>> list(get_circulations([1, 2, 3])) [[1, 2, 3], [2, 3, 1], [3, 1, 2]] """ for i in range(len(elements)): yield elements[i:] + elements[:i]
def get_circulations(elements: T) -> Iterable[T]: """Iterate over all possible circulations of an ordered collection (tuple or list). Example: >>> list(get_circulations([1, 2, 3])) [[1, 2, 3], [2, 3, 1], [3, 1, 2]] """ for i in range(len(elements)): yield elements[i:] + elements[:i]
[ "Iterate", "over", "all", "possible", "circulations", "of", "an", "ordered", "collection", "(", "tuple", "or", "list", ")", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L268-L277
[ "def", "get_circulations", "(", "elements", ":", "T", ")", "->", "Iterable", "[", "T", "]", ":", "for", "i", "in", "range", "(", "len", "(", "elements", ")", ")", ":", "yield", "elements", "[", "i", ":", "]", "+", "elements", "[", ":", "i", "]" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
canonical_circulation
Get get a canonical representation of the ordered collection by finding its minimum circulation with the given sort key
src/pybel_tools/utils.py
def canonical_circulation(elements: T, key: Optional[Callable[[T], bool]] = None) -> T: """Get get a canonical representation of the ordered collection by finding its minimum circulation with the given sort key """ return min(get_circulations(elements), key=key)
def canonical_circulation(elements: T, key: Optional[Callable[[T], bool]] = None) -> T: """Get get a canonical representation of the ordered collection by finding its minimum circulation with the given sort key """ return min(get_circulations(elements), key=key)
[ "Get", "get", "a", "canonical", "representation", "of", "the", "ordered", "collection", "by", "finding", "its", "minimum", "circulation", "with", "the", "given", "sort", "key" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L280-L284
[ "def", "canonical_circulation", "(", "elements", ":", "T", ",", "key", ":", "Optional", "[", "Callable", "[", "[", "T", "]", ",", "bool", "]", "]", "=", "None", ")", "->", "T", ":", "return", "min", "(", "get_circulations", "(", "elements", ")", ",",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
pair_has_contradiction
Check if a pair of nodes has any contradictions in their causal relationships. Assumes both nodes are in the graph.
src/pybel_tools/summary/contradictions.py
def pair_has_contradiction(graph: BELGraph, u: BaseEntity, v: BaseEntity) -> bool: """Check if a pair of nodes has any contradictions in their causal relationships. Assumes both nodes are in the graph. """ relations = {data[RELATION] for data in graph[u][v].values()} return relation_set_has_contrad...
def pair_has_contradiction(graph: BELGraph, u: BaseEntity, v: BaseEntity) -> bool: """Check if a pair of nodes has any contradictions in their causal relationships. Assumes both nodes are in the graph. """ relations = {data[RELATION] for data in graph[u][v].values()} return relation_set_has_contrad...
[ "Check", "if", "a", "pair", "of", "nodes", "has", "any", "contradictions", "in", "their", "causal", "relationships", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/contradictions.py#L17-L23
[ "def", "pair_has_contradiction", "(", "graph", ":", "BELGraph", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ")", "->", "bool", ":", "relations", "=", "{", "data", "[", "RELATION", "]", "for", "data", "in", "graph", "[", "u", "]", "[", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
relation_set_has_contradictions
Return if the set of BEL relations contains a contradiction.
src/pybel_tools/summary/contradictions.py
def relation_set_has_contradictions(relations: Set[str]) -> bool: """Return if the set of BEL relations contains a contradiction.""" has_increases = any(relation in CAUSAL_INCREASE_RELATIONS for relation in relations) has_decreases = any(relation in CAUSAL_DECREASE_RELATIONS for relation in relations) h...
def relation_set_has_contradictions(relations: Set[str]) -> bool: """Return if the set of BEL relations contains a contradiction.""" has_increases = any(relation in CAUSAL_INCREASE_RELATIONS for relation in relations) has_decreases = any(relation in CAUSAL_DECREASE_RELATIONS for relation in relations) h...
[ "Return", "if", "the", "set", "of", "BEL", "relations", "contains", "a", "contradiction", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/contradictions.py#L26-L31
[ "def", "relation_set_has_contradictions", "(", "relations", ":", "Set", "[", "str", "]", ")", "->", "bool", ":", "has_increases", "=", "any", "(", "relation", "in", "CAUSAL_INCREASE_RELATIONS", "for", "relation", "in", "relations", ")", "has_decreases", "=", "an...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
percolation_graph
Prepare the (internal) percolation graph from a given graph Helper function to prepare the given graph for spanning cluster detection (if required). Basically it strips off the auxiliary nodes and edges again. It also returns fundamental graph quantitities (number of nodes and edges). Parameters ...
percolate/percolate.py
def percolation_graph(graph, spanning_cluster=True): """ Prepare the (internal) percolation graph from a given graph Helper function to prepare the given graph for spanning cluster detection (if required). Basically it strips off the auxiliary nodes and edges again. It also returns fundamental ...
def percolation_graph(graph, spanning_cluster=True): """ Prepare the (internal) percolation graph from a given graph Helper function to prepare the given graph for spanning cluster detection (if required). Basically it strips off the auxiliary nodes and edges again. It also returns fundamental ...
[ "Prepare", "the", "(", "internal", ")", "percolation", "graph", "from", "a", "given", "graph" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L31-L100
[ "def", "percolation_graph", "(", "graph", ",", "spanning_cluster", "=", "True", ")", ":", "ret", "=", "dict", "(", ")", "ret", "[", "'graph'", "]", "=", "graph", "ret", "[", "'spanning_cluster'", "]", "=", "bool", "(", "spanning_cluster", ")", "# initializ...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
sample_states
Generate successive sample states of the percolation model This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from the graph to the percolation model. At each iteration, it calculates and returns the cluster statistics. Parameters ---------- grap...
percolate/percolate.py
def sample_states( graph, spanning_cluster=True, model='bond', copy_result=True ): ''' Generate successive sample states of the percolation model This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from the graph to the percolation model. At each i...
def sample_states( graph, spanning_cluster=True, model='bond', copy_result=True ): ''' Generate successive sample states of the percolation model This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from the graph to the percolation model. At each i...
[ "Generate", "successive", "sample", "states", "of", "the", "percolation", "model" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L103-L356
[ "def", "sample_states", "(", "graph", ",", "spanning_cluster", "=", "True", ",", "model", "=", "'bond'", ",", "copy_result", "=", "True", ")", ":", "if", "model", "!=", "'bond'", ":", "raise", "ValueError", "(", "'Only bond percolation supported.'", ")", "if",...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
single_run_arrays
r''' Generate statistics for a single run This is a stand-alone helper function to evolve a single sample state (realization) and return the cluster statistics. Parameters ---------- spanning_cluster : bool, optional Whether to detect a spanning cluster or not. Defaults to ``Tr...
percolate/percolate.py
def single_run_arrays(spanning_cluster=True, **kwargs): r''' Generate statistics for a single run This is a stand-alone helper function to evolve a single sample state (realization) and return the cluster statistics. Parameters ---------- spanning_cluster : bool, optional Whether t...
def single_run_arrays(spanning_cluster=True, **kwargs): r''' Generate statistics for a single run This is a stand-alone helper function to evolve a single sample state (realization) and return the cluster statistics. Parameters ---------- spanning_cluster : bool, optional Whether t...
[ "r", "Generate", "statistics", "for", "a", "single", "run" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L359-L447
[ "def", "single_run_arrays", "(", "spanning_cluster", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# initial iteration", "# we do not need a copy of the result dictionary since we copy the values", "# anyway", "kwargs", "[", "'copy_result'", "]", "=", "False", "ret", "...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
_microcanonical_average_spanning_cluster
r''' Compute the average number of runs that have a spanning cluster Helper function for :func:`microcanonical_averages` Parameters ---------- has_spanning_cluster : 1-D :py:class:`numpy.ndarray` of bool Each entry is the ``has_spanning_cluster`` field of the output of :func:`samp...
percolate/percolate.py
def _microcanonical_average_spanning_cluster(has_spanning_cluster, alpha): r''' Compute the average number of runs that have a spanning cluster Helper function for :func:`microcanonical_averages` Parameters ---------- has_spanning_cluster : 1-D :py:class:`numpy.ndarray` of bool Each e...
def _microcanonical_average_spanning_cluster(has_spanning_cluster, alpha): r''' Compute the average number of runs that have a spanning cluster Helper function for :func:`microcanonical_averages` Parameters ---------- has_spanning_cluster : 1-D :py:class:`numpy.ndarray` of bool Each e...
[ "r", "Compute", "the", "average", "number", "of", "runs", "that", "have", "a", "spanning", "cluster" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L450-L572
[ "def", "_microcanonical_average_spanning_cluster", "(", "has_spanning_cluster", ",", "alpha", ")", ":", "ret", "=", "dict", "(", ")", "runs", "=", "has_spanning_cluster", ".", "size", "# Bayesian posterior mean for Binomial proportion (uniform prior)", "k", "=", "has_spanni...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
_microcanonical_average_max_cluster_size
Compute the average size of the largest cluster Helper function for :func:`microcanonical_averages` Parameters ---------- max_cluster_size : 1-D :py:class:`numpy.ndarray` of int Each entry is the ``max_cluster_size`` field of the output of :func:`sample_states`: The size of th...
percolate/percolate.py
def _microcanonical_average_max_cluster_size(max_cluster_size, alpha): """ Compute the average size of the largest cluster Helper function for :func:`microcanonical_averages` Parameters ---------- max_cluster_size : 1-D :py:class:`numpy.ndarray` of int Each entry is the ``max_cluster_...
def _microcanonical_average_max_cluster_size(max_cluster_size, alpha): """ Compute the average size of the largest cluster Helper function for :func:`microcanonical_averages` Parameters ---------- max_cluster_size : 1-D :py:class:`numpy.ndarray` of int Each entry is the ``max_cluster_...
[ "Compute", "the", "average", "size", "of", "the", "largest", "cluster" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L575-L635
[ "def", "_microcanonical_average_max_cluster_size", "(", "max_cluster_size", ",", "alpha", ")", ":", "ret", "=", "dict", "(", ")", "runs", "=", "max_cluster_size", ".", "size", "sqrt_n", "=", "np", ".", "sqrt", "(", "runs", ")", "max_cluster_size_sample_mean", "=...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
_microcanonical_average_moments
Compute the average moments of the cluster size distributions Helper function for :func:`microcanonical_averages` Parameters ---------- moments : 2-D :py:class:`numpy.ndarray` of int ``moments.shape[1] == 5`. Each array ``moments[r, :]`` is the ``moments`` field of the output of ...
percolate/percolate.py
def _microcanonical_average_moments(moments, alpha): """ Compute the average moments of the cluster size distributions Helper function for :func:`microcanonical_averages` Parameters ---------- moments : 2-D :py:class:`numpy.ndarray` of int ``moments.shape[1] == 5`. Each array ...
def _microcanonical_average_moments(moments, alpha): """ Compute the average moments of the cluster size distributions Helper function for :func:`microcanonical_averages` Parameters ---------- moments : 2-D :py:class:`numpy.ndarray` of int ``moments.shape[1] == 5`. Each array ...
[ "Compute", "the", "average", "moments", "of", "the", "cluster", "size", "distributions" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L638-L705
[ "def", "_microcanonical_average_moments", "(", "moments", ",", "alpha", ")", ":", "ret", "=", "dict", "(", ")", "runs", "=", "moments", ".", "shape", "[", "0", "]", "sqrt_n", "=", "np", ".", "sqrt", "(", "runs", ")", "moments_sample_mean", "=", "moments"...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
microcanonical_averages
r''' Generate successive microcanonical percolation ensemble averages This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from the graph to the percolation model for a number of independent runs in parallel. At each iteration, it calculates and returns...
percolate/percolate.py
def microcanonical_averages( graph, runs=40, spanning_cluster=True, model='bond', alpha=alpha_1sigma, copy_result=True ): r''' Generate successive microcanonical percolation ensemble averages This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from...
def microcanonical_averages( graph, runs=40, spanning_cluster=True, model='bond', alpha=alpha_1sigma, copy_result=True ): r''' Generate successive microcanonical percolation ensemble averages This is a :ref:`generator function <python:tut-generators>` to successively add one edge at a time from...
[ "r", "Generate", "successive", "microcanonical", "percolation", "ensemble", "averages" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L708-L896
[ "def", "microcanonical_averages", "(", "graph", ",", "runs", "=", "40", ",", "spanning_cluster", "=", "True", ",", "model", "=", "'bond'", ",", "alpha", "=", "alpha_1sigma", ",", "copy_result", "=", "True", ")", ":", "try", ":", "runs", "=", "int", "(", ...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
spanning_1d_chain
Generate a linear chain with auxiliary nodes for spanning cluster detection Parameters ---------- length : int Number of nodes in the chain, excluding the auxiliary nodes. Returns ------- networkx.Graph A linear chain graph with auxiliary nodes for spanning cluster detection ...
percolate/percolate.py
def spanning_1d_chain(length): """ Generate a linear chain with auxiliary nodes for spanning cluster detection Parameters ---------- length : int Number of nodes in the chain, excluding the auxiliary nodes. Returns ------- networkx.Graph A linear chain graph with auxili...
def spanning_1d_chain(length): """ Generate a linear chain with auxiliary nodes for spanning cluster detection Parameters ---------- length : int Number of nodes in the chain, excluding the auxiliary nodes. Returns ------- networkx.Graph A linear chain graph with auxili...
[ "Generate", "a", "linear", "chain", "with", "auxiliary", "nodes", "for", "spanning", "cluster", "detection" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L899-L928
[ "def", "spanning_1d_chain", "(", "length", ")", ":", "ret", "=", "nx", ".", "grid_graph", "(", "dim", "=", "[", "int", "(", "length", "+", "2", ")", "]", ")", "ret", ".", "node", "[", "0", "]", "[", "'span'", "]", "=", "0", "ret", "[", "0", "...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
spanning_2d_grid
Generate a square lattice with auxiliary nodes for spanning detection Parameters ---------- length : int Number of nodes in one dimension, excluding the auxiliary nodes. Returns ------- networkx.Graph A square lattice graph with auxiliary nodes for spanning cluster detec...
percolate/percolate.py
def spanning_2d_grid(length): """ Generate a square lattice with auxiliary nodes for spanning detection Parameters ---------- length : int Number of nodes in one dimension, excluding the auxiliary nodes. Returns ------- networkx.Graph A square lattice graph with auxilia...
def spanning_2d_grid(length): """ Generate a square lattice with auxiliary nodes for spanning detection Parameters ---------- length : int Number of nodes in one dimension, excluding the auxiliary nodes. Returns ------- networkx.Graph A square lattice graph with auxilia...
[ "Generate", "a", "square", "lattice", "with", "auxiliary", "nodes", "for", "spanning", "detection" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L931-L965
[ "def", "spanning_2d_grid", "(", "length", ")", ":", "ret", "=", "nx", ".", "grid_2d_graph", "(", "length", "+", "2", ",", "length", ")", "for", "i", "in", "range", "(", "length", ")", ":", "# side 0", "ret", ".", "node", "[", "(", "0", ",", "i", ...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
microcanonical_averages_arrays
Compile microcanonical averages over all iteration steps into single arrays Helper function to aggregate the microcanonical averages over all iteration steps into single arrays for further processing Parameters ---------- microcanonical_averages : iterable Typically, this is the :func:`mic...
percolate/percolate.py
def microcanonical_averages_arrays(microcanonical_averages): """ Compile microcanonical averages over all iteration steps into single arrays Helper function to aggregate the microcanonical averages over all iteration steps into single arrays for further processing Parameters ---------- mi...
def microcanonical_averages_arrays(microcanonical_averages): """ Compile microcanonical averages over all iteration steps into single arrays Helper function to aggregate the microcanonical averages over all iteration steps into single arrays for further processing Parameters ---------- mi...
[ "Compile", "microcanonical", "averages", "over", "all", "iteration", "steps", "into", "single", "arrays" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L968-L1064
[ "def", "microcanonical_averages_arrays", "(", "microcanonical_averages", ")", ":", "ret", "=", "dict", "(", ")", "for", "n", ",", "microcanonical_average", "in", "enumerate", "(", "microcanonical_averages", ")", ":", "assert", "n", "==", "microcanonical_average", "[...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
_binomial_pmf
Compute the binomial PMF according to Newman and Ziff Helper function for :func:`canonical_averages` See Also -------- canonical_averages Notes ----- See Newman & Ziff, Equation (10) [10]_ References ---------- .. [10] Newman, M. E. J. & Ziff, R. M. Fast monte carlo algori...
percolate/percolate.py
def _binomial_pmf(n, p): """ Compute the binomial PMF according to Newman and Ziff Helper function for :func:`canonical_averages` See Also -------- canonical_averages Notes ----- See Newman & Ziff, Equation (10) [10]_ References ---------- .. [10] Newman, M. E. J. ...
def _binomial_pmf(n, p): """ Compute the binomial PMF according to Newman and Ziff Helper function for :func:`canonical_averages` See Also -------- canonical_averages Notes ----- See Newman & Ziff, Equation (10) [10]_ References ---------- .. [10] Newman, M. E. J. ...
[ "Compute", "the", "binomial", "PMF", "according", "to", "Newman", "and", "Ziff" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L1067-L1109
[ "def", "_binomial_pmf", "(", "n", ",", "p", ")", ":", "n", "=", "int", "(", "n", ")", "ret", "=", "np", ".", "empty", "(", "n", "+", "1", ")", "nmax", "=", "int", "(", "np", ".", "round", "(", "p", "*", "n", ")", ")", "ret", "[", "nmax", ...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
canonical_averages
Compute the canonical cluster statistics from microcanonical statistics This is according to Newman and Ziff, Equation (2). Note that we also simply average the bounds of the confidence intervals according to this formula. Parameters ---------- ps : iterable of float Each entry is a pr...
percolate/percolate.py
def canonical_averages(ps, microcanonical_averages_arrays): """ Compute the canonical cluster statistics from microcanonical statistics This is according to Newman and Ziff, Equation (2). Note that we also simply average the bounds of the confidence intervals according to this formula. Paramet...
def canonical_averages(ps, microcanonical_averages_arrays): """ Compute the canonical cluster statistics from microcanonical statistics This is according to Newman and Ziff, Equation (2). Note that we also simply average the bounds of the confidence intervals according to this formula. Paramet...
[ "Compute", "the", "canonical", "cluster", "statistics", "from", "microcanonical", "statistics" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L1112-L1223
[ "def", "canonical_averages", "(", "ps", ",", "microcanonical_averages_arrays", ")", ":", "num_sites", "=", "microcanonical_averages_arrays", "[", "'N'", "]", "num_edges", "=", "microcanonical_averages_arrays", "[", "'M'", "]", "spanning_cluster", "=", "(", "'spanning_cl...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
valid
statistics
Helper function to compute percolation statistics See Also -------- canonical_averages microcanonical_averages sample_states
percolate/percolate.py
def statistics( graph, ps, spanning_cluster=True, model='bond', alpha=alpha_1sigma, runs=40 ): """ Helper function to compute percolation statistics See Also -------- canonical_averages microcanonical_averages sample_states """ my_microcanonical_averages = microcanonical_av...
def statistics( graph, ps, spanning_cluster=True, model='bond', alpha=alpha_1sigma, runs=40 ): """ Helper function to compute percolation statistics See Also -------- canonical_averages microcanonical_averages sample_states """ my_microcanonical_averages = microcanonical_av...
[ "Helper", "function", "to", "compute", "percolation", "statistics" ]
andsor/pypercolate
python
https://github.com/andsor/pypercolate/blob/92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac/percolate/percolate.py#L1226-L1252
[ "def", "statistics", "(", "graph", ",", "ps", ",", "spanning_cluster", "=", "True", ",", "model", "=", "'bond'", ",", "alpha", "=", "alpha_1sigma", ",", "runs", "=", "40", ")", ":", "my_microcanonical_averages", "=", "microcanonical_averages", "(", "graph", ...
92478c1fc4d4ff5ae157f7607fd74f6f9ec360ac
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('html_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), file=file)
src/pybel_tools/assembler/html/assembler.py
def to_html(graph: BELGraph) -> 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('html_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), file=file) """ context = g...
def to_html(graph: BELGraph) -> 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('html_output.html', 'w') as file: ... print(to_html(sialic_acid_graph), file=file) """ context = g...
[ "Render", "the", "graph", "as", "an", "HTML", "string", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/html/assembler.py#L45-L98
[ "def", "to_html", "(", "graph", ":", "BELGraph", ")", "->", "str", ":", "context", "=", "get_network_summary_dict", "(", "graph", ")", "summary_dict", "=", "graph", ".", "summary_dict", "(", ")", "citation_years", "=", "context", "[", "'citation_years'", "]", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_network_summary_dict
Create a summary dictionary.
src/pybel_tools/assembler/html/assembler.py
def get_network_summary_dict(graph: BELGraph) -> Mapping: """Create a summary dictionary.""" return dict( # Counters function_count=count_functions(graph), modifications_count=get_modifications_count(graph), relation_count=count_relations(graph), authors_count=count_autho...
def get_network_summary_dict(graph: BELGraph) -> Mapping: """Create a summary dictionary.""" return dict( # Counters function_count=count_functions(graph), modifications_count=get_modifications_count(graph), relation_count=count_relations(graph), authors_count=count_autho...
[ "Create", "a", "summary", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/html/assembler.py#L101-L171
[ "def", "get_network_summary_dict", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", ":", "return", "dict", "(", "# Counters", "function_count", "=", "count_functions", "(", "graph", ")", ",", "modifications_count", "=", "get_modifications_count", "(", "graph", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_pair_tuple
Get the pair as a tuple of BEL/hashes.
src/pybel_tools/assembler/html/assembler.py
def get_pair_tuple(a: BaseEntity, b: BaseEntity) -> Tuple[str, str, str, str]: """Get the pair as a tuple of BEL/hashes.""" return a.as_bel(), a.sha512, b.as_bel(), b.sha512
def get_pair_tuple(a: BaseEntity, b: BaseEntity) -> Tuple[str, str, str, str]: """Get the pair as a tuple of BEL/hashes.""" return a.as_bel(), a.sha512, b.as_bel(), b.sha512
[ "Get", "the", "pair", "as", "a", "tuple", "of", "BEL", "/", "hashes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/html/assembler.py#L174-L176
[ "def", "get_pair_tuple", "(", "a", ":", "BaseEntity", ",", "b", ":", "BaseEntity", ")", "->", "Tuple", "[", "str", ",", "str", ",", "str", ",", "str", "]", ":", "return", "a", ".", "as_bel", "(", ")", ",", "a", ".", "sha512", ",", "b", ".", "as...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_triplet_tuple
Get the triple as a tuple of BEL/hashes.
src/pybel_tools/assembler/html/assembler.py
def get_triplet_tuple(a: BaseEntity, b: BaseEntity, c: BaseEntity) -> Tuple[str, str, str, str, str, str]: """Get the triple as a tuple of BEL/hashes.""" return a.as_bel(), a.sha512, b.as_bel(), b.sha512, c.as_bel(), c.sha512
def get_triplet_tuple(a: BaseEntity, b: BaseEntity, c: BaseEntity) -> Tuple[str, str, str, str, str, str]: """Get the triple as a tuple of BEL/hashes.""" return a.as_bel(), a.sha512, b.as_bel(), b.sha512, c.as_bel(), c.sha512
[ "Get", "the", "triple", "as", "a", "tuple", "of", "BEL", "/", "hashes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/assembler/html/assembler.py#L179-L181
[ "def", "get_triplet_tuple", "(", "a", ":", "BaseEntity", ",", "b", ":", "BaseEntity", ",", "c", ":", "BaseEntity", ")", "->", "Tuple", "[", "str", ",", "str", ",", "str", ",", "str", ",", "str", ",", "str", "]", ":", "return", "a", ".", "as_bel", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
rank_causalr_hypothesis
Test the regulator hypothesis of the given node on the input data using the algorithm. Note: this method returns both +/- signed hypotheses evaluated Algorithm: 1. Calculate the shortest path between the regulator node and each node in observed_regulation 2. Calculate the concordance of the causal ne...
src/pybel_tools/analysis/causalr/algorithm.py
def rank_causalr_hypothesis(graph, node_to_regulation, regulator_node): """Test the regulator hypothesis of the given node on the input data using the algorithm. Note: this method returns both +/- signed hypotheses evaluated Algorithm: 1. Calculate the shortest path between the regulator node and eac...
def rank_causalr_hypothesis(graph, node_to_regulation, regulator_node): """Test the regulator hypothesis of the given node on the input data using the algorithm. Note: this method returns both +/- signed hypotheses evaluated Algorithm: 1. Calculate the shortest path between the regulator node and eac...
[ "Test", "the", "regulator", "hypothesis", "of", "the", "given", "node", "on", "the", "input", "data", "using", "the", "algorithm", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/causalr/algorithm.py#L26-L82
[ "def", "rank_causalr_hypothesis", "(", "graph", ",", "node_to_regulation", ",", "regulator_node", ")", ":", "upregulation_hypothesis", "=", "{", "'correct'", ":", "0", ",", "'incorrect'", ":", "0", ",", "'ambiguous'", ":", "0", "}", "downregulation_hypothesis", "=...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
run_cna
Returns the effect from the root to the target nodes represented as {-1,1} :param pybel.BELGraph graph: A BEL graph :param BaseEntity root: The root node :param iter targets: The targets nodes :param dict relationship_dict: dictionary with relationship effects :return list[tuple]:
src/pybel_tools/analysis/causalr/algorithm.py
def run_cna(graph, root, targets, relationship_dict=None): """ Returns the effect from the root to the target nodes represented as {-1,1} :param pybel.BELGraph graph: A BEL graph :param BaseEntity root: The root node :param iter targets: The targets nodes :param dict relationship_dict: dictionary w...
def run_cna(graph, root, targets, relationship_dict=None): """ Returns the effect from the root to the target nodes represented as {-1,1} :param pybel.BELGraph graph: A BEL graph :param BaseEntity root: The root node :param iter targets: The targets nodes :param dict relationship_dict: dictionary w...
[ "Returns", "the", "effect", "from", "the", "root", "to", "the", "target", "nodes", "represented", "as", "{", "-", "1", "1", "}" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/causalr/algorithm.py#L85-L125
[ "def", "run_cna", "(", "graph", ",", "root", ",", "targets", ",", "relationship_dict", "=", "None", ")", ":", "causal_effects", "=", "[", "]", "relationship_dict", "=", "causal_effect_dict", "if", "relationship_dict", "is", "None", "else", "relationship_dict", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_path_effect
Calculate the final effect of the root node to the sink node in the path. :param pybel.BELGraph graph: A BEL graph :param list path: Path from root to sink node :param dict relationship_dict: dictionary with relationship effects :rtype: Effect
src/pybel_tools/analysis/causalr/algorithm.py
def get_path_effect(graph, path, relationship_dict): """Calculate the final effect of the root node to the sink node in the path. :param pybel.BELGraph graph: A BEL graph :param list path: Path from root to sink node :param dict relationship_dict: dictionary with relationship effects :rtype: Effect...
def get_path_effect(graph, path, relationship_dict): """Calculate the final effect of the root node to the sink node in the path. :param pybel.BELGraph graph: A BEL graph :param list path: Path from root to sink node :param dict relationship_dict: dictionary with relationship effects :rtype: Effect...
[ "Calculate", "the", "final", "effect", "of", "the", "root", "node", "to", "the", "sink", "node", "in", "the", "path", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/causalr/algorithm.py#L128-L157
[ "def", "get_path_effect", "(", "graph", ",", "path", ",", "relationship_dict", ")", ":", "causal_effect", "=", "[", "]", "for", "predecessor", ",", "successor", "in", "pairwise", "(", "path", ")", ":", "if", "pair_has_contradiction", "(", "graph", ",", "pred...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
rank_edges
Return the highest ranked edge from a multiedge. :param dict edges: dictionary with all edges between two nodes :param dict edge_ranking: A dictionary of {relationship: score} :return: Highest ranked edge :rtype: tuple: (edge id, relation, score given ranking)
src/pybel_tools/analysis/causalr/algorithm.py
def rank_edges(edges, edge_ranking=None): """Return the highest ranked edge from a multiedge. :param dict edges: dictionary with all edges between two nodes :param dict edge_ranking: A dictionary of {relationship: score} :return: Highest ranked edge :rtype: tuple: (edge id, relation, score given ra...
def rank_edges(edges, edge_ranking=None): """Return the highest ranked edge from a multiedge. :param dict edges: dictionary with all edges between two nodes :param dict edge_ranking: A dictionary of {relationship: score} :return: Highest ranked edge :rtype: tuple: (edge id, relation, score given ra...
[ "Return", "the", "highest", "ranked", "edge", "from", "a", "multiedge", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/causalr/algorithm.py#L160-L175
[ "def", "rank_edges", "(", "edges", ",", "edge_ranking", "=", "None", ")", ":", "edge_ranking", "=", "default_edge_ranking", "if", "edge_ranking", "is", "None", "else", "edge_ranking", "edges_scores", "=", "[", "(", "edge_id", ",", "edge_data", "[", "RELATION", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
group_nodes_by_annotation
Group the nodes occurring in edges by the given annotation.
src/pybel_tools/selection/group_nodes.py
def group_nodes_by_annotation(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, Set[BaseEntity]]: """Group the nodes occurring in edges by the given annotation.""" result = defaultdict(set) for u, v, d in graph.edges(data=True): if not edge_has_annotation(d, annotation): co...
def group_nodes_by_annotation(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, Set[BaseEntity]]: """Group the nodes occurring in edges by the given annotation.""" result = defaultdict(set) for u, v, d in graph.edges(data=True): if not edge_has_annotation(d, annotation): co...
[ "Group", "the", "nodes", "occurring", "in", "edges", "by", "the", "given", "annotation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/group_nodes.py#L22-L33
[ "def", "group_nodes_by_annotation", "(", "graph", ":", "BELGraph", ",", "annotation", ":", "str", "=", "'Subgraph'", ")", "->", "Mapping", "[", "str", ",", "Set", "[", "BaseEntity", "]", "]", ":", "result", "=", "defaultdict", "(", "set", ")", "for", "u"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
average_node_annotation
Groups graph into subgraphs and assigns each subgraph a score based on the average of all nodes values for the given node key :param pybel.BELGraph graph: A BEL graph :param key: The key in the node data dictionary representing the experimental data :param annotation: A BEL annotation to use to group n...
src/pybel_tools/selection/group_nodes.py
def average_node_annotation(graph: BELGraph, key: str, annotation: str = 'Subgraph', aggregator: Optional[Callable[[Iterable[X]], X]] = None, ) -> Mapping[str, X]: """Groups graph into subgraphs and assig...
def average_node_annotation(graph: BELGraph, key: str, annotation: str = 'Subgraph', aggregator: Optional[Callable[[Iterable[X]], X]] = None, ) -> Mapping[str, X]: """Groups graph into subgraphs and assig...
[ "Groups", "graph", "into", "subgraphs", "and", "assigns", "each", "subgraph", "a", "score", "based", "on", "the", "average", "of", "all", "nodes", "values", "for", "the", "given", "node", "key" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/group_nodes.py#L36-L63
[ "def", "average_node_annotation", "(", "graph", ":", "BELGraph", ",", "key", ":", "str", ",", "annotation", ":", "str", "=", "'Subgraph'", ",", "aggregator", ":", "Optional", "[", "Callable", "[", "[", "Iterable", "[", "X", "]", "]", ",", "X", "]", "]"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
group_nodes_by_annotation_filtered
Group the nodes occurring in edges by the given annotation, with a node filter applied. :param graph: A BEL graph :param node_predicates: A predicate or list of predicates (graph, node) -> bool :param annotation: The annotation to use for grouping :return: A dictionary of {annotation value: set of node...
src/pybel_tools/selection/group_nodes.py
def group_nodes_by_annotation_filtered(graph: BELGraph, node_predicates: NodePredicates = None, annotation: str = 'Subgraph', ) -> Mapping[str, Set[BaseEntity]]: """Group the nodes occurring in edges...
def group_nodes_by_annotation_filtered(graph: BELGraph, node_predicates: NodePredicates = None, annotation: str = 'Subgraph', ) -> Mapping[str, Set[BaseEntity]]: """Group the nodes occurring in edges...
[ "Group", "the", "nodes", "occurring", "in", "edges", "by", "the", "given", "annotation", "with", "a", "node", "filter", "applied", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/group_nodes.py#L66-L86
[ "def", "group_nodes_by_annotation_filtered", "(", "graph", ":", "BELGraph", ",", "node_predicates", ":", "NodePredicates", "=", "None", ",", "annotation", ":", "str", "=", "'Subgraph'", ",", ")", "->", "Mapping", "[", "str", ",", "Set", "[", "BaseEntity", "]",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_mapped_nodes
Return a dict with keys: nodes that match the namespace and in names and values other nodes (complexes, variants, orthologous...) or this node. :param graph: A BEL graph :param namespace: The namespace to search :param names: List or set of values from which we want to map nodes from :return: Main ...
src/pybel_tools/selection/group_nodes.py
def get_mapped_nodes(graph: BELGraph, namespace: str, names: Iterable[str]) -> Mapping[BaseEntity, Set[BaseEntity]]: """Return a dict with keys: nodes that match the namespace and in names and values other nodes (complexes, variants, orthologous...) or this node. :param graph: A BEL graph :param namesp...
def get_mapped_nodes(graph: BELGraph, namespace: str, names: Iterable[str]) -> Mapping[BaseEntity, Set[BaseEntity]]: """Return a dict with keys: nodes that match the namespace and in names and values other nodes (complexes, variants, orthologous...) or this node. :param graph: A BEL graph :param namesp...
[ "Return", "a", "dict", "with", "keys", ":", "nodes", "that", "match", "the", "namespace", "and", "in", "names", "and", "values", "other", "nodes", "(", "complexes", "variants", "orthologous", "...", ")", "or", "this", "node", ".", ":", "param", "graph", ...
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/group_nodes.py#L89-L110
[ "def", "get_mapped_nodes", "(", "graph", ":", "BELGraph", ",", "namespace", ":", "str", ",", "names", ":", "Iterable", "[", "str", "]", ")", "->", "Mapping", "[", "BaseEntity", ",", "Set", "[", "BaseEntity", "]", "]", ":", "parent_to_variants", "=", "def...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
build_expand_node_neighborhood_by_hash
Make an expand function that's bound to the manager.
src/pybel_tools/mutation/bound.py
def build_expand_node_neighborhood_by_hash(manager: Manager) -> Callable[[BELGraph, BELGraph, str], None]: """Make an expand function that's bound to the manager.""" @uni_in_place_transformation def expand_node_neighborhood_by_hash(universe: BELGraph, graph: BELGraph, node_hash: str) -> None: """Ex...
def build_expand_node_neighborhood_by_hash(manager: Manager) -> Callable[[BELGraph, BELGraph, str], None]: """Make an expand function that's bound to the manager.""" @uni_in_place_transformation def expand_node_neighborhood_by_hash(universe: BELGraph, graph: BELGraph, node_hash: str) -> None: """Ex...
[ "Make", "an", "expand", "function", "that", "s", "bound", "to", "the", "manager", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/bound.py#L17-L26
[ "def", "build_expand_node_neighborhood_by_hash", "(", "manager", ":", "Manager", ")", "->", "Callable", "[", "[", "BELGraph", ",", "BELGraph", ",", "str", "]", ",", "None", "]", ":", "@", "uni_in_place_transformation", "def", "expand_node_neighborhood_by_hash", "(",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
build_delete_node_by_hash
Make a delete function that's bound to the manager.
src/pybel_tools/mutation/bound.py
def build_delete_node_by_hash(manager: Manager) -> Callable[[BELGraph, str], None]: """Make a delete function that's bound to the manager.""" @in_place_transformation def delete_node_by_hash(graph: BELGraph, node_hash: str) -> None: """Remove a node by identifier.""" node = manager.get_dsl_...
def build_delete_node_by_hash(manager: Manager) -> Callable[[BELGraph, str], None]: """Make a delete function that's bound to the manager.""" @in_place_transformation def delete_node_by_hash(graph: BELGraph, node_hash: str) -> None: """Remove a node by identifier.""" node = manager.get_dsl_...
[ "Make", "a", "delete", "function", "that", "s", "bound", "to", "the", "manager", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/bound.py#L29-L38
[ "def", "build_delete_node_by_hash", "(", "manager", ":", "Manager", ")", "->", "Callable", "[", "[", "BELGraph", ",", "str", "]", ",", "None", "]", ":", "@", "in_place_transformation", "def", "delete_node_by_hash", "(", "graph", ":", "BELGraph", ",", "node_has...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
bel_to_spia_matrices
Create an excel sheet ready to be used in SPIA software. :param graph: BELGraph :return: dictionary with matrices
src/pybel_tools/analysis/spia.py
def bel_to_spia_matrices(graph: BELGraph) -> Mapping[str, pd.DataFrame]: """Create an excel sheet ready to be used in SPIA software. :param graph: BELGraph :return: dictionary with matrices """ index_nodes = get_matrix_index(graph) spia_matrices = build_spia_matrices(index_nodes) for u, v,...
def bel_to_spia_matrices(graph: BELGraph) -> Mapping[str, pd.DataFrame]: """Create an excel sheet ready to be used in SPIA software. :param graph: BELGraph :return: dictionary with matrices """ index_nodes = get_matrix_index(graph) spia_matrices = build_spia_matrices(index_nodes) for u, v,...
[ "Create", "an", "excel", "sheet", "ready", "to", "be", "used", "in", "SPIA", "software", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L64-L108
[ "def", "bel_to_spia_matrices", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "pd", ".", "DataFrame", "]", ":", "index_nodes", "=", "get_matrix_index", "(", "graph", ")", "spia_matrices", "=", "build_spia_matrices", "(", "index_nodes", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_matrix_index
Return set of HGNC names from Proteins/Rnas/Genes/miRNA, nodes that can be used by SPIA.
src/pybel_tools/analysis/spia.py
def get_matrix_index(graph: BELGraph) -> Set[str]: """Return set of HGNC names from Proteins/Rnas/Genes/miRNA, nodes that can be used by SPIA.""" # TODO: Using HGNC Symbols for now return { node.name for node in graph if isinstance(node, CentralDogma) and node.namespace.upper() == 'H...
def get_matrix_index(graph: BELGraph) -> Set[str]: """Return set of HGNC names from Proteins/Rnas/Genes/miRNA, nodes that can be used by SPIA.""" # TODO: Using HGNC Symbols for now return { node.name for node in graph if isinstance(node, CentralDogma) and node.namespace.upper() == 'H...
[ "Return", "set", "of", "HGNC", "names", "from", "Proteins", "/", "Rnas", "/", "Genes", "/", "miRNA", "nodes", "that", "can", "be", "used", "by", "SPIA", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L111-L118
[ "def", "get_matrix_index", "(", "graph", ":", "BELGraph", ")", "->", "Set", "[", "str", "]", ":", "# TODO: Using HGNC Symbols for now", "return", "{", "node", ".", "name", "for", "node", "in", "graph", "if", "isinstance", "(", "node", ",", "CentralDogma", ")...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
build_spia_matrices
Build an adjacency matrix for each KEGG relationship and return in a dictionary. :param nodes: A set of HGNC gene symbols :return: Dictionary of adjacency matrix for each relationship
src/pybel_tools/analysis/spia.py
def build_spia_matrices(nodes: Set[str]) -> Dict[str, pd.DataFrame]: """Build an adjacency matrix for each KEGG relationship and return in a dictionary. :param nodes: A set of HGNC gene symbols :return: Dictionary of adjacency matrix for each relationship """ nodes = list(sorted(nodes)) # Crea...
def build_spia_matrices(nodes: Set[str]) -> Dict[str, pd.DataFrame]: """Build an adjacency matrix for each KEGG relationship and return in a dictionary. :param nodes: A set of HGNC gene symbols :return: Dictionary of adjacency matrix for each relationship """ nodes = list(sorted(nodes)) # Crea...
[ "Build", "an", "adjacency", "matrix", "for", "each", "KEGG", "relationship", "and", "return", "in", "a", "dictionary", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L121-L134
[ "def", "build_spia_matrices", "(", "nodes", ":", "Set", "[", "str", "]", ")", "->", "Dict", "[", "str", ",", "pd", ".", "DataFrame", "]", ":", "nodes", "=", "list", "(", "sorted", "(", "nodes", ")", ")", "# Create sheets of the excel in the given order", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
update_spia_matrices
Populate the adjacency matrix.
src/pybel_tools/analysis/spia.py
def update_spia_matrices(spia_matrices: Dict[str, pd.DataFrame], u: CentralDogma, v: CentralDogma, edge_data: EdgeData, ) -> None: """Populate the adjacency matrix.""" if u.namespace.upper() != 'HGNC' or v.namesp...
def update_spia_matrices(spia_matrices: Dict[str, pd.DataFrame], u: CentralDogma, v: CentralDogma, edge_data: EdgeData, ) -> None: """Populate the adjacency matrix.""" if u.namespace.upper() != 'HGNC' or v.namesp...
[ "Populate", "the", "adjacency", "matrix", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L137-L181
[ "def", "update_spia_matrices", "(", "spia_matrices", ":", "Dict", "[", "str", ",", "pd", ".", "DataFrame", "]", ",", "u", ":", "CentralDogma", ",", "v", ":", "CentralDogma", ",", "edge_data", ":", "EdgeData", ",", ")", "->", "None", ":", "if", "u", "."...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
spia_matrices_to_excel
Export a SPIA data dictionary into an Excel sheet at the given path. .. note:: # The R import should add the values: # ["nodes"] from the columns # ["title"] from the name of the file # ["NumberOfReactions"] set to "0"
src/pybel_tools/analysis/spia.py
def spia_matrices_to_excel(spia_matrices: Mapping[str, pd.DataFrame], path: str) -> None: """Export a SPIA data dictionary into an Excel sheet at the given path. .. note:: # The R import should add the values: # ["nodes"] from the columns # ["title"] from the name of the file #...
def spia_matrices_to_excel(spia_matrices: Mapping[str, pd.DataFrame], path: str) -> None: """Export a SPIA data dictionary into an Excel sheet at the given path. .. note:: # The R import should add the values: # ["nodes"] from the columns # ["title"] from the name of the file #...
[ "Export", "a", "SPIA", "data", "dictionary", "into", "an", "Excel", "sheet", "at", "the", "given", "path", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L184-L200
[ "def", "spia_matrices_to_excel", "(", "spia_matrices", ":", "Mapping", "[", "str", ",", "pd", ".", "DataFrame", "]", ",", "path", ":", "str", ")", "->", "None", ":", "writer", "=", "pd", ".", "ExcelWriter", "(", "path", ",", "engine", "=", "'xlsxwriter'"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
spia_matrices_to_tsvs
Export a SPIA data dictionary into a directory as several TSV documents.
src/pybel_tools/analysis/spia.py
def spia_matrices_to_tsvs(spia_matrices: Mapping[str, pd.DataFrame], directory: str) -> None: """Export a SPIA data dictionary into a directory as several TSV documents.""" os.makedirs(directory, exist_ok=True) for relation, df in spia_matrices.items(): df.to_csv(os.path.join(directory, f'{relation}...
def spia_matrices_to_tsvs(spia_matrices: Mapping[str, pd.DataFrame], directory: str) -> None: """Export a SPIA data dictionary into a directory as several TSV documents.""" os.makedirs(directory, exist_ok=True) for relation, df in spia_matrices.items(): df.to_csv(os.path.join(directory, f'{relation}...
[ "Export", "a", "SPIA", "data", "dictionary", "into", "a", "directory", "as", "several", "TSV", "documents", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L203-L207
[ "def", "spia_matrices_to_tsvs", "(", "spia_matrices", ":", "Mapping", "[", "str", ",", "pd", ".", "DataFrame", "]", ",", "directory", ":", "str", ")", "->", "None", ":", "os", ".", "makedirs", "(", "directory", ",", "exist_ok", "=", "True", ")", "for", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
main
Export the graph to a SPIA Excel sheet.
src/pybel_tools/analysis/spia.py
def main(graph: BELGraph, xlsx: str, tsvs: str): """Export the graph to a SPIA Excel sheet.""" if not xlsx and not tsvs: click.secho('Specify at least one option --xlsx or --tsvs', fg='red') sys.exit(1) spia_matrices = bel_to_spia_matrices(graph) if xlsx: spia_matrices_to_excel...
def main(graph: BELGraph, xlsx: str, tsvs: str): """Export the graph to a SPIA Excel sheet.""" if not xlsx and not tsvs: click.secho('Specify at least one option --xlsx or --tsvs', fg='red') sys.exit(1) spia_matrices = bel_to_spia_matrices(graph) if xlsx: spia_matrices_to_excel...
[ "Export", "the", "graph", "to", "a", "SPIA", "Excel", "sheet", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/spia.py#L214-L226
[ "def", "main", "(", "graph", ":", "BELGraph", ",", "xlsx", ":", "str", ",", "tsvs", ":", "str", ")", ":", "if", "not", "xlsx", "and", "not", "tsvs", ":", "click", ".", "secho", "(", "'Specify at least one option --xlsx or --tsvs'", ",", "fg", "=", "'red'...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
overlay_data
Overlays tabular data on the network :param graph: A BEL Graph :param data: A dictionary of {tuple node: data for that node} :param label: The annotation label to put in the node dictionary :param overwrite: Should old annotations be overwritten?
src/pybel_tools/integration/overlay.py
def overlay_data(graph: BELGraph, data: Mapping[BaseEntity, Any], label: Optional[str] = None, overwrite: bool = False, ) -> None: """Overlays tabular data on the network :param graph: A BEL Graph :param data: A dictionary of {tuple node: ...
def overlay_data(graph: BELGraph, data: Mapping[BaseEntity, Any], label: Optional[str] = None, overwrite: bool = False, ) -> None: """Overlays tabular data on the network :param graph: A BEL Graph :param data: A dictionary of {tuple node: ...
[ "Overlays", "tabular", "data", "on", "the", "network" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/integration/overlay.py#L30-L54
[ "def", "overlay_data", "(", "graph", ":", "BELGraph", ",", "data", ":", "Mapping", "[", "BaseEntity", ",", "Any", "]", ",", "label", ":", "Optional", "[", "str", "]", "=", "None", ",", "overwrite", ":", "bool", "=", "False", ",", ")", "->", "None", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
overlay_type_data
Overlay tabular data on the network for data that comes from an data set with identifiers that lack namespaces. For example, if you want to overlay differential gene expression data from a table, that table probably has HGNC identifiers, but no specific annotations that they are in the HGNC namespace or ...
src/pybel_tools/integration/overlay.py
def overlay_type_data(graph: BELGraph, data: Mapping[str, float], func: str, namespace: str, label: Optional[str] = None, overwrite: bool = False, impute: Optional[float] = None, ...
def overlay_type_data(graph: BELGraph, data: Mapping[str, float], func: str, namespace: str, label: Optional[str] = None, overwrite: bool = False, impute: Optional[float] = None, ...
[ "Overlay", "tabular", "data", "on", "the", "network", "for", "data", "that", "comes", "from", "an", "data", "set", "with", "identifiers", "that", "lack", "namespaces", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/integration/overlay.py#L58-L86
[ "def", "overlay_type_data", "(", "graph", ":", "BELGraph", ",", "data", ":", "Mapping", "[", "str", ",", "float", "]", ",", "func", ":", "str", ",", "namespace", ":", "str", ",", "label", ":", "Optional", "[", "str", "]", "=", "None", ",", "overwrite...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
load_differential_gene_expression
Load and pre-process a differential gene expression data. :param path: The path to the CSV :param gene_symbol_column: The header of the gene symbol column in the data frame :param logfc_column: The header of the log-fold-change column in the data frame :param aggregator: A function that aggregates a li...
src/pybel_tools/integration/overlay.py
def load_differential_gene_expression(path: str, gene_symbol_column: str = 'Gene.symbol', logfc_column: str = 'logFC', aggregator: Optional[Callable[[List[float]], float]] = None, ...
def load_differential_gene_expression(path: str, gene_symbol_column: str = 'Gene.symbol', logfc_column: str = 'logFC', aggregator: Optional[Callable[[List[float]], float]] = None, ...
[ "Load", "and", "pre", "-", "process", "a", "differential", "gene", "expression", "data", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/integration/overlay.py#L89-L125
[ "def", "load_differential_gene_expression", "(", "path", ":", "str", ",", "gene_symbol_column", ":", "str", "=", "'Gene.symbol'", ",", "logfc_column", ":", "str", "=", "'logFC'", ",", "aggregator", ":", "Optional", "[", "Callable", "[", "[", "List", "[", "floa...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_merged_namespace_names
Loads many namespaces and combines their names. :param iter[str] locations: An iterable of URLs or file paths pointing to BEL namespaces. :param bool check_keywords: Should all the keywords be the same? Defaults to ``True`` :return: A dictionary of {names: labels} :rtype: dict[str, str] Example Us...
src/pybel_tools/definition_utils/summary_independent.py
def get_merged_namespace_names(locations, check_keywords=True): """Loads many namespaces and combines their names. :param iter[str] locations: An iterable of URLs or file paths pointing to BEL namespaces. :param bool check_keywords: Should all the keywords be the same? Defaults to ``True`` :return: A d...
def get_merged_namespace_names(locations, check_keywords=True): """Loads many namespaces and combines their names. :param iter[str] locations: An iterable of URLs or file paths pointing to BEL namespaces. :param bool check_keywords: Should all the keywords be the same? Defaults to ``True`` :return: A d...
[ "Loads", "many", "namespaces", "and", "combines", "their", "names", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/definition_utils/summary_independent.py#L22-L51
[ "def", "get_merged_namespace_names", "(", "locations", ",", "check_keywords", "=", "True", ")", ":", "resources", "=", "{", "location", ":", "get_bel_resource", "(", "location", ")", "for", "location", "in", "locations", "}", "if", "check_keywords", ":", "resour...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
merge_namespaces
Merges namespaces from multiple locations to one. :param iter input_locations: An iterable of URLs or file paths pointing to BEL namespaces. :param str output_path: The path to the file to write the merged namespace :param str namespace_name: The namespace name :param str namespace_keyword: Preferred B...
src/pybel_tools/definition_utils/summary_independent.py
def merge_namespaces(input_locations, output_path, namespace_name, namespace_keyword, namespace_domain, author_name, citation_name, namespace_description=None, namespace_species=None, namespace_version=None, namespace_query_url=None, namespace_created=None, author_contact=None,...
def merge_namespaces(input_locations, output_path, namespace_name, namespace_keyword, namespace_domain, author_name, citation_name, namespace_description=None, namespace_species=None, namespace_version=None, namespace_query_url=None, namespace_created=None, author_contact=None,...
[ "Merges", "namespaces", "from", "multiple", "locations", "to", "one", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/definition_utils/summary_independent.py#L54-L120
[ "def", "merge_namespaces", "(", "input_locations", ",", "output_path", ",", "namespace_name", ",", "namespace_keyword", ",", "namespace_domain", ",", "author_name", ",", "citation_name", ",", "namespace_description", "=", "None", ",", "namespace_species", "=", "None", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
run_rcr
Run the reverse causal reasoning algorithm on a graph. Steps: 1. Get all downstream controlled things into map (that have at least 4 downstream things) 2. calculate population of all things that are downstream controlled .. note:: Assumes all nodes have been pre-tagged with data :param pybel.BEL...
src/pybel_tools/analysis/rcr.py
def run_rcr(graph, tag='dgxp'): """Run the reverse causal reasoning algorithm on a graph. Steps: 1. Get all downstream controlled things into map (that have at least 4 downstream things) 2. calculate population of all things that are downstream controlled .. note:: Assumes all nodes have been pre...
def run_rcr(graph, tag='dgxp'): """Run the reverse causal reasoning algorithm on a graph. Steps: 1. Get all downstream controlled things into map (that have at least 4 downstream things) 2. calculate population of all things that are downstream controlled .. note:: Assumes all nodes have been pre...
[ "Run", "the", "reverse", "causal", "reasoning", "algorithm", "on", "a", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/analysis/rcr.py#L30-L124
[ "def", "run_rcr", "(", "graph", ",", "tag", "=", "'dgxp'", ")", ":", "# Step 1: Calculate the hypothesis subnetworks (just simple star graphs)", "hypotheses", "=", "defaultdict", "(", "set", ")", "increases", "=", "defaultdict", "(", "set", ")", "decreases", "=", "d...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
export_namespace
Exports all names and missing names from the given namespace to its own BEL Namespace files in the given directory. Could be useful during quick and dirty curation, where planned namespace building is not a priority. :param pybel.BELGraph graph: A BEL graph :param str namespace: The namespace to proce...
src/pybel_tools/definition_utils/summary_dependent.py
def export_namespace(graph, namespace, directory=None, cacheable=False): """Exports all names and missing names from the given namespace to its own BEL Namespace files in the given directory. Could be useful during quick and dirty curation, where planned namespace building is not a priority. :param py...
def export_namespace(graph, namespace, directory=None, cacheable=False): """Exports all names and missing names from the given namespace to its own BEL Namespace files in the given directory. Could be useful during quick and dirty curation, where planned namespace building is not a priority. :param py...
[ "Exports", "all", "names", "and", "missing", "names", "from", "the", "given", "namespace", "to", "its", "own", "BEL", "Namespace", "files", "in", "the", "given", "directory", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/definition_utils/summary_dependent.py#L19-L60
[ "def", "export_namespace", "(", "graph", ",", "namespace", ",", "directory", "=", "None", ",", "cacheable", "=", "False", ")", ":", "directory", "=", "os", ".", "getcwd", "(", ")", "if", "directory", "is", "None", "else", "directory", "path", "=", "os", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
export_namespaces
Thinly wraps :func:`export_namespace` for an iterable of namespaces. :param pybel.BELGraph graph: A BEL graph :param iter[str] namespaces: An iterable of strings for the namespaces to process :param str directory: The path to the directory where to output the namespaces. Defaults to the current working ...
src/pybel_tools/definition_utils/summary_dependent.py
def export_namespaces(graph, namespaces, directory=None, cacheable=False): """Thinly wraps :func:`export_namespace` for an iterable of namespaces. :param pybel.BELGraph graph: A BEL graph :param iter[str] namespaces: An iterable of strings for the namespaces to process :param str directory: The path to...
def export_namespaces(graph, namespaces, directory=None, cacheable=False): """Thinly wraps :func:`export_namespace` for an iterable of namespaces. :param pybel.BELGraph graph: A BEL graph :param iter[str] namespaces: An iterable of strings for the namespaces to process :param str directory: The path to...
[ "Thinly", "wraps", ":", "func", ":", "export_namespace", "for", "an", "iterable", "of", "namespaces", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/definition_utils/summary_dependent.py#L63-L76
[ "def", "export_namespaces", "(", "graph", ",", "namespaces", ",", "directory", "=", "None", ",", "cacheable", "=", "False", ")", ":", "directory", "=", "os", ".", "getcwd", "(", ")", "if", "directory", "is", "None", "else", "directory", "# avoid making multi...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
lint_file
Helps remove extraneous whitespace from the lines of a file :param file in_file: A readable file or file-like :param file out_file: A writable file or file-like
src/pybel_tools/document_utils/utils.py
def lint_file(in_file, out_file=None): """Helps remove extraneous whitespace from the lines of a file :param file in_file: A readable file or file-like :param file out_file: A writable file or file-like """ for line in in_file: print(line.strip(), file=out_file)
def lint_file(in_file, out_file=None): """Helps remove extraneous whitespace from the lines of a file :param file in_file: A readable file or file-like :param file out_file: A writable file or file-like """ for line in in_file: print(line.strip(), file=out_file)
[ "Helps", "remove", "extraneous", "whitespace", "from", "the", "lines", "of", "a", "file" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/utils.py#L14-L21
[ "def", "lint_file", "(", "in_file", ",", "out_file", "=", "None", ")", ":", "for", "line", "in", "in_file", ":", "print", "(", "line", ".", "strip", "(", ")", ",", "file", "=", "out_file", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
lint_directory
Adds a linted version of each document in the source directory to the target directory :param str source: Path to directory to lint :param str target: Path to directory to output
src/pybel_tools/document_utils/utils.py
def lint_directory(source, target): """Adds a linted version of each document in the source directory to the target directory :param str source: Path to directory to lint :param str target: Path to directory to output """ for path in os.listdir(source): if not path.endswith('.bel'): ...
def lint_directory(source, target): """Adds a linted version of each document in the source directory to the target directory :param str source: Path to directory to lint :param str target: Path to directory to output """ for path in os.listdir(source): if not path.endswith('.bel'): ...
[ "Adds", "a", "linted", "version", "of", "each", "document", "in", "the", "source", "directory", "to", "the", "target", "directory" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/utils.py#L24-L36
[ "def", "lint_directory", "(", "source", ",", "target", ")", ":", "for", "path", "in", "os", ".", "listdir", "(", "source", ")", ":", "if", "not", "path", ".", "endswith", "(", "'.bel'", ")", ":", "continue", "log", ".", "info", "(", "'linting: %s'", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
make_pubmed_abstract_group
Build a skeleton for the citations' statements. :param pmids: A list of PubMed identifiers :return: An iterator over the lines of the citation section
src/pybel_tools/document_utils/document_utils.py
def make_pubmed_abstract_group(pmids: Iterable[Union[str, int]]) -> Iterable[str]: """Build a skeleton for the citations' statements. :param pmids: A list of PubMed identifiers :return: An iterator over the lines of the citation section """ for pmid in set(pmids): yield '' res ...
def make_pubmed_abstract_group(pmids: Iterable[Union[str, int]]) -> Iterable[str]: """Build a skeleton for the citations' statements. :param pmids: A list of PubMed identifiers :return: An iterator over the lines of the citation section """ for pmid in set(pmids): yield '' res ...
[ "Build", "a", "skeleton", "for", "the", "citations", "statements", ".", ":", "param", "pmids", ":", "A", "list", "of", "PubMed", "identifiers", ":", "return", ":", "An", "iterator", "over", "the", "lines", "of", "the", "citation", "section" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/document_utils.py#L21-L39
[ "def", "make_pubmed_abstract_group", "(", "pmids", ":", "Iterable", "[", "Union", "[", "str", ",", "int", "]", "]", ")", "->", "Iterable", "[", "str", "]", ":", "for", "pmid", "in", "set", "(", "pmids", ")", ":", "yield", "''", "res", "=", "requests"...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_entrez_gene_data
Get gene info from Entrez.
src/pybel_tools/document_utils/document_utils.py
def get_entrez_gene_data(entrez_ids: Iterable[Union[str, int]]): """Get gene info from Entrez.""" url = PUBMED_GENE_QUERY_URL.format(','.join(str(x).strip() for x in entrez_ids)) response = requests.get(url) tree = ElementTree.fromstring(response.content) return { element.attrib['uid']: { ...
def get_entrez_gene_data(entrez_ids: Iterable[Union[str, int]]): """Get gene info from Entrez.""" url = PUBMED_GENE_QUERY_URL.format(','.join(str(x).strip() for x in entrez_ids)) response = requests.get(url) tree = ElementTree.fromstring(response.content) return { element.attrib['uid']: { ...
[ "Get", "gene", "info", "from", "Entrez", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/document_utils.py#L52-L64
[ "def", "get_entrez_gene_data", "(", "entrez_ids", ":", "Iterable", "[", "Union", "[", "str", ",", "int", "]", "]", ")", ":", "url", "=", "PUBMED_GENE_QUERY_URL", ".", "format", "(", "','", ".", "join", "(", "str", "(", "x", ")", ".", "strip", "(", ")...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
make_pubmed_gene_group
Builds a skeleton for gene summaries :param entrez_ids: A list of Entrez Gene identifiers to query the PubMed service :return: An iterator over statement lines for NCBI Entrez Gene summaries
src/pybel_tools/document_utils/document_utils.py
def make_pubmed_gene_group(entrez_ids: Iterable[Union[str, int]]) -> Iterable[str]: """Builds a skeleton for gene summaries :param entrez_ids: A list of Entrez Gene identifiers to query the PubMed service :return: An iterator over statement lines for NCBI Entrez Gene summaries """ url = PUBMED_GENE...
def make_pubmed_gene_group(entrez_ids: Iterable[Union[str, int]]) -> Iterable[str]: """Builds a skeleton for gene summaries :param entrez_ids: A list of Entrez Gene identifiers to query the PubMed service :return: An iterator over statement lines for NCBI Entrez Gene summaries """ url = PUBMED_GENE...
[ "Builds", "a", "skeleton", "for", "gene", "summaries" ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/document_utils.py#L67-L81
[ "def", "make_pubmed_gene_group", "(", "entrez_ids", ":", "Iterable", "[", "Union", "[", "str", ",", "int", "]", "]", ")", "->", "Iterable", "[", "str", "]", ":", "url", "=", "PUBMED_GENE_QUERY_URL", ".", "format", "(", "','", ".", "join", "(", "str", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
write_boilerplate
Write a boilerplate BEL document, with standard document metadata, definitions. :param name: The unique name for this BEL document :param contact: The email address of the maintainer :param description: A description of the contents of this document :param authors: The authors of this document :par...
src/pybel_tools/document_utils/document_utils.py
def write_boilerplate(name: str, version: Optional[str] = None, description: Optional[str] = None, authors: Optional[str] = None, contact: Optional[str] = None, copyright: Optional[str] = None, ...
def write_boilerplate(name: str, version: Optional[str] = None, description: Optional[str] = None, authors: Optional[str] = None, contact: Optional[str] = None, copyright: Optional[str] = None, ...
[ "Write", "a", "boilerplate", "BEL", "document", "with", "standard", "document", "metadata", "definitions", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/document_utils/document_utils.py#L84-L145
[ "def", "write_boilerplate", "(", "name", ":", "str", ",", "version", ":", "Optional", "[", "str", "]", "=", "None", ",", "description", ":", "Optional", "[", "str", "]", "=", "None", ",", "authors", ":", "Optional", "[", "str", "]", "=", "None", ",",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_subgraph_by_node_filter
Induce a sub-graph on the nodes that pass the given predicate(s).
src/pybel_tools/selection/induce_subgraph.py
def get_subgraph_by_node_filter(graph: BELGraph, node_predicates: NodePredicates) -> BELGraph: """Induce a sub-graph on the nodes that pass the given predicate(s).""" return get_subgraph_by_induction(graph, filter_nodes(graph, node_predicates))
def get_subgraph_by_node_filter(graph: BELGraph, node_predicates: NodePredicates) -> BELGraph: """Induce a sub-graph on the nodes that pass the given predicate(s).""" return get_subgraph_by_induction(graph, filter_nodes(graph, node_predicates))
[ "Induce", "a", "sub", "-", "graph", "on", "the", "nodes", "that", "pass", "the", "given", "predicate", "(", "s", ")", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/induce_subgraph.py#L23-L25
[ "def", "get_subgraph_by_node_filter", "(", "graph", ":", "BELGraph", ",", "node_predicates", ":", "NodePredicates", ")", "->", "BELGraph", ":", "return", "get_subgraph_by_induction", "(", "graph", ",", "filter_nodes", "(", "graph", ",", "node_predicates", ")", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_subgraph_by_node_search
Get a sub-graph induced over all nodes matching the query string. :param graph: A BEL Graph :param query: A query string or iterable of query strings for node names Thinly wraps :func:`search_node_names` and :func:`get_subgraph_by_induction`.
src/pybel_tools/selection/induce_subgraph.py
def get_subgraph_by_node_search(graph: BELGraph, query: Strings) -> BELGraph: """Get a sub-graph induced over all nodes matching the query string. :param graph: A BEL Graph :param query: A query string or iterable of query strings for node names Thinly wraps :func:`search_node_names` and :func:`get_su...
def get_subgraph_by_node_search(graph: BELGraph, query: Strings) -> BELGraph: """Get a sub-graph induced over all nodes matching the query string. :param graph: A BEL Graph :param query: A query string or iterable of query strings for node names Thinly wraps :func:`search_node_names` and :func:`get_su...
[ "Get", "a", "sub", "-", "graph", "induced", "over", "all", "nodes", "matching", "the", "query", "string", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/induce_subgraph.py#L35-L44
[ "def", "get_subgraph_by_node_search", "(", "graph", ":", "BELGraph", ",", "query", ":", "Strings", ")", "->", "BELGraph", ":", "nodes", "=", "search_node_names", "(", "graph", ",", "query", ")", "return", "get_subgraph_by_induction", "(", "graph", ",", "nodes", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
get_largest_component
Get the giant component of a graph.
src/pybel_tools/selection/induce_subgraph.py
def get_largest_component(graph: BELGraph) -> BELGraph: """Get the giant component of a graph.""" biggest_component_nodes = max(nx.weakly_connected_components(graph), key=len) return subgraph(graph, biggest_component_nodes)
def get_largest_component(graph: BELGraph) -> BELGraph: """Get the giant component of a graph.""" biggest_component_nodes = max(nx.weakly_connected_components(graph), key=len) return subgraph(graph, biggest_component_nodes)
[ "Get", "the", "giant", "component", "of", "a", "graph", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/induce_subgraph.py#L48-L51
[ "def", "get_largest_component", "(", "graph", ":", "BELGraph", ")", "->", "BELGraph", ":", "biggest_component_nodes", "=", "max", "(", "nx", ".", "weakly_connected_components", "(", "graph", ")", ",", "key", "=", "len", ")", "return", "subgraph", "(", "graph",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
random_by_nodes
Get a random graph by inducing over a percentage of the original nodes. :param graph: A BEL graph :param percentage: The percentage of edges to keep
src/pybel_tools/mutation/random.py
def random_by_nodes(graph: BELGraph, percentage: Optional[float] = None) -> BELGraph: """Get a random graph by inducing over a percentage of the original nodes. :param graph: A BEL graph :param percentage: The percentage of edges to keep """ percentage = percentage or 0.9 assert 0 < percentage...
def random_by_nodes(graph: BELGraph, percentage: Optional[float] = None) -> BELGraph: """Get a random graph by inducing over a percentage of the original nodes. :param graph: A BEL graph :param percentage: The percentage of edges to keep """ percentage = percentage or 0.9 assert 0 < percentage...
[ "Get", "a", "random", "graph", "by", "inducing", "over", "a", "percentage", "of", "the", "original", "nodes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/random.py#L20-L39
[ "def", "random_by_nodes", "(", "graph", ":", "BELGraph", ",", "percentage", ":", "Optional", "[", "float", "]", "=", "None", ")", "->", "BELGraph", ":", "percentage", "=", "percentage", "or", "0.9", "assert", "0", "<", "percentage", "<=", "1", "nodes", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
random_by_edges
Get a random graph by keeping a certain percentage of original edges. :param graph: A BEL graph :param percentage: What percentage of eges to take
src/pybel_tools/mutation/random.py
def random_by_edges(graph: BELGraph, percentage: Optional[float] = None) -> BELGraph: """Get a random graph by keeping a certain percentage of original edges. :param graph: A BEL graph :param percentage: What percentage of eges to take """ percentage = percentage or 0.9 assert 0 < percentage <=...
def random_by_edges(graph: BELGraph, percentage: Optional[float] = None) -> BELGraph: """Get a random graph by keeping a certain percentage of original edges. :param graph: A BEL graph :param percentage: What percentage of eges to take """ percentage = percentage or 0.9 assert 0 < percentage <=...
[ "Get", "a", "random", "graph", "by", "keeping", "a", "certain", "percentage", "of", "original", "edges", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/random.py#L43-L64
[ "def", "random_by_edges", "(", "graph", ":", "BELGraph", ",", "percentage", ":", "Optional", "[", "float", "]", "=", "None", ")", "->", "BELGraph", ":", "percentage", "=", "percentage", "or", "0.9", "assert", "0", "<", "percentage", "<=", "1", "edges", "...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
shuffle_node_data
Shuffle the node's data. Useful for permutation testing. :param graph: A BEL graph :param key: The node data dictionary key :param percentage: What percentage of possible swaps to make
src/pybel_tools/mutation/random.py
def shuffle_node_data(graph: BELGraph, key: str, percentage: Optional[float] = None) -> BELGraph: """Shuffle the node's data. Useful for permutation testing. :param graph: A BEL graph :param key: The node data dictionary key :param percentage: What percentage of possible swaps to make """ ...
def shuffle_node_data(graph: BELGraph, key: str, percentage: Optional[float] = None) -> BELGraph: """Shuffle the node's data. Useful for permutation testing. :param graph: A BEL graph :param key: The node data dictionary key :param percentage: What percentage of possible swaps to make """ ...
[ "Shuffle", "the", "node", "s", "data", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/random.py#L68-L89
[ "def", "shuffle_node_data", "(", "graph", ":", "BELGraph", ",", "key", ":", "str", ",", "percentage", ":", "Optional", "[", "float", "]", "=", "None", ")", "->", "BELGraph", ":", "percentage", "=", "percentage", "or", "0.3", "assert", "0", "<", "percenta...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
shuffle_relations
Shuffle the relations. Useful for permutation testing. :param graph: A BEL graph :param percentage: What percentage of possible swaps to make
src/pybel_tools/mutation/random.py
def shuffle_relations(graph: BELGraph, percentage: Optional[str] = None) -> BELGraph: """Shuffle the relations. Useful for permutation testing. :param graph: A BEL graph :param percentage: What percentage of possible swaps to make """ percentage = percentage or 0.3 assert 0 < percentage <=...
def shuffle_relations(graph: BELGraph, percentage: Optional[str] = None) -> BELGraph: """Shuffle the relations. Useful for permutation testing. :param graph: A BEL graph :param percentage: What percentage of possible swaps to make """ percentage = percentage or 0.3 assert 0 < percentage <=...
[ "Shuffle", "the", "relations", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/random.py#L93-L115
[ "def", "shuffle_relations", "(", "graph", ":", "BELGraph", ",", "percentage", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "BELGraph", ":", "percentage", "=", "percentage", "or", "0.3", "assert", "0", "<", "percentage", "<=", "1", "n", "=", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
is_edge_consistent
Check if all edges between two nodes have the same relation. :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :return: If all edges from the source to target node have the same relation :rtype: bool
src/pybel_tools/selection/rewiring.py
def is_edge_consistent(graph, u, v): """Check if all edges between two nodes have the same relation. :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :return: If all edges from the source to target node have the same relation :rtyp...
def is_edge_consistent(graph, u, v): """Check if all edges between two nodes have the same relation. :param pybel.BELGraph graph: A BEL Graph :param tuple u: The source BEL node :param tuple v: The target BEL node :return: If all edges from the source to target node have the same relation :rtyp...
[ "Check", "if", "all", "edges", "between", "two", "nodes", "have", "the", "same", "relation", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/rewiring.py#L14-L26
[ "def", "is_edge_consistent", "(", "graph", ",", "u", ",", "v", ")", ":", "if", "not", "graph", ".", "has_edge", "(", "u", ",", "v", ")", ":", "raise", "ValueError", "(", "'{} does not contain an edge ({}, {})'", ".", "format", "(", "graph", ",", "u", ","...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
all_edges_consistent
Return if all edges are consistent in a graph. Wraps :func:`pybel_tools.utils.is_edge_consistent`. :param pybel.BELGraph graph: A BEL graph :return: Are all edges consistent :rtype: bool
src/pybel_tools/selection/rewiring.py
def all_edges_consistent(graph): """Return if all edges are consistent in a graph. Wraps :func:`pybel_tools.utils.is_edge_consistent`. :param pybel.BELGraph graph: A BEL graph :return: Are all edges consistent :rtype: bool """ return all( is_edge_consistent(graph, u, v) for u, v...
def all_edges_consistent(graph): """Return if all edges are consistent in a graph. Wraps :func:`pybel_tools.utils.is_edge_consistent`. :param pybel.BELGraph graph: A BEL graph :return: Are all edges consistent :rtype: bool """ return all( is_edge_consistent(graph, u, v) for u, v...
[ "Return", "if", "all", "edges", "are", "consistent", "in", "a", "graph", ".", "Wraps", ":", "func", ":", "pybel_tools", ".", "utils", ".", "is_edge_consistent", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/rewiring.py#L29-L39
[ "def", "all_edges_consistent", "(", "graph", ")", ":", "return", "all", "(", "is_edge_consistent", "(", "graph", ",", "u", ",", "v", ")", "for", "u", ",", "v", "in", "graph", ".", "edges", "(", ")", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
rewire_targets
Rewire a graph's edges' target nodes. - For BEL graphs, assumes edge consistency (all edges between two given nodes are have the same relation) - Doesn't make self-edges :param pybel.BELGraph graph: A BEL graph :param float rewiring_probability: The probability of rewiring (between 0 and 1) :retur...
src/pybel_tools/selection/rewiring.py
def rewire_targets(graph, rewiring_probability): """Rewire a graph's edges' target nodes. - For BEL graphs, assumes edge consistency (all edges between two given nodes are have the same relation) - Doesn't make self-edges :param pybel.BELGraph graph: A BEL graph :param float rewiring_probability: ...
def rewire_targets(graph, rewiring_probability): """Rewire a graph's edges' target nodes. - For BEL graphs, assumes edge consistency (all edges between two given nodes are have the same relation) - Doesn't make self-edges :param pybel.BELGraph graph: A BEL graph :param float rewiring_probability: ...
[ "Rewire", "a", "graph", "s", "edges", "target", "nodes", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/selection/rewiring.py#L43-L71
[ "def", "rewire_targets", "(", "graph", ",", "rewiring_probability", ")", ":", "if", "not", "all_edges_consistent", "(", "graph", ")", ":", "raise", "ValueError", "(", "'{} is not consistent'", ".", "format", "(", "graph", ")", ")", "result", "=", "graph", ".",...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
self_edge_filter
Check if the source and target nodes are the same.
src/pybel_tools/biogrammar/double_edges.py
def self_edge_filter(_: BELGraph, source: BaseEntity, target: BaseEntity, __: str) -> bool: """Check if the source and target nodes are the same.""" return source == target
def self_edge_filter(_: BELGraph, source: BaseEntity, target: BaseEntity, __: str) -> bool: """Check if the source and target nodes are the same.""" return source == target
[ "Check", "if", "the", "source", "and", "target", "nodes", "are", "the", "same", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/biogrammar/double_edges.py#L15-L17
[ "def", "self_edge_filter", "(", "_", ":", "BELGraph", ",", "source", ":", "BaseEntity", ",", "target", ":", "BaseEntity", ",", "__", ":", "str", ")", "->", "bool", ":", "return", "source", "==", "target" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
has_protein_modification_increases_activity
Check if pmod of source causes activity of target.
src/pybel_tools/biogrammar/double_edges.py
def has_protein_modification_increases_activity(graph: BELGraph, source: BaseEntity, target: BaseEntity, key: str, ) -> bool: ...
def has_protein_modification_increases_activity(graph: BELGraph, source: BaseEntity, target: BaseEntity, key: str, ) -> bool: ...
[ "Check", "if", "pmod", "of", "source", "causes", "activity", "of", "target", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/biogrammar/double_edges.py#L20-L27
[ "def", "has_protein_modification_increases_activity", "(", "graph", ":", "BELGraph", ",", "source", ":", "BaseEntity", ",", "target", ":", "BaseEntity", ",", "key", ":", "str", ",", ")", "->", "bool", ":", "edge_data", "=", "graph", "[", "source", "]", "[", ...
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
has_degradation_increases_activity
Check if the degradation of source causes activity of target.
src/pybel_tools/biogrammar/double_edges.py
def has_degradation_increases_activity(data: Dict) -> bool: """Check if the degradation of source causes activity of target.""" return part_has_modifier(data, SUBJECT, DEGRADATION) and part_has_modifier(data, OBJECT, ACTIVITY)
def has_degradation_increases_activity(data: Dict) -> bool: """Check if the degradation of source causes activity of target.""" return part_has_modifier(data, SUBJECT, DEGRADATION) and part_has_modifier(data, OBJECT, ACTIVITY)
[ "Check", "if", "the", "degradation", "of", "source", "causes", "activity", "of", "target", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/biogrammar/double_edges.py#L31-L33
[ "def", "has_degradation_increases_activity", "(", "data", ":", "Dict", ")", "->", "bool", ":", "return", "part_has_modifier", "(", "data", ",", "SUBJECT", ",", "DEGRADATION", ")", "and", "part_has_modifier", "(", "data", ",", "OBJECT", ",", "ACTIVITY", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c
valid
has_translocation_increases_activity
Check if the translocation of source causes activity of target.
src/pybel_tools/biogrammar/double_edges.py
def has_translocation_increases_activity(data: Dict) -> bool: """Check if the translocation of source causes activity of target.""" return part_has_modifier(data, SUBJECT, TRANSLOCATION) and part_has_modifier(data, OBJECT, ACTIVITY)
def has_translocation_increases_activity(data: Dict) -> bool: """Check if the translocation of source causes activity of target.""" return part_has_modifier(data, SUBJECT, TRANSLOCATION) and part_has_modifier(data, OBJECT, ACTIVITY)
[ "Check", "if", "the", "translocation", "of", "source", "causes", "activity", "of", "target", "." ]
pybel/pybel-tools
python
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/biogrammar/double_edges.py#L37-L39
[ "def", "has_translocation_increases_activity", "(", "data", ":", "Dict", ")", "->", "bool", ":", "return", "part_has_modifier", "(", "data", ",", "SUBJECT", ",", "TRANSLOCATION", ")", "and", "part_has_modifier", "(", "data", ",", "OBJECT", ",", "ACTIVITY", ")" ]
3491adea0ac4ee60f57275ef72f9b73da6dbfe0c