hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | periphery | <not_specific> | def periphery(self, **kwargs):
"""Expand around the periphery of the graph w.r.t. its parent graph."""
from pybel_tools.mutation.expansion import expand_periphery
cp = self.graph.copy()
expand_periphery(universe=self.parent, graph=cp, **kwargs)
return cp | Expand around the periphery of the graph w.r.t. its parent graph. | Expand around the periphery of the graph w.r.t. its parent graph. | [
"Expand",
"around",
"the",
"periphery",
"of",
"the",
"graph",
"w",
".",
"r",
".",
"t",
".",
"its",
"parent",
"graph",
"."
] | def periphery(self, **kwargs):
from pybel_tools.mutation.expansion import expand_periphery
cp = self.graph.copy()
expand_periphery(universe=self.parent, graph=cp, **kwargs)
return cp | [
"def",
"periphery",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"from",
"pybel_tools",
".",
"mutation",
".",
"expansion",
"import",
"expand_periphery",
"cp",
"=",
"self",
".",
"graph",
".",
"copy",
"(",
")",
"expand_periphery",
"(",
"universe",
"=",
"self"... | Expand around the periphery of the graph w.r.t. | [
"Expand",
"around",
"the",
"periphery",
"of",
"the",
"graph",
"w",
".",
"r",
".",
"t",
"."
] | [
"\"\"\"Expand around the periphery of the graph w.r.t. its parent graph.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | internal | <not_specific> | def internal(self, **kwargs):
"""Expand missing edges between nodes in the graph w.r.t. its parent graph."""
from pybel_tools.mutation.expansion import expand_internal
cp = self.graph.copy()
expand_internal(universe=self.parent, graph=cp, **kwargs)
return cp | Expand missing edges between nodes in the graph w.r.t. its parent graph. | Expand missing edges between nodes in the graph w.r.t. its parent graph. | [
"Expand",
"missing",
"edges",
"between",
"nodes",
"in",
"the",
"graph",
"w",
".",
"r",
".",
"t",
".",
"its",
"parent",
"graph",
"."
] | def internal(self, **kwargs):
from pybel_tools.mutation.expansion import expand_internal
cp = self.graph.copy()
expand_internal(universe=self.parent, graph=cp, **kwargs)
return cp | [
"def",
"internal",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"from",
"pybel_tools",
".",
"mutation",
".",
"expansion",
"import",
"expand_internal",
"cp",
"=",
"self",
".",
"graph",
".",
"copy",
"(",
")",
"expand_internal",
"(",
"universe",
"=",
"self",
... | Expand missing edges between nodes in the graph w.r.t. | [
"Expand",
"missing",
"edges",
"between",
"nodes",
"in",
"the",
"graph",
"w",
".",
"r",
".",
"t",
"."
] | [
"\"\"\"Expand missing edges between nodes in the graph w.r.t. its parent graph.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e6ac644f046a5a49da5f40d989b3dd0a8d2716d | rpatil524/pybel | src/pybel/struct/summary/edge_summary.py | [
"MIT"
] | Python | iter_annotation_value_pairs | Iterable[Tuple[str, Entity]] | def iter_annotation_value_pairs(graph: BELGraph) -> Iterable[Tuple[str, Entity]]:
"""Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph.
:param graph: A BEL graph
"""
return (
(key, entity)
for _, _, data in graph.edges(data=True)
for key,... | Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph.
:param graph: A BEL graph
| Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph. | [
"Iterate",
"over",
"the",
"key",
"/",
"value",
"pairs",
"with",
"duplicates",
"for",
"each",
"annotation",
"used",
"in",
"a",
"BEL",
"graph",
"."
] | def iter_annotation_value_pairs(graph: BELGraph) -> Iterable[Tuple[str, Entity]]:
return (
(key, entity)
for _, _, data in graph.edges(data=True)
for key, entities in data.get(ANNOTATIONS, {}).items()
for entity in entities
) | [
"def",
"iter_annotation_value_pairs",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"Entity",
"]",
"]",
":",
"return",
"(",
"(",
"key",
",",
"entity",
")",
"for",
"_",
",",
"_",
",",
"data",
"in",
"graph",
".",
... | Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph. | [
"Iterate",
"over",
"the",
"key",
"/",
"value",
"pairs",
"with",
"duplicates",
"for",
"each",
"annotation",
"used",
"in",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Iterate over the key/value pairs, with duplicates, for each annotation used in a BEL graph.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others":... |
1e6ac644f046a5a49da5f40d989b3dd0a8d2716d | rpatil524/pybel | src/pybel/struct/summary/edge_summary.py | [
"MIT"
] | Python | iter_annotation_values | Iterable[Entity] | def iter_annotation_values(graph: BELGraph, annotation: str) -> Iterable[Entity]:
"""Iterate over all of the values for an annotation used in the graph.
:param graph: A BEL graph
:param annotation: The annotation to grab
"""
return (
entity
for _, _, data in graph.edges(data=True)
... | Iterate over all of the values for an annotation used in the graph.
:param graph: A BEL graph
:param annotation: The annotation to grab
| Iterate over all of the values for an annotation used in the graph. | [
"Iterate",
"over",
"all",
"of",
"the",
"values",
"for",
"an",
"annotation",
"used",
"in",
"the",
"graph",
"."
] | def iter_annotation_values(graph: BELGraph, annotation: str) -> Iterable[Entity]:
return (
entity
for _, _, data in graph.edges(data=True)
if edge_has_annotation(data, annotation)
for entity in data[ANNOTATIONS][annotation]
) | [
"def",
"iter_annotation_values",
"(",
"graph",
":",
"BELGraph",
",",
"annotation",
":",
"str",
")",
"->",
"Iterable",
"[",
"Entity",
"]",
":",
"return",
"(",
"entity",
"for",
"_",
",",
"_",
",",
"data",
"in",
"graph",
".",
"edges",
"(",
"data",
"=",
... | Iterate over all of the values for an annotation used in the graph. | [
"Iterate",
"over",
"all",
"of",
"the",
"values",
"for",
"an",
"annotation",
"used",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Iterate over all of the values for an annotation used in the graph.\n\n :param graph: A BEL graph\n :param annotation: The annotation to grab\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "annotation",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "annotation",... |
1e6ac644f046a5a49da5f40d989b3dd0a8d2716d | rpatil524/pybel | src/pybel/struct/summary/edge_summary.py | [
"MIT"
] | Python | count_relations | Counter | def count_relations(graph: BELGraph) -> Counter:
"""Return a histogram over all relationships in a graph.
:param graph: A BEL graph
:return: A Counter from {relation type: frequency}
"""
return Counter(
data[RELATION]
for _, _, data in graph.edges(data=True)
) | Return a histogram over all relationships in a graph.
:param graph: A BEL graph
:return: A Counter from {relation type: frequency}
| Return a histogram over all relationships in a graph. | [
"Return",
"a",
"histogram",
"over",
"all",
"relationships",
"in",
"a",
"graph",
"."
] | def count_relations(graph: BELGraph) -> Counter:
return Counter(
data[RELATION]
for _, _, data in graph.edges(data=True)
) | [
"def",
"count_relations",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Counter",
":",
"return",
"Counter",
"(",
"data",
"[",
"RELATION",
"]",
"for",
"_",
",",
"_",
",",
"data",
"in",
"graph",
".",
"edges",
"(",
"data",
"=",
"True",
")",
")"
] | Return a histogram over all relationships in a graph. | [
"Return",
"a",
"histogram",
"over",
"all",
"relationships",
"in",
"a",
"graph",
"."
] | [
"\"\"\"Return a histogram over all relationships in a graph.\n\n :param graph: A BEL graph\n :return: A Counter from {relation type: frequency}\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [
{
"docstring": "A Counter from {relation type: frequency}",
"docstring_tokens": [
"A",
"Counter",
"from",
"{",
"relation",
"type",
":",
"frequency",
"}"
],
"type": null
}
],
"raises": [],
"para... |
1e6ac644f046a5a49da5f40d989b3dd0a8d2716d | rpatil524/pybel | src/pybel/struct/summary/edge_summary.py | [
"MIT"
] | Python | count_annotations | Counter | def count_annotations(graph: BELGraph) -> Counter:
"""Count how many times each annotation is used in the graph.
:param graph: A BEL graph
:return: A Counter from {annotation key: frequency}
"""
return Counter(_annotation_iter_helper(graph)) | Count how many times each annotation is used in the graph.
:param graph: A BEL graph
:return: A Counter from {annotation key: frequency}
| Count how many times each annotation is used in the graph. | [
"Count",
"how",
"many",
"times",
"each",
"annotation",
"is",
"used",
"in",
"the",
"graph",
"."
] | def count_annotations(graph: BELGraph) -> Counter:
return Counter(_annotation_iter_helper(graph)) | [
"def",
"count_annotations",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Counter",
":",
"return",
"Counter",
"(",
"_annotation_iter_helper",
"(",
"graph",
")",
")"
] | Count how many times each annotation is used in the graph. | [
"Count",
"how",
"many",
"times",
"each",
"annotation",
"is",
"used",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Count how many times each annotation is used in the graph.\n\n :param graph: A BEL graph\n :return: A Counter from {annotation key: frequency}\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [
{
"docstring": "A Counter from {annotation key: frequency}",
"docstring_tokens": [
"A",
"Counter",
"from",
"{",
"annotation",
"key",
":",
"frequency",
"}"
],
"type": null
}
],
"raises": [],
"pa... |
1e6ac644f046a5a49da5f40d989b3dd0a8d2716d | rpatil524/pybel | src/pybel/struct/summary/edge_summary.py | [
"MIT"
] | Python | _annotation_iter_helper | Iterable[str] | def _annotation_iter_helper(graph: BELGraph) -> Iterable[str]:
"""Iterate over the annotation keys.
:param graph: A BEL graph
"""
return (
key
for _, _, data in graph.edges(data=True)
if ANNOTATIONS in data
for key in data[ANNOTATIONS]
) | Iterate over the annotation keys.
:param graph: A BEL graph
| Iterate over the annotation keys. | [
"Iterate",
"over",
"the",
"annotation",
"keys",
"."
] | def _annotation_iter_helper(graph: BELGraph) -> Iterable[str]:
return (
key
for _, _, data in graph.edges(data=True)
if ANNOTATIONS in data
for key in data[ANNOTATIONS]
) | [
"def",
"_annotation_iter_helper",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"return",
"(",
"key",
"for",
"_",
",",
"_",
",",
"data",
"in",
"graph",
".",
"edges",
"(",
"data",
"=",
"True",
")",
"if",
"ANNOTATIONS",
"i... | Iterate over the annotation keys. | [
"Iterate",
"over",
"the",
"annotation",
"keys",
"."
] | [
"\"\"\"Iterate over the annotation keys.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others":... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | clear | null | def clear(self):
"""Clear the graph and all control parser data (current citation, annotations, and statement group)."""
if self.graph is not None:
self.graph.clear()
self.control_parser.clear() | Clear the graph and all control parser data (current citation, annotations, and statement group). | Clear the graph and all control parser data (current citation, annotations, and statement group). | [
"Clear",
"the",
"graph",
"and",
"all",
"control",
"parser",
"data",
"(",
"current",
"citation",
"annotations",
"and",
"statement",
"group",
")",
"."
] | def clear(self):
if self.graph is not None:
self.graph.clear()
self.control_parser.clear() | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"self",
".",
"graph",
"is",
"not",
"None",
":",
"self",
".",
"graph",
".",
"clear",
"(",
")",
"self",
".",
"control_parser",
".",
"clear",
"(",
")"
] | Clear the graph and all control parser data (current citation, annotations, and statement group). | [
"Clear",
"the",
"graph",
"and",
"all",
"control",
"parser",
"data",
"(",
"current",
"citation",
"annotations",
"and",
"statement",
"group",
")",
"."
] | [
"\"\"\"Clear the graph and all control parser data (current citation, annotations, and statement group).\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | check_function_semantics | ParseResults | def check_function_semantics(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Raise an exception if the function used on the tokens is wrong.
:raises: InvalidFunctionSemantic
"""
concept = tokens.get(CONCEPT)
if not self._namespace_dict or concept is Non... | Raise an exception if the function used on the tokens is wrong.
:raises: InvalidFunctionSemantic
| Raise an exception if the function used on the tokens is wrong. | [
"Raise",
"an",
"exception",
"if",
"the",
"function",
"used",
"on",
"the",
"tokens",
"is",
"wrong",
"."
] | def check_function_semantics(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
concept = tokens.get(CONCEPT)
if not self._namespace_dict or concept is None:
return tokens
namespace, name = concept[NAMESPACE], concept[NAME]
if namespace in self.concept_par... | [
"def",
"check_function_semantics",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"concept",
"=",
"tokens",
".",
"get",
"(",
"CONCEPT",
")",
"if",
"not",
"self",
".",... | Raise an exception if the function used on the tokens is wrong. | [
"Raise",
"an",
"exception",
"if",
"the",
"function",
"used",
"on",
"the",
"tokens",
"is",
"wrong",
"."
] | [
"\"\"\"Raise an exception if the function used on the tokens is wrong.\n\n :raises: InvalidFunctionSemantic\n \"\"\"",
"# Don't check dirty names in lenient mode"
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | _add_qualified_edge_helper | str | def _add_qualified_edge_helper(
self,
*,
source,
source_modifier,
relation,
target,
target_modifier,
annotations,
) -> str:
"""Add a qualified edge from the internal aspects of the parser."""
m = {
BINDS: self.graph.add_bind... | Add a qualified edge from the internal aspects of the parser. | Add a qualified edge from the internal aspects of the parser. | [
"Add",
"a",
"qualified",
"edge",
"from",
"the",
"internal",
"aspects",
"of",
"the",
"parser",
"."
] | def _add_qualified_edge_helper(
self,
*,
source,
source_modifier,
relation,
target,
target_modifier,
annotations,
) -> str:
m = {
BINDS: self.graph.add_binds,
}
adder = m.get(relation)
d = dict(
e... | [
"def",
"_add_qualified_edge_helper",
"(",
"self",
",",
"*",
",",
"source",
",",
"source_modifier",
",",
"relation",
",",
"target",
",",
"target_modifier",
",",
"annotations",
",",
")",
"->",
"str",
":",
"m",
"=",
"{",
"BINDS",
":",
"self",
".",
"graph",
... | Add a qualified edge from the internal aspects of the parser. | [
"Add",
"a",
"qualified",
"edge",
"from",
"the",
"internal",
"aspects",
"of",
"the",
"parser",
"."
] | [
"\"\"\"Add a qualified edge from the internal aspects of the parser.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": null
},
{
"param": "source_modifier",
"type": null
},
{
"param": "relation",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "target_modifier",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens":... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | _add_qualified_edge | str | def _add_qualified_edge(self, *, source, source_modifier, relation, target, target_modifier) -> str:
"""Add an edge, then adds the opposite direction edge if it should."""
d = dict(
relation=relation,
annotations=self.control_parser.annotations,
)
if relation in T... | Add an edge, then adds the opposite direction edge if it should. | Add an edge, then adds the opposite direction edge if it should. | [
"Add",
"an",
"edge",
"then",
"adds",
"the",
"opposite",
"direction",
"edge",
"if",
"it",
"should",
"."
] | def _add_qualified_edge(self, *, source, source_modifier, relation, target, target_modifier) -> str:
d = dict(
relation=relation,
annotations=self.control_parser.annotations,
)
if relation in TWO_WAY_RELATIONS:
self._add_qualified_edge_helper(
... | [
"def",
"_add_qualified_edge",
"(",
"self",
",",
"*",
",",
"source",
",",
"source_modifier",
",",
"relation",
",",
"target",
",",
"target_modifier",
")",
"->",
"str",
":",
"d",
"=",
"dict",
"(",
"relation",
"=",
"relation",
",",
"annotations",
"=",
"self",
... | Add an edge, then adds the opposite direction edge if it should. | [
"Add",
"an",
"edge",
"then",
"adds",
"the",
"opposite",
"direction",
"edge",
"if",
"it",
"should",
"."
] | [
"\"\"\"Add an edge, then adds the opposite direction edge if it should.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": null
},
{
"param": "source_modifier",
"type": null
},
{
"param": "relation",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "target_modifier",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens":... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | _handle_relation_harness | ParseResults | def _handle_relation_harness(self, line: str, position: int, tokens: Union[ParseResults, Dict]) -> ParseResults:
"""Handle BEL relations based on the policy specified on instantiation.
Note: this can't be changed after instantiation!
"""
self._handle_relation_checked(line, position, tok... | Handle BEL relations based on the policy specified on instantiation.
Note: this can't be changed after instantiation!
| Handle BEL relations based on the policy specified on instantiation.
Note: this can't be changed after instantiation! | [
"Handle",
"BEL",
"relations",
"based",
"on",
"the",
"policy",
"specified",
"on",
"instantiation",
".",
"Note",
":",
"this",
"can",
"'",
"t",
"be",
"changed",
"after",
"instantiation!"
] | def _handle_relation_harness(self, line: str, position: int, tokens: Union[ParseResults, Dict]) -> ParseResults:
self._handle_relation_checked(line, position, tokens)
return tokens | [
"def",
"_handle_relation_harness",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"Union",
"[",
"ParseResults",
",",
"Dict",
"]",
")",
"->",
"ParseResults",
":",
"self",
".",
"_handle_relation_checked",
"(",
"line",
... | Handle BEL relations based on the policy specified on instantiation. | [
"Handle",
"BEL",
"relations",
"based",
"on",
"the",
"policy",
"specified",
"on",
"instantiation",
"."
] | [
"\"\"\"Handle BEL relations based on the policy specified on instantiation.\n\n Note: this can't be changed after instantiation!\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "Union[ParseResults, Dict]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | handle_inverse_unqualified_relation | ParseResults | def handle_inverse_unqualified_relation(self, _, __, tokens: ParseResults) -> ParseResults:
"""Handle unqualified relations that should go reverse."""
source = self.ensure_node(tokens[SOURCE])
target = self.ensure_node(tokens[TARGET])
relation = tokens[RELATION]
self.graph.add_un... | Handle unqualified relations that should go reverse. | Handle unqualified relations that should go reverse. | [
"Handle",
"unqualified",
"relations",
"that",
"should",
"go",
"reverse",
"."
] | def handle_inverse_unqualified_relation(self, _, __, tokens: ParseResults) -> ParseResults:
source = self.ensure_node(tokens[SOURCE])
target = self.ensure_node(tokens[TARGET])
relation = tokens[RELATION]
self.graph.add_unqualified_edge(source=target, target=source, relation=relation)
... | [
"def",
"handle_inverse_unqualified_relation",
"(",
"self",
",",
"_",
",",
"__",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"source",
"=",
"self",
".",
"ensure_node",
"(",
"tokens",
"[",
"SOURCE",
"]",
")",
"target",
"=",
"self",
".... | Handle unqualified relations that should go reverse. | [
"Handle",
"unqualified",
"relations",
"that",
"should",
"go",
"reverse",
"."
] | [
"\"\"\"Handle unqualified relations that should go reverse.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "_",
"type": null
},
{
"param": "__",
"type": null
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "_",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | ensure_node | BaseEntity | def ensure_node(self, tokens: ParseResults) -> BaseEntity:
"""Turn parsed tokens into canonical node name and makes sure its in the graph."""
node = parse_result_to_dsl(tokens)
self.graph.add_node_from_data(node)
return node | Turn parsed tokens into canonical node name and makes sure its in the graph. | Turn parsed tokens into canonical node name and makes sure its in the graph. | [
"Turn",
"parsed",
"tokens",
"into",
"canonical",
"node",
"name",
"and",
"makes",
"sure",
"its",
"in",
"the",
"graph",
"."
] | def ensure_node(self, tokens: ParseResults) -> BaseEntity:
node = parse_result_to_dsl(tokens)
self.graph.add_node_from_data(node)
return node | [
"def",
"ensure_node",
"(",
"self",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"BaseEntity",
":",
"node",
"=",
"parse_result_to_dsl",
"(",
"tokens",
")",
"self",
".",
"graph",
".",
"add_node_from_data",
"(",
"node",
")",
"return",
"node"
] | Turn parsed tokens into canonical node name and makes sure its in the graph. | [
"Turn",
"parsed",
"tokens",
"into",
"canonical",
"node",
"name",
"and",
"makes",
"sure",
"its",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Turn parsed tokens into canonical node name and makes sure its in the graph.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tokens",
"type": "ParseResults",
"docstring": null,
"docstrin... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | handle_molecular_activity_default | ParseResults | def handle_molecular_activity_default(_: str, __: int, tokens: ParseResults) -> ParseResults:
"""Handle a BEL 2.0 style molecular activity with BEL default names."""
upgraded_cls = language.activity_labels[tokens[0]]
upgraded_concept = language.activity_mapping[upgraded_cls]
tokens[NAMESPACE] = upgraded... | Handle a BEL 2.0 style molecular activity with BEL default names. | Handle a BEL 2.0 style molecular activity with BEL default names. | [
"Handle",
"a",
"BEL",
"2",
".",
"0",
"style",
"molecular",
"activity",
"with",
"BEL",
"default",
"names",
"."
] | def handle_molecular_activity_default(_: str, __: int, tokens: ParseResults) -> ParseResults:
upgraded_cls = language.activity_labels[tokens[0]]
upgraded_concept = language.activity_mapping[upgraded_cls]
tokens[NAMESPACE] = upgraded_concept.namespace
tokens[NAME] = upgraded_concept.name
tokens[IDENT... | [
"def",
"handle_molecular_activity_default",
"(",
"_",
":",
"str",
",",
"__",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"upgraded_cls",
"=",
"language",
".",
"activity_labels",
"[",
"tokens",
"[",
"0",
"]",
"]",
"upgraded... | Handle a BEL 2.0 style molecular activity with BEL default names. | [
"Handle",
"a",
"BEL",
"2",
".",
"0",
"style",
"molecular",
"activity",
"with",
"BEL",
"default",
"names",
"."
] | [
"\"\"\"Handle a BEL 2.0 style molecular activity with BEL default names.\"\"\""
] | [
{
"param": "_",
"type": "str"
},
{
"param": "__",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "_",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "__",
"type": "int",
"docstring": null,
"docstring_tokens": [],
... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | modifier_po_to_dict | <not_specific> | def modifier_po_to_dict(tokens):
"""Get the location, activity, and/or transformation information as a dictionary.
:return: a dictionary describing the modifier
:rtype: dict
"""
attrs = {}
if LOCATION in tokens:
attrs[LOCATION] = dict(tokens[LOCATION])
if MODIFIER not in tokens:
... | Get the location, activity, and/or transformation information as a dictionary.
:return: a dictionary describing the modifier
:rtype: dict
| Get the location, activity, and/or transformation information as a dictionary. | [
"Get",
"the",
"location",
"activity",
"and",
"/",
"or",
"transformation",
"information",
"as",
"a",
"dictionary",
"."
] | def modifier_po_to_dict(tokens):
attrs = {}
if LOCATION in tokens:
attrs[LOCATION] = dict(tokens[LOCATION])
if MODIFIER not in tokens:
return attrs
if tokens[MODIFIER] == DEGRADATION:
attrs[MODIFIER] = tokens[MODIFIER]
elif tokens[MODIFIER] == ACTIVITY:
attrs[MODIFIER... | [
"def",
"modifier_po_to_dict",
"(",
"tokens",
")",
":",
"attrs",
"=",
"{",
"}",
"if",
"LOCATION",
"in",
"tokens",
":",
"attrs",
"[",
"LOCATION",
"]",
"=",
"dict",
"(",
"tokens",
"[",
"LOCATION",
"]",
")",
"if",
"MODIFIER",
"not",
"in",
"tokens",
":",
... | Get the location, activity, and/or transformation information as a dictionary. | [
"Get",
"the",
"location",
"activity",
"and",
"/",
"or",
"transformation",
"information",
"as",
"a",
"dictionary",
"."
] | [
"\"\"\"Get the location, activity, and/or transformation information as a dictionary.\n\n :return: a dictionary describing the modifier\n :rtype: dict\n \"\"\"",
"# for when it was auto-upgraded"
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [
{
"docstring": "a dictionary describing the modifier",
"docstring_tokens": [
"a",
"dictionary",
"describing",
"the",
"modifier"
],
"type": "dict"
}
],
"raises": [],
"params": [
{
"identifier": "tokens",
"type"... |
1ea1e8556b1404a6511262fbc3d2514285310f8c | rpatil524/pybel | src/pybel/parser/parse_bel.py | [
"MIT"
] | Python | parse | <not_specific> | def parse(s: str, pprint=False):
"""Parse a BEL statement (without validation)."""
rv = _default_parser().parse(s)
if pprint:
import json
print(json.dumps(rv, indent=2))
else:
return rv | Parse a BEL statement (without validation). | Parse a BEL statement (without validation). | [
"Parse",
"a",
"BEL",
"statement",
"(",
"without",
"validation",
")",
"."
] | def parse(s: str, pprint=False):
rv = _default_parser().parse(s)
if pprint:
import json
print(json.dumps(rv, indent=2))
else:
return rv | [
"def",
"parse",
"(",
"s",
":",
"str",
",",
"pprint",
"=",
"False",
")",
":",
"rv",
"=",
"_default_parser",
"(",
")",
".",
"parse",
"(",
"s",
")",
"if",
"pprint",
":",
"import",
"json",
"print",
"(",
"json",
".",
"dumps",
"(",
"rv",
",",
"indent",... | Parse a BEL statement (without validation). | [
"Parse",
"a",
"BEL",
"statement",
"(",
"without",
"validation",
")",
"."
] | [
"\"\"\"Parse a BEL statement (without validation).\"\"\""
] | [
{
"param": "s",
"type": "str"
},
{
"param": "pprint",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pprint",
"type": null,
"docstring": null,
"docstring_tokens": [... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | raise_for_undefined_annotation | None | def raise_for_undefined_annotation(self, line: str, position: int, annotation: str) -> None:
"""Raise an exception if the annotation is not defined.
:raises: UndefinedAnnotationWarning
"""
if self._in_debug_mode:
return
if not self.has_annotation(annotation):
... | Raise an exception if the annotation is not defined.
:raises: UndefinedAnnotationWarning
| Raise an exception if the annotation is not defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"annotation",
"is",
"not",
"defined",
"."
] | def raise_for_undefined_annotation(self, line: str, position: int, annotation: str) -> None:
if self._in_debug_mode:
return
if not self.has_annotation(annotation):
raise UndefinedAnnotationWarning(self.get_line_number(), line, position, annotation) | [
"def",
"raise_for_undefined_annotation",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"annotation",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"_in_debug_mode",
":",
"return",
"if",
"not",
"self",
".",
"has_annotation... | Raise an exception if the annotation is not defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"annotation",
"is",
"not",
"defined",
"."
] | [
"\"\"\"Raise an exception if the annotation is not defined.\n\n :raises: UndefinedAnnotationWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "annotation",
"type": "str"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | raise_for_invalid_annotation_value | None | def raise_for_invalid_annotation_value(self, line: str, position: int, key: str, value: str) -> None:
"""Raise an exception if the annotation is not defined.
:raises: IllegalAnnotationValueWarning or MissingAnnotationRegexWarning
"""
if self._in_debug_mode:
return
i... | Raise an exception if the annotation is not defined.
:raises: IllegalAnnotationValueWarning or MissingAnnotationRegexWarning
| Raise an exception if the annotation is not defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"annotation",
"is",
"not",
"defined",
"."
] | def raise_for_invalid_annotation_value(self, line: str, position: int, key: str, value: str) -> None:
if self._in_debug_mode:
return
if self.has_enumerated_annotation(key) and value not in self.annotation_to_term[key]:
raise IllegalAnnotationValueWarning(self.get_line_number(), l... | [
"def",
"raise_for_invalid_annotation_value",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"key",
":",
"str",
",",
"value",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"_in_debug_mode",
":",
"return",
"if",
"self",
... | Raise an exception if the annotation is not defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"annotation",
"is",
"not",
"defined",
"."
] | [
"\"\"\"Raise an exception if the annotation is not defined.\n\n :raises: IllegalAnnotationValueWarning or MissingAnnotationRegexWarning\n \"\"\"",
"# TODO condense"
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "key",
"type": "str"
},
{
"param": "value",
"type": "str"
}
] | {
"returns": [],
"raises": [
{
"docstring": "IllegalAnnotationValueWarning or MissingAnnotationRegexWarning",
"docstring_tokens": [
"IllegalAnnotationValueWarning",
"or",
"MissingAnnotationRegexWarning"
],
"type": null
}
],
"params": [
{
"identif... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | raise_for_missing_citation | None | def raise_for_missing_citation(self, line: str, position: int) -> None:
"""Raise an exception if there is no citation present in the parser.
:raises: MissingCitationException
"""
if self.citation_clearing and not self.citation_is_set:
raise MissingCitationException(self.get_... | Raise an exception if there is no citation present in the parser.
:raises: MissingCitationException
| Raise an exception if there is no citation present in the parser. | [
"Raise",
"an",
"exception",
"if",
"there",
"is",
"no",
"citation",
"present",
"in",
"the",
"parser",
"."
] | def raise_for_missing_citation(self, line: str, position: int) -> None:
if self.citation_clearing and not self.citation_is_set:
raise MissingCitationException(self.get_line_number(), line, position) | [
"def",
"raise_for_missing_citation",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
")",
"->",
"None",
":",
"if",
"self",
".",
"citation_clearing",
"and",
"not",
"self",
".",
"citation_is_set",
":",
"raise",
"MissingCitationException",
"(",... | Raise an exception if there is no citation present in the parser. | [
"Raise",
"an",
"exception",
"if",
"there",
"is",
"no",
"citation",
"present",
"in",
"the",
"parser",
"."
] | [
"\"\"\"Raise an exception if there is no citation present in the parser.\n\n :raises: MissingCitationException\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | handle_annotation_key | ParseResults | def handle_annotation_key(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Handle an annotation key before parsing to validate that it's either enumerated or as a regex.
:raise: MissingCitationException or UndefinedAnnotationWarning
"""
key = tokens['key']
... | Handle an annotation key before parsing to validate that it's either enumerated or as a regex.
:raise: MissingCitationException or UndefinedAnnotationWarning
| Handle an annotation key before parsing to validate that it's either enumerated or as a regex. | [
"Handle",
"an",
"annotation",
"key",
"before",
"parsing",
"to",
"validate",
"that",
"it",
"'",
"s",
"either",
"enumerated",
"or",
"as",
"a",
"regex",
"."
] | def handle_annotation_key(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
key = tokens['key']
self.raise_for_missing_citation(line, position)
self.raise_for_undefined_annotation(line, position, key)
return tokens | [
"def",
"handle_annotation_key",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"key",
"=",
"tokens",
"[",
"'key'",
"]",
"self",
".",
"raise_for_missing_citation",
"(",
... | Handle an annotation key before parsing to validate that it's either enumerated or as a regex. | [
"Handle",
"an",
"annotation",
"key",
"before",
"parsing",
"to",
"validate",
"that",
"it",
"'",
"s",
"either",
"enumerated",
"or",
"as",
"a",
"regex",
"."
] | [
"\"\"\"Handle an annotation key before parsing to validate that it's either enumerated or as a regex.\n\n :raise: MissingCitationException or UndefinedAnnotationWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": "MissingCitationException or UndefinedAnnotationWarning",
"docstring_tokens": [
"MissingCitationException",
"or",
"UndefinedAnnotationWarning"
],
"type": null
}
],
"params": [
{
"identifier": "self",
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | handle_unset_statement_group | ParseResults | def handle_unset_statement_group(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Unset the statement group, or raises an exception if it is not set.
:raises: MissingAnnotationKeyWarning
"""
if self.statement_group is None:
raise MissingAnnotationKey... | Unset the statement group, or raises an exception if it is not set.
:raises: MissingAnnotationKeyWarning
| Unset the statement group, or raises an exception if it is not set. | [
"Unset",
"the",
"statement",
"group",
"or",
"raises",
"an",
"exception",
"if",
"it",
"is",
"not",
"set",
"."
] | def handle_unset_statement_group(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
if self.statement_group is None:
raise MissingAnnotationKeyWarning(self.get_line_number(), line, position, BEL_KEYWORD_STATEMENT_GROUP)
self.statement_group = None
return tokens | [
"def",
"handle_unset_statement_group",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"if",
"self",
".",
"statement_group",
"is",
"None",
":",
"raise",
"MissingAnnotationKe... | Unset the statement group, or raises an exception if it is not set. | [
"Unset",
"the",
"statement",
"group",
"or",
"raises",
"an",
"exception",
"if",
"it",
"is",
"not",
"set",
"."
] | [
"\"\"\"Unset the statement group, or raises an exception if it is not set.\n\n :raises: MissingAnnotationKeyWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | handle_unset_citation | ParseResults | def handle_unset_citation(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Unset the citation, or raise an exception if it is not set.
:raises: MissingAnnotationKeyWarning
"""
if not self.citation_is_set:
raise MissingAnnotationKeyWarning(self.get_li... | Unset the citation, or raise an exception if it is not set.
:raises: MissingAnnotationKeyWarning
| Unset the citation, or raise an exception if it is not set. | [
"Unset",
"the",
"citation",
"or",
"raise",
"an",
"exception",
"if",
"it",
"is",
"not",
"set",
"."
] | def handle_unset_citation(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
if not self.citation_is_set:
raise MissingAnnotationKeyWarning(self.get_line_number(), line, position, BEL_KEYWORD_CITATION)
self.clear_citation()
return tokens | [
"def",
"handle_unset_citation",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"if",
"not",
"self",
".",
"citation_is_set",
":",
"raise",
"MissingAnnotationKeyWarning",
"("... | Unset the citation, or raise an exception if it is not set. | [
"Unset",
"the",
"citation",
"or",
"raise",
"an",
"exception",
"if",
"it",
"is",
"not",
"set",
"."
] | [
"\"\"\"Unset the citation, or raise an exception if it is not set.\n\n :raises: MissingAnnotationKeyWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | handle_unset_evidence | ParseResults | def handle_unset_evidence(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Unset the evidence, or throws an exception if it is not already set.
The value for ``tokens[EVIDENCE]`` corresponds to which alternate of SupportingText or Evidence was used in
the BEL script.
... | Unset the evidence, or throws an exception if it is not already set.
The value for ``tokens[EVIDENCE]`` corresponds to which alternate of SupportingText or Evidence was used in
the BEL script.
:raises: MissingAnnotationKeyWarning
| Unset the evidence, or throws an exception if it is not already set.
The value for ``tokens[EVIDENCE]`` corresponds to which alternate of SupportingText or Evidence was used in
the BEL script. | [
"Unset",
"the",
"evidence",
"or",
"throws",
"an",
"exception",
"if",
"it",
"is",
"not",
"already",
"set",
".",
"The",
"value",
"for",
"`",
"`",
"tokens",
"[",
"EVIDENCE",
"]",
"`",
"`",
"corresponds",
"to",
"which",
"alternate",
"of",
"SupportingText",
"... | def handle_unset_evidence(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
if self.evidence is None:
raise MissingAnnotationKeyWarning(self.get_line_number(), line, position, tokens[EVIDENCE])
self.evidence = None
return tokens | [
"def",
"handle_unset_evidence",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"if",
"self",
".",
"evidence",
"is",
"None",
":",
"raise",
"MissingAnnotationKeyWarning",
"... | Unset the evidence, or throws an exception if it is not already set. | [
"Unset",
"the",
"evidence",
"or",
"throws",
"an",
"exception",
"if",
"it",
"is",
"not",
"already",
"set",
"."
] | [
"\"\"\"Unset the evidence, or throws an exception if it is not already set.\n\n The value for ``tokens[EVIDENCE]`` corresponds to which alternate of SupportingText or Evidence was used in\n the BEL script.\n\n :raises: MissingAnnotationKeyWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | handle_unset_command | ParseResults | def handle_unset_command(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Handle an ``UNSET X`` statement or raises an exception if it is not already set.
:raises: MissingAnnotationKeyWarning
"""
key = tokens['key']
self.validate_unset_command(line, posi... | Handle an ``UNSET X`` statement or raises an exception if it is not already set.
:raises: MissingAnnotationKeyWarning
| Handle an ``UNSET X`` statement or raises an exception if it is not already set. | [
"Handle",
"an",
"`",
"`",
"UNSET",
"X",
"`",
"`",
"statement",
"or",
"raises",
"an",
"exception",
"if",
"it",
"is",
"not",
"already",
"set",
"."
] | def handle_unset_command(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
key = tokens['key']
self.validate_unset_command(line, position, key)
del self.annotations[key]
return tokens | [
"def",
"handle_unset_command",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"key",
"=",
"tokens",
"[",
"'key'",
"]",
"self",
".",
"validate_unset_command",
"(",
"line... | Handle an ``UNSET X`` statement or raises an exception if it is not already set. | [
"Handle",
"an",
"`",
"`",
"UNSET",
"X",
"`",
"`",
"statement",
"or",
"raises",
"an",
"exception",
"if",
"it",
"is",
"not",
"already",
"set",
"."
] | [
"\"\"\"Handle an ``UNSET X`` statement or raises an exception if it is not already set.\n\n :raises: MissingAnnotationKeyWarning\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | clear_citation | None | def clear_citation(self) -> None:
"""Clear the citation and if citation clearing is enabled, clear the evidence and annotations."""
self.citation_db = None
self.citation_db_id = None
if self.citation_clearing:
self.evidence = None
self.annotations.clear() | Clear the citation and if citation clearing is enabled, clear the evidence and annotations. | Clear the citation and if citation clearing is enabled, clear the evidence and annotations. | [
"Clear",
"the",
"citation",
"and",
"if",
"citation",
"clearing",
"is",
"enabled",
"clear",
"the",
"evidence",
"and",
"annotations",
"."
] | def clear_citation(self) -> None:
self.citation_db = None
self.citation_db_id = None
if self.citation_clearing:
self.evidence = None
self.annotations.clear() | [
"def",
"clear_citation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"citation_db",
"=",
"None",
"self",
".",
"citation_db_id",
"=",
"None",
"if",
"self",
".",
"citation_clearing",
":",
"self",
".",
"evidence",
"=",
"None",
"self",
".",
"annotations"... | Clear the citation and if citation clearing is enabled, clear the evidence and annotations. | [
"Clear",
"the",
"citation",
"and",
"if",
"citation",
"clearing",
"is",
"enabled",
"clear",
"the",
"evidence",
"and",
"annotations",
"."
] | [
"\"\"\"Clear the citation and if citation clearing is enabled, clear the evidence and annotations.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7ba48a4a8027992780bc4583c41f12ad2ae69a70 | rpatil524/pybel | src/pybel/parser/parse_control.py | [
"MIT"
] | Python | clear | None | def clear(self) -> None:
"""Clear the statement_group, citation, evidence, and annotations."""
self.statement_group = None
self.citation_db = None
self.citation_db_id = None
self.evidence = None
self.annotations.clear() | Clear the statement_group, citation, evidence, and annotations. | Clear the statement_group, citation, evidence, and annotations. | [
"Clear",
"the",
"statement_group",
"citation",
"evidence",
"and",
"annotations",
"."
] | def clear(self) -> None:
self.statement_group = None
self.citation_db = None
self.citation_db_id = None
self.evidence = None
self.annotations.clear() | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"statement_group",
"=",
"None",
"self",
".",
"citation_db",
"=",
"None",
"self",
".",
"citation_db_id",
"=",
"None",
"self",
".",
"evidence",
"=",
"None",
"self",
".",
"annotations",
".",
... | Clear the statement_group, citation, evidence, and annotations. | [
"Clear",
"the",
"statement_group",
"citation",
"evidence",
"and",
"annotations",
"."
] | [
"\"\"\"Clear the statement_group, citation, evidence, and annotations.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d11b6c8a18786a0a2a3e3b9b124f549ea31c3368 | rpatil524/pybel | src/pybel/io/neo4j.py | [
"MIT"
] | Python | to_neo4j | null | def to_neo4j(graph, neo_connection, use_tqdm: bool = False):
"""Upload a BEL graph to a Neo4j graph database using :mod:`py2neo`.
:param pybel.BELGraph graph: A BEL Graph
:param neo_connection: A :mod:`py2neo` connection object. Refer to the
`py2neo documentation <http://py2neo.org/v3/database.html#th... | Upload a BEL graph to a Neo4j graph database using :mod:`py2neo`.
:param pybel.BELGraph graph: A BEL Graph
:param neo_connection: A :mod:`py2neo` connection object. Refer to the
`py2neo documentation <http://py2neo.org/v3/database.html#the-graph>`_ for how to build this object.
:type neo_connection: s... | Upload a BEL graph to a Neo4j graph database using :mod:`py2neo`. | [
"Upload",
"a",
"BEL",
"graph",
"to",
"a",
"Neo4j",
"graph",
"database",
"using",
":",
"mod",
":",
"`",
"py2neo",
"`",
"."
] | def to_neo4j(graph, neo_connection, use_tqdm: bool = False):
import py2neo
if isinstance(neo_connection, str):
neo_connection = py2neo.Graph(neo_connection)
tx = neo_connection.begin()
node_map = {}
nodes = list(graph)
if use_tqdm:
nodes = tqdm(nodes, desc='nodes')
for node i... | [
"def",
"to_neo4j",
"(",
"graph",
",",
"neo_connection",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
")",
":",
"import",
"py2neo",
"if",
"isinstance",
"(",
"neo_connection",
",",
"str",
")",
":",
"neo_connection",
"=",
"py2neo",
".",
"Graph",
"(",
"neo_conn... | Upload a BEL graph to a Neo4j graph database using :mod:`py2neo`. | [
"Upload",
"a",
"BEL",
"graph",
"to",
"a",
"Neo4j",
"graph",
"database",
"using",
":",
"mod",
":",
"`",
"py2neo",
"`",
"."
] | [
"\"\"\"Upload a BEL graph to a Neo4j graph database using :mod:`py2neo`.\n\n :param pybel.BELGraph graph: A BEL Graph\n :param neo_connection: A :mod:`py2neo` connection object. Refer to the\n `py2neo documentation <http://py2neo.org/v3/database.html#the-graph>`_ for how to build this object.\n :type n... | [
{
"param": "graph",
"type": null
},
{
"param": "neo_connection",
"type": null
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL Graph",
"docstring_tokens": [
"A",
"BEL",
"Graph"
],
"default": null,
"is_optional": false
},
{
"identifier": "neo_connection",
... |
c74507c13403b0d37b24eaa2477651d57556d62a | rpatil524/pybel | src/pybel/io/cx.py | [
"MIT"
] | Python | to_cx_file | None | def to_cx_file(graph: BELGraph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs) -> None:
"""Write a BEL graph to a JSON file in CX format.
:param graph: A BEL graph
:param path: A writable file or file-like
:param indent: How many spaces to use to pretty print. Change to None for no pret... | Write a BEL graph to a JSON file in CX format.
:param graph: A BEL graph
:param path: A writable file or file-like
:param indent: How many spaces to use to pretty print. Change to None for no pretty printing
The example below shows how to output a BEL graph as CX to an open file.
.. code-block:: ... | Write a BEL graph to a JSON file in CX format. | [
"Write",
"a",
"BEL",
"graph",
"to",
"a",
"JSON",
"file",
"in",
"CX",
"format",
"."
] | def to_cx_file(graph: BELGraph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs) -> None:
graph_cx_json_dict = to_cx(graph)
json.dump(graph_cx_json_dict, path, ensure_ascii=False, indent=indent, **kwargs) | [
"def",
"to_cx_file",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"indent",
":",
"Optional",
"[",
"int",
"]",
"=",
"2",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"graph_cx_json_dict",
"=",
"to_cx",... | Write a BEL graph to a JSON file in CX format. | [
"Write",
"a",
"BEL",
"graph",
"to",
"a",
"JSON",
"file",
"in",
"CX",
"format",
"."
] | [
"\"\"\"Write a BEL graph to a JSON file in CX format.\n\n :param graph: A BEL graph\n :param path: A writable file or file-like\n :param indent: How many spaces to use to pretty print. Change to None for no pretty printing\n\n The example below shows how to output a BEL graph as CX to an open file.\n\n ... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "indent",
"type": "Optional[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
c74507c13403b0d37b24eaa2477651d57556d62a | rpatil524/pybel | src/pybel/io/cx.py | [
"MIT"
] | Python | from_cx_file | BELGraph | def from_cx_file(path: Union[str, TextIO]) -> BELGraph:
"""Read a file containing CX JSON and converts to a BEL graph.
:param path: A readable file or file-like containing the CX JSON for this graph
:return: A BEL Graph representing the CX graph contained in the file
"""
return from_cx(json.load(pa... | Read a file containing CX JSON and converts to a BEL graph.
:param path: A readable file or file-like containing the CX JSON for this graph
:return: A BEL Graph representing the CX graph contained in the file
| Read a file containing CX JSON and converts to a BEL graph. | [
"Read",
"a",
"file",
"containing",
"CX",
"JSON",
"and",
"converts",
"to",
"a",
"BEL",
"graph",
"."
] | def from_cx_file(path: Union[str, TextIO]) -> BELGraph:
return from_cx(json.load(path)) | [
"def",
"from_cx_file",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
")",
"->",
"BELGraph",
":",
"return",
"from_cx",
"(",
"json",
".",
"load",
"(",
"path",
")",
")"
] | Read a file containing CX JSON and converts to a BEL graph. | [
"Read",
"a",
"file",
"containing",
"CX",
"JSON",
"and",
"converts",
"to",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Read a file containing CX JSON and converts to a BEL graph.\n\n :param path: A readable file or file-like containing the CX JSON for this graph\n :return: A BEL Graph representing the CX graph contained in the file\n \"\"\""
] | [
{
"param": "path",
"type": "Union[str, TextIO]"
}
] | {
"returns": [
{
"docstring": "A BEL Graph representing the CX graph contained in the file",
"docstring_tokens": [
"A",
"BEL",
"Graph",
"representing",
"the",
"CX",
"graph",
"contained",
"in",
"the",
"file"
]... |
27b2a787ab39aa7a8d91005ea9db421fe07e71c4 | rpatil524/pybel | src/pybel/io/line_utils.py | [
"MIT"
] | Python | parse_lines | None | def parse_lines(
graph: BELGraph,
lines: Iterable[str],
manager: Optional[Manager] = None,
disallow_nested: bool = False,
citation_clearing: bool = True,
use_tqdm: bool = False,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
no_identifier_validation: bool = False,
disallow_unqualif... | Parse an iterable of lines into this graph.
Delegates to :func:`parse_document`, :func:`parse_definitions`, and :func:`parse_statements`.
:param graph: A BEL graph
:param lines: An iterable over lines of BEL script
:param manager: A PyBEL database manager
:param disallow_nested: If true, turns on ... | Parse an iterable of lines into this graph. | [
"Parse",
"an",
"iterable",
"of",
"lines",
"into",
"this",
"graph",
"."
] | def parse_lines(
graph: BELGraph,
lines: Iterable[str],
manager: Optional[Manager] = None,
disallow_nested: bool = False,
citation_clearing: bool = True,
use_tqdm: bool = False,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
no_identifier_validation: bool = False,
disallow_unqualif... | [
"def",
"parse_lines",
"(",
"graph",
":",
"BELGraph",
",",
"lines",
":",
"Iterable",
"[",
"str",
"]",
",",
"manager",
":",
"Optional",
"[",
"Manager",
"]",
"=",
"None",
",",
"disallow_nested",
":",
"bool",
"=",
"False",
",",
"citation_clearing",
":",
"boo... | Parse an iterable of lines into this graph. | [
"Parse",
"an",
"iterable",
"of",
"lines",
"into",
"this",
"graph",
"."
] | [
"\"\"\"Parse an iterable of lines into this graph.\n\n Delegates to :func:`parse_document`, :func:`parse_definitions`, and :func:`parse_statements`.\n\n :param graph: A BEL graph\n :param lines: An iterable over lines of BEL script\n :param manager: A PyBEL database manager\n :param disallow_nested: ... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "lines",
"type": "Iterable[str]"
},
{
"param": "manager",
"type": "Optional[Manager]"
},
{
"param": "disallow_nested",
"type": "bool"
},
{
"param": "citation_clearing",
"type": "bool"
},
{
"param": "... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "lines",
... |
27b2a787ab39aa7a8d91005ea9db421fe07e71c4 | rpatil524/pybel | src/pybel/io/line_utils.py | [
"MIT"
] | Python | parse_document | None | def parse_document(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
metadata_parser: MetadataParser,
) -> None:
"""Parse the lines in the document section of a BEL script."""
parse_document_start_time = time.time()
for line_number, line in enumerated_lines:
try:
... | Parse the lines in the document section of a BEL script. | Parse the lines in the document section of a BEL script. | [
"Parse",
"the",
"lines",
"in",
"the",
"document",
"section",
"of",
"a",
"BEL",
"script",
"."
] | def parse_document(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
metadata_parser: MetadataParser,
) -> None:
parse_document_start_time = time.time()
for line_number, line in enumerated_lines:
try:
metadata_parser.parseString(line, line_number=line_number)
... | [
"def",
"parse_document",
"(",
"graph",
":",
"BELGraph",
",",
"enumerated_lines",
":",
"Iterable",
"[",
"Tuple",
"[",
"int",
",",
"str",
"]",
"]",
",",
"metadata_parser",
":",
"MetadataParser",
",",
")",
"->",
"None",
":",
"parse_document_start_time",
"=",
"t... | Parse the lines in the document section of a BEL script. | [
"Parse",
"the",
"lines",
"in",
"the",
"document",
"section",
"of",
"a",
"BEL",
"script",
"."
] | [
"\"\"\"Parse the lines in the document section of a BEL script.\"\"\"",
"# This has to be insert since it needs to go on the front!"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "enumerated_lines",
"type": "Iterable[Tuple[int, str]]"
},
{
"param": "metadata_parser",
"type": "MetadataParser"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "enumerated_lines",
"type": "Iterable[Tuple[int, str]]",
"doc... |
27b2a787ab39aa7a8d91005ea9db421fe07e71c4 | rpatil524/pybel | src/pybel/io/line_utils.py | [
"MIT"
] | Python | parse_definitions | None | def parse_definitions(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
metadata_parser: MetadataParser,
allow_failures: bool = False,
use_tqdm: bool = False,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
"""Parse the lines in the definitions section of a BEL scrip... | Parse the lines in the definitions section of a BEL script.
:param graph: A BEL graph
:param enumerated_lines: An enumerated iterable over the lines in the definitions section of a BEL script
:param metadata_parser: A metadata parser
:param allow_failures: If true, allows parser to continue past strang... | Parse the lines in the definitions section of a BEL script. | [
"Parse",
"the",
"lines",
"in",
"the",
"definitions",
"section",
"of",
"a",
"BEL",
"script",
"."
] | def parse_definitions(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
metadata_parser: MetadataParser,
allow_failures: bool = False,
use_tqdm: bool = False,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
parse_definitions_start_time = time.time()
if use_tqdm:
... | [
"def",
"parse_definitions",
"(",
"graph",
":",
"BELGraph",
",",
"enumerated_lines",
":",
"Iterable",
"[",
"Tuple",
"[",
"int",
",",
"str",
"]",
"]",
",",
"metadata_parser",
":",
"MetadataParser",
",",
"allow_failures",
":",
"bool",
"=",
"False",
",",
"use_tq... | Parse the lines in the definitions section of a BEL script. | [
"Parse",
"the",
"lines",
"in",
"the",
"definitions",
"section",
"of",
"a",
"BEL",
"script",
"."
] | [
"\"\"\"Parse the lines in the definitions section of a BEL script.\n\n :param graph: A BEL graph\n :param enumerated_lines: An enumerated iterable over the lines in the definitions section of a BEL script\n :param metadata_parser: A metadata parser\n :param allow_failures: If true, allows parser to cont... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "enumerated_lines",
"type": "Iterable[Tuple[int, str]]"
},
{
"param": "metadata_parser",
"type": "MetadataParser"
},
{
"param": "allow_failures",
"type": "bool"
},
{
"param": "use_tqdm",
"type": "bool"
},
... | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
},
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
},
{
"docstring": null,
"docstring_tokens": [
"N... |
27b2a787ab39aa7a8d91005ea9db421fe07e71c4 | rpatil524/pybel | src/pybel/io/line_utils.py | [
"MIT"
] | Python | parse_statements | None | def parse_statements(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
bel_parser: BELParser,
use_tqdm: bool = True,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
"""Parse a list of statements from a BEL Script.
:param graph: A BEL graph
:param enumerated_line... | Parse a list of statements from a BEL Script.
:param graph: A BEL graph
:param enumerated_lines: An enumerated iterable over the lines in the statements section of a BEL script
:param bel_parser: A BEL parser
:param use_tqdm: Use :mod:`tqdm` to show a progress bar? Requires reading whole file to memory... | Parse a list of statements from a BEL Script. | [
"Parse",
"a",
"list",
"of",
"statements",
"from",
"a",
"BEL",
"Script",
"."
] | def parse_statements(
graph: BELGraph,
enumerated_lines: Iterable[Tuple[int, str]],
bel_parser: BELParser,
use_tqdm: bool = True,
tqdm_kwargs: Optional[Mapping[str, Any]] = None,
) -> None:
parse_statements_start_time = time.time()
if use_tqdm:
tqdm_kwargs = {} if tqdm_kwargs is None... | [
"def",
"parse_statements",
"(",
"graph",
":",
"BELGraph",
",",
"enumerated_lines",
":",
"Iterable",
"[",
"Tuple",
"[",
"int",
",",
"str",
"]",
"]",
",",
"bel_parser",
":",
"BELParser",
",",
"use_tqdm",
":",
"bool",
"=",
"True",
",",
"tqdm_kwargs",
":",
"... | Parse a list of statements from a BEL Script. | [
"Parse",
"a",
"list",
"of",
"statements",
"from",
"a",
"BEL",
"Script",
"."
] | [
"\"\"\"Parse a list of statements from a BEL Script.\n\n :param graph: A BEL graph\n :param enumerated_lines: An enumerated iterable over the lines in the statements section of a BEL script\n :param bel_parser: A BEL parser\n :param use_tqdm: Use :mod:`tqdm` to show a progress bar? Requires reading whol... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "enumerated_lines",
"type": "Iterable[Tuple[int, str]]"
},
{
"param": "bel_parser",
"type": "BELParser"
},
{
"param": "use_tqdm",
"type": "bool"
},
{
"param": "tqdm_kwargs",
"type": "Optional[Mapping[str, An... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "enumerated_l... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | to_bytes | bytes | def to_bytes(graph: BELGraph, protocol: int = pickle.HIGHEST_PROTOCOL) -> bytes:
"""Convert a graph to bytes with pickle.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2.
:param graph: A BEL graph
:param pr... | Convert a graph to bytes with pickle.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2.
:param graph: A BEL graph
:param protocol: Pickling protocol to use. Defaults to ``HIGHEST_PROTOCOL``.
.. seealso:: ht... | Convert a graph to bytes with pickle.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2. | [
"Convert",
"a",
"graph",
"to",
"bytes",
"with",
"pickle",
".",
"Note",
"that",
"the",
"pickle",
"module",
"has",
"some",
"incompatibilities",
"between",
"Python",
"2",
"and",
"3",
".",
"To",
"export",
"a",
"universally",
"importable",
"pickle",
"choose",
"0"... | def to_bytes(graph: BELGraph, protocol: int = pickle.HIGHEST_PROTOCOL) -> bytes:
raise_for_not_bel(graph)
return pickle.dumps(graph, protocol=protocol) | [
"def",
"to_bytes",
"(",
"graph",
":",
"BELGraph",
",",
"protocol",
":",
"int",
"=",
"pickle",
".",
"HIGHEST_PROTOCOL",
")",
"->",
"bytes",
":",
"raise_for_not_bel",
"(",
"graph",
")",
"return",
"pickle",
".",
"dumps",
"(",
"graph",
",",
"protocol",
"=",
... | Convert a graph to bytes with pickle. | [
"Convert",
"a",
"graph",
"to",
"bytes",
"with",
"pickle",
"."
] | [
"\"\"\"Convert a graph to bytes with pickle.\n\n Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable\n pickle, choose 0, 1, or 2.\n\n :param graph: A BEL graph\n :param protocol: Pickling protocol to use. Defaults to ``HIGHEST_PROTOCOL``.\n\n... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "protocol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "protocol",
... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | from_bytes | BELGraph | def from_bytes(bytes_graph: bytes, check_version: bool = True) -> BELGraph:
"""Read a graph from bytes (the result of pickling the graph).
:param bytes_graph: File or filename to write
:param check_version: Checks if the graph was produced by this version of PyBEL
"""
graph = pickle.loads(bytes_gra... | Read a graph from bytes (the result of pickling the graph).
:param bytes_graph: File or filename to write
:param check_version: Checks if the graph was produced by this version of PyBEL
| Read a graph from bytes (the result of pickling the graph). | [
"Read",
"a",
"graph",
"from",
"bytes",
"(",
"the",
"result",
"of",
"pickling",
"the",
"graph",
")",
"."
] | def from_bytes(bytes_graph: bytes, check_version: bool = True) -> BELGraph:
graph = pickle.loads(bytes_graph)
raise_for_not_bel(graph)
if check_version:
raise_for_old_graph(graph)
return graph | [
"def",
"from_bytes",
"(",
"bytes_graph",
":",
"bytes",
",",
"check_version",
":",
"bool",
"=",
"True",
")",
"->",
"BELGraph",
":",
"graph",
"=",
"pickle",
".",
"loads",
"(",
"bytes_graph",
")",
"raise_for_not_bel",
"(",
"graph",
")",
"if",
"check_version",
... | Read a graph from bytes (the result of pickling the graph). | [
"Read",
"a",
"graph",
"from",
"bytes",
"(",
"the",
"result",
"of",
"pickling",
"the",
"graph",
")",
"."
] | [
"\"\"\"Read a graph from bytes (the result of pickling the graph).\n\n :param bytes_graph: File or filename to write\n :param check_version: Checks if the graph was produced by this version of PyBEL\n \"\"\""
] | [
{
"param": "bytes_graph",
"type": "bytes"
},
{
"param": "check_version",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bytes_graph",
"type": "bytes",
"docstring": "File or filename to write",
"docstring_tokens": [
"File",
"or",
"filename",
"to",
"write"
],
"default": null,
"is_optional"... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | to_bytes_gz | bytes | def to_bytes_gz(graph: BELGraph, protocol: int = pickle.HIGHEST_PROTOCOL) -> bytes:
"""Convert a graph to gzipped bytes with pickle.
:param graph: A BEL graph
:param protocol: Pickling protocol to use. Defaults to ``HIGHEST_PROTOCOL``.
"""
io = BytesIO()
with gzip.open(io, mode='wb') as file:
... | Convert a graph to gzipped bytes with pickle.
:param graph: A BEL graph
:param protocol: Pickling protocol to use. Defaults to ``HIGHEST_PROTOCOL``.
| Convert a graph to gzipped bytes with pickle. | [
"Convert",
"a",
"graph",
"to",
"gzipped",
"bytes",
"with",
"pickle",
"."
] | def to_bytes_gz(graph: BELGraph, protocol: int = pickle.HIGHEST_PROTOCOL) -> bytes:
io = BytesIO()
with gzip.open(io, mode='wb') as file:
pickle.dump(graph, file, protocol=protocol)
return io.getvalue() | [
"def",
"to_bytes_gz",
"(",
"graph",
":",
"BELGraph",
",",
"protocol",
":",
"int",
"=",
"pickle",
".",
"HIGHEST_PROTOCOL",
")",
"->",
"bytes",
":",
"io",
"=",
"BytesIO",
"(",
")",
"with",
"gzip",
".",
"open",
"(",
"io",
",",
"mode",
"=",
"'wb'",
")",
... | Convert a graph to gzipped bytes with pickle. | [
"Convert",
"a",
"graph",
"to",
"gzipped",
"bytes",
"with",
"pickle",
"."
] | [
"\"\"\"Convert a graph to gzipped bytes with pickle.\n\n :param graph: A BEL graph\n :param protocol: Pickling protocol to use. Defaults to ``HIGHEST_PROTOCOL``.\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "protocol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "protocol",
... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | from_bytes_gz | BELGraph | def from_bytes_gz(bytes_graph: bytes) -> BELGraph:
"""Read a graph from gzipped bytes (the result of pickling the graph).
:param bytes_graph: File or filename to write
"""
with gzip.GzipFile(fileobj=BytesIO(bytes_graph), mode='rb') as file:
return pickle.load(file) | Read a graph from gzipped bytes (the result of pickling the graph).
:param bytes_graph: File or filename to write
| Read a graph from gzipped bytes (the result of pickling the graph). | [
"Read",
"a",
"graph",
"from",
"gzipped",
"bytes",
"(",
"the",
"result",
"of",
"pickling",
"the",
"graph",
")",
"."
] | def from_bytes_gz(bytes_graph: bytes) -> BELGraph:
with gzip.GzipFile(fileobj=BytesIO(bytes_graph), mode='rb') as file:
return pickle.load(file) | [
"def",
"from_bytes_gz",
"(",
"bytes_graph",
":",
"bytes",
")",
"->",
"BELGraph",
":",
"with",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"BytesIO",
"(",
"bytes_graph",
")",
",",
"mode",
"=",
"'rb'",
")",
"as",
"file",
":",
"return",
"pickle",
".",
"... | Read a graph from gzipped bytes (the result of pickling the graph). | [
"Read",
"a",
"graph",
"from",
"gzipped",
"bytes",
"(",
"the",
"result",
"of",
"pickling",
"the",
"graph",
")",
"."
] | [
"\"\"\"Read a graph from gzipped bytes (the result of pickling the graph).\n\n :param bytes_graph: File or filename to write\n \"\"\""
] | [
{
"param": "bytes_graph",
"type": "bytes"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bytes_graph",
"type": "bytes",
"docstring": "File or filename to write",
"docstring_tokens": [
"File",
"or",
"filename",
"to",
"write"
],
"default": null,
"is_optional"... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | to_pickle | None | def to_pickle(graph: BELGraph, path: Union[str, BinaryIO], protocol: int = pickle.HIGHEST_PROTOCOL) -> None:
"""Write this graph to a pickle file.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2.
:param graph: ... | Write this graph to a pickle file.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2.
:param graph: A BEL graph
:param path: A path or file-like
:param protocol: Pickling protocol to use. Defaults to ``HIGHES... | Write this graph to a pickle file.
Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable
pickle, choose 0, 1, or 2. | [
"Write",
"this",
"graph",
"to",
"a",
"pickle",
"file",
".",
"Note",
"that",
"the",
"pickle",
"module",
"has",
"some",
"incompatibilities",
"between",
"Python",
"2",
"and",
"3",
".",
"To",
"export",
"a",
"universally",
"importable",
"pickle",
"choose",
"0",
... | def to_pickle(graph: BELGraph, path: Union[str, BinaryIO], protocol: int = pickle.HIGHEST_PROTOCOL) -> None:
raise_for_not_bel(graph)
pickle.dump(graph, path, protocol) | [
"def",
"to_pickle",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"BinaryIO",
"]",
",",
"protocol",
":",
"int",
"=",
"pickle",
".",
"HIGHEST_PROTOCOL",
")",
"->",
"None",
":",
"raise_for_not_bel",
"(",
"graph",
")",
"pickle",... | Write this graph to a pickle file. | [
"Write",
"this",
"graph",
"to",
"a",
"pickle",
"file",
"."
] | [
"\"\"\"Write this graph to a pickle file.\n\n Note that the pickle module has some incompatibilities between Python 2 and 3. To export a universally importable\n pickle, choose 0, 1, or 2.\n\n :param graph: A BEL graph\n :param path: A path or file-like\n :param protocol: Pickling protocol to use. De... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, BinaryIO]"
},
{
"param": "protocol",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
467bb96cf65df5d1f233e21d475a7ce9439a2a77 | rpatil524/pybel | src/pybel/io/gpickle.py | [
"MIT"
] | Python | from_pickle | BELGraph | def from_pickle(path: Union[str, BinaryIO], check_version: bool = True) -> BELGraph:
"""Read a graph from a pickle file.
:param path: File or filename to read. Filenames ending in .gz or .bz2 will be uncompressed.
:param bool check_version: Checks if the graph was produced by this version of PyBEL
"""
... | Read a graph from a pickle file.
:param path: File or filename to read. Filenames ending in .gz or .bz2 will be uncompressed.
:param bool check_version: Checks if the graph was produced by this version of PyBEL
| Read a graph from a pickle file. | [
"Read",
"a",
"graph",
"from",
"a",
"pickle",
"file",
"."
] | def from_pickle(path: Union[str, BinaryIO], check_version: bool = True) -> BELGraph:
graph = pickle.load(path)
raise_for_not_bel(graph)
if check_version:
raise_for_old_graph(graph)
return graph | [
"def",
"from_pickle",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"BinaryIO",
"]",
",",
"check_version",
":",
"bool",
"=",
"True",
")",
"->",
"BELGraph",
":",
"graph",
"=",
"pickle",
".",
"load",
"(",
"path",
")",
"raise_for_not_bel",
"(",
"graph",
")"... | Read a graph from a pickle file. | [
"Read",
"a",
"graph",
"from",
"a",
"pickle",
"file",
"."
] | [
"\"\"\"Read a graph from a pickle file.\n\n :param path: File or filename to read. Filenames ending in .gz or .bz2 will be uncompressed.\n :param bool check_version: Checks if the graph was produced by this version of PyBEL\n \"\"\""
] | [
{
"param": "path",
"type": "Union[str, BinaryIO]"
},
{
"param": "check_version",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "Union[str, BinaryIO]",
"docstring": "File or filename to read. Filenames ending in .gz or .bz2 will be uncompressed.",
"docstring_tokens": [
"File",
"or",
"filename",
"to",
... |
c9c8dd3420d458c730e22f921b495cf4f06d7ed5 | rpatil524/pybel | src/pybel/io/bel_commons_client.py | [
"MIT"
] | Python | to_bel_commons | requests.Response | def to_bel_commons(
graph: BELGraph,
host: Optional[str] = None,
user: Optional[str] = None,
password: Optional[str] = None,
public: bool = True,
) -> requests.Response:
"""Send a graph to the receiver service and returns the :mod:`requests` response object.
:param graph: A BEL graph
:p... | Send a graph to the receiver service and returns the :mod:`requests` response object.
:param graph: A BEL graph
:param host: The location of the BEL Commons server. Alternatively, looks up in PyBEL config with
``PYBEL_REMOTE_HOST`` or the environment as ``PYBEL_REMOTE_HOST``.
:param user: Username for... | Send a graph to the receiver service and returns the :mod:`requests` response object. | [
"Send",
"a",
"graph",
"to",
"the",
"receiver",
"service",
"and",
"returns",
"the",
":",
"mod",
":",
"`",
"requests",
"`",
"response",
"object",
"."
] | def to_bel_commons(
graph: BELGraph,
host: Optional[str] = None,
user: Optional[str] = None,
password: Optional[str] = None,
public: bool = True,
) -> requests.Response:
if host is None:
host = _get_host()
logger.debug('using host: %s', host)
if user is None:
user = _... | [
"def",
"to_bel_commons",
"(",
"graph",
":",
"BELGraph",
",",
"host",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"user",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"password",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"pu... | Send a graph to the receiver service and returns the :mod:`requests` response object. | [
"Send",
"a",
"graph",
"to",
"the",
"receiver",
"service",
"and",
"returns",
"the",
":",
"mod",
":",
"`",
"requests",
"`",
"response",
"object",
"."
] | [
"\"\"\"Send a graph to the receiver service and returns the :mod:`requests` response object.\n\n :param graph: A BEL graph\n :param host: The location of the BEL Commons server. Alternatively, looks up in PyBEL config with\n ``PYBEL_REMOTE_HOST`` or the environment as ``PYBEL_REMOTE_HOST``.\n :param us... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "host",
"type": "Optional[str]"
},
{
"param": "user",
"type": "Optional[str]"
},
{
"param": "password",
"type": "Optional[str]"
},
{
"param": "public",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "The response object from :mod:`requests`",
"docstring_tokens": [
"The",
"response",
"object",
"from",
":",
"mod",
":",
"`",
"requests",
"`"
],
"type": null
}
],
"raises": ... |
c9c8dd3420d458c730e22f921b495cf4f06d7ed5 | rpatil524/pybel | src/pybel/io/bel_commons_client.py | [
"MIT"
] | Python | from_bel_commons | BELGraph | def from_bel_commons(network_id: int, host: Optional[str] = None) -> BELGraph:
"""Retrieve a public network from BEL Commons.
In the future, this function may be extended to support authentication.
:param network_id: The BEL Commons network identifier
:param host: The location of the BEL Commons serve... | Retrieve a public network from BEL Commons.
In the future, this function may be extended to support authentication.
:param network_id: The BEL Commons network identifier
:param host: The location of the BEL Commons server. Alternatively, looks up in PyBEL config with
``PYBEL_REMOTE_HOST`` or the envi... | Retrieve a public network from BEL Commons.
In the future, this function may be extended to support authentication. | [
"Retrieve",
"a",
"public",
"network",
"from",
"BEL",
"Commons",
".",
"In",
"the",
"future",
"this",
"function",
"may",
"be",
"extended",
"to",
"support",
"authentication",
"."
] | def from_bel_commons(network_id: int, host: Optional[str] = None) -> BELGraph:
if host is None:
host = _get_host()
if host is None:
raise ValueError('host not specified in arguments, PyBEL configuration, or environment.')
url = host + GET_ENDPOINT.format(network_id)
res = requests.get(ur... | [
"def",
"from_bel_commons",
"(",
"network_id",
":",
"int",
",",
"host",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"BELGraph",
":",
"if",
"host",
"is",
"None",
":",
"host",
"=",
"_get_host",
"(",
")",
"if",
"host",
"is",
"None",
":",
... | Retrieve a public network from BEL Commons. | [
"Retrieve",
"a",
"public",
"network",
"from",
"BEL",
"Commons",
"."
] | [
"\"\"\"Retrieve a public network from BEL Commons.\n\n In the future, this function may be extended to support authentication.\n\n :param network_id: The BEL Commons network identifier\n :param host: The location of the BEL Commons server. Alternatively, looks up in PyBEL config with\n ``PYBEL_REMOTE_H... | [
{
"param": "network_id",
"type": "int"
},
{
"param": "host",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [
{
"docstring": "ValueError if host configuration can not be found",
"docstring_tokens": [
"ValueError",
"if",
"host",
"configuration",
"can",
"not",
"be",
"found"
],
"type": null
}
],
"pa... |
0f5fc496210b4352a23780e895c631dc89975a76 | rpatil524/pybel | src/pybel/struct/summary/provenance.py | [
"MIT"
] | Python | iterate_citation_identifiers | <not_specific> | def iterate_citation_identifiers(graph, prefix: str):
"""Iterate over all citation identifiers with the given prefix in a graph.
:param graph: A BEL graph
:param prefix: The citation prefix to keep
:return: An iterator over the PubMed identifiers in the graph
"""
predicate = CITATION_PREDICATES... | Iterate over all citation identifiers with the given prefix in a graph.
:param graph: A BEL graph
:param prefix: The citation prefix to keep
:return: An iterator over the PubMed identifiers in the graph
| Iterate over all citation identifiers with the given prefix in a graph. | [
"Iterate",
"over",
"all",
"citation",
"identifiers",
"with",
"the",
"given",
"prefix",
"in",
"a",
"graph",
"."
] | def iterate_citation_identifiers(graph, prefix: str):
predicate = CITATION_PREDICATES.get(prefix)
if predicate is None:
raise ValueError(f'Invalid citation prefix: {prefix}')
return (
data[CITATION][IDENTIFIER].strip()
for _, _, data in graph.edges(data=True)
if predicate(dat... | [
"def",
"iterate_citation_identifiers",
"(",
"graph",
",",
"prefix",
":",
"str",
")",
":",
"predicate",
"=",
"CITATION_PREDICATES",
".",
"get",
"(",
"prefix",
")",
"if",
"predicate",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"f'Invalid citation prefix: {prefix... | Iterate over all citation identifiers with the given prefix in a graph. | [
"Iterate",
"over",
"all",
"citation",
"identifiers",
"with",
"the",
"given",
"prefix",
"in",
"a",
"graph",
"."
] | [
"\"\"\"Iterate over all citation identifiers with the given prefix in a graph.\n\n :param graph: A BEL graph\n :param prefix: The citation prefix to keep\n :return: An iterator over the PubMed identifiers in the graph\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "prefix",
"type": "str"
}
] | {
"returns": [
{
"docstring": "An iterator over the PubMed identifiers in the graph",
"docstring_tokens": [
"An",
"iterator",
"over",
"the",
"PubMed",
"identifiers",
"in",
"the",
"graph"
],
"type": null
}
],
"r... |
0f5fc496210b4352a23780e895c631dc89975a76 | rpatil524/pybel | src/pybel/struct/summary/provenance.py | [
"MIT"
] | Python | iterate_pubmed_identifiers | Iterable[str] | def iterate_pubmed_identifiers(graph: BELGraph) -> Iterable[str]:
"""Iterate over all PubMed identifiers in a graph.
:param graph: A BEL graph
:return: An iterator over the PubMed identifiers in the graph
"""
return iterate_citation_identifiers(graph, 'pubmed') | Iterate over all PubMed identifiers in a graph.
:param graph: A BEL graph
:return: An iterator over the PubMed identifiers in the graph
| Iterate over all PubMed identifiers in a graph. | [
"Iterate",
"over",
"all",
"PubMed",
"identifiers",
"in",
"a",
"graph",
"."
] | def iterate_pubmed_identifiers(graph: BELGraph) -> Iterable[str]:
return iterate_citation_identifiers(graph, 'pubmed') | [
"def",
"iterate_pubmed_identifiers",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"return",
"iterate_citation_identifiers",
"(",
"graph",
",",
"'pubmed'",
")"
] | Iterate over all PubMed identifiers in a graph. | [
"Iterate",
"over",
"all",
"PubMed",
"identifiers",
"in",
"a",
"graph",
"."
] | [
"\"\"\"Iterate over all PubMed identifiers in a graph.\n\n :param graph: A BEL graph\n :return: An iterator over the PubMed identifiers in the graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [
{
"docstring": "An iterator over the PubMed identifiers in the graph",
"docstring_tokens": [
"An",
"iterator",
"over",
"the",
"PubMed",
"identifiers",
"in",
"the",
"graph"
],
"type": null
}
],
"r... |
0f5fc496210b4352a23780e895c631dc89975a76 | rpatil524/pybel | src/pybel/struct/summary/provenance.py | [
"MIT"
] | Python | iterate_pmc_identifiers | Iterable[str] | def iterate_pmc_identifiers(graph: BELGraph) -> Iterable[str]:
"""Iterate over all PMC identifiers in a graph.
:param graph: A BEL graph
:return: An iterator over the PMC identifiers in the graph
"""
return iterate_citation_identifiers(graph, 'pmc') | Iterate over all PMC identifiers in a graph.
:param graph: A BEL graph
:return: An iterator over the PMC identifiers in the graph
| Iterate over all PMC identifiers in a graph. | [
"Iterate",
"over",
"all",
"PMC",
"identifiers",
"in",
"a",
"graph",
"."
] | def iterate_pmc_identifiers(graph: BELGraph) -> Iterable[str]:
return iterate_citation_identifiers(graph, 'pmc') | [
"def",
"iterate_pmc_identifiers",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"return",
"iterate_citation_identifiers",
"(",
"graph",
",",
"'pmc'",
")"
] | Iterate over all PMC identifiers in a graph. | [
"Iterate",
"over",
"all",
"PMC",
"identifiers",
"in",
"a",
"graph",
"."
] | [
"\"\"\"Iterate over all PMC identifiers in a graph.\n\n :param graph: A BEL graph\n :return: An iterator over the PMC identifiers in the graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [
{
"docstring": "An iterator over the PMC identifiers in the graph",
"docstring_tokens": [
"An",
"iterator",
"over",
"the",
"PMC",
"identifiers",
"in",
"the",
"graph"
],
"type": null
}
],
"raises"... |
8076ec17b1d2ad9d5375ebc4397df3deebb17d8d | rpatil524/pybel | src/pybel/testing/utils.py | [
"MIT"
] | Python | make_dummy_namespaces | None | def make_dummy_namespaces(manager: Manager, graph: BELGraph) -> None:
"""Make dummy namespaces for the test."""
for keyword, names in get_names(graph).items():
graph.namespace_url[keyword] = url = n()
namespace = Namespace(keyword=keyword, url=url)
manager.session.add(namespace)
... | Make dummy namespaces for the test. | Make dummy namespaces for the test. | [
"Make",
"dummy",
"namespaces",
"for",
"the",
"test",
"."
] | def make_dummy_namespaces(manager: Manager, graph: BELGraph) -> None:
for keyword, names in get_names(graph).items():
graph.namespace_url[keyword] = url = n()
namespace = Namespace(keyword=keyword, url=url)
manager.session.add(namespace)
for name in names:
entry = Namespa... | [
"def",
"make_dummy_namespaces",
"(",
"manager",
":",
"Manager",
",",
"graph",
":",
"BELGraph",
")",
"->",
"None",
":",
"for",
"keyword",
",",
"names",
"in",
"get_names",
"(",
"graph",
")",
".",
"items",
"(",
")",
":",
"graph",
".",
"namespace_url",
"[",
... | Make dummy namespaces for the test. | [
"Make",
"dummy",
"namespaces",
"for",
"the",
"test",
"."
] | [
"\"\"\"Make dummy namespaces for the test.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docst... |
8076ec17b1d2ad9d5375ebc4397df3deebb17d8d | rpatil524/pybel | src/pybel/testing/utils.py | [
"MIT"
] | Python | make_dummy_annotations | null | def make_dummy_annotations(manager: Manager, graph: BELGraph):
"""Make dummy annotations for the test."""
namespaces = {}
for keyword, entity in iter_annotation_value_pairs(graph):
namespace = namespaces.get(keyword)
if namespace is None:
graph.annotation_url[keyword] = url = n()... | Make dummy annotations for the test. | Make dummy annotations for the test. | [
"Make",
"dummy",
"annotations",
"for",
"the",
"test",
"."
] | def make_dummy_annotations(manager: Manager, graph: BELGraph):
namespaces = {}
for keyword, entity in iter_annotation_value_pairs(graph):
namespace = namespaces.get(keyword)
if namespace is None:
graph.annotation_url[keyword] = url = n()
namespace = Namespace(keyword=keyw... | [
"def",
"make_dummy_annotations",
"(",
"manager",
":",
"Manager",
",",
"graph",
":",
"BELGraph",
")",
":",
"namespaces",
"=",
"{",
"}",
"for",
"keyword",
",",
"entity",
"in",
"iter_annotation_value_pairs",
"(",
"graph",
")",
":",
"namespace",
"=",
"namespaces",... | Make dummy annotations for the test. | [
"Make",
"dummy",
"annotations",
"for",
"the",
"test",
"."
] | [
"\"\"\"Make dummy annotations for the test.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docst... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | function_table_df | pd.DataFrame | def function_table_df(graph: BELGraph, examples: bool = True) -> pd.DataFrame:
"""Create a dataframe describing the functions in the graph."""
function_mapping = multidict((node.function, node) for node in graph)
function_c = Counter({function: len(nodes) for function, nodes in function_mapping.items()})
... | Create a dataframe describing the functions in the graph. | Create a dataframe describing the functions in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"functions",
"in",
"the",
"graph",
"."
] | def function_table_df(graph: BELGraph, examples: bool = True) -> pd.DataFrame:
function_mapping = multidict((node.function, node) for node in graph)
function_c = Counter({function: len(nodes) for function, nodes in function_mapping.items()})
if not examples:
return pd.DataFrame(function_c.most_commo... | [
"def",
"function_table_df",
"(",
"graph",
":",
"BELGraph",
",",
"examples",
":",
"bool",
"=",
"True",
")",
"->",
"pd",
".",
"DataFrame",
":",
"function_mapping",
"=",
"multidict",
"(",
"(",
"node",
".",
"function",
",",
"node",
")",
"for",
"node",
"in",
... | Create a dataframe describing the functions in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"functions",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Create a dataframe describing the functions in the graph.\"\"\"",
"# noqa:S311"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | functions_str | str | def functions_str(graph, examples: bool = True, add_count: bool = True, **kwargs) -> str:
"""Make a summary string of the functions in the graph."""
df = function_table_df(graph, examples=examples)
headers = list(df.columns)
if add_count:
headers[0] += ' ({})'.format(len(df.index))
return ta... | Make a summary string of the functions in the graph. | Make a summary string of the functions in the graph. | [
"Make",
"a",
"summary",
"string",
"of",
"the",
"functions",
"in",
"the",
"graph",
"."
] | def functions_str(graph, examples: bool = True, add_count: bool = True, **kwargs) -> str:
df = function_table_df(graph, examples=examples)
headers = list(df.columns)
if add_count:
headers[0] += ' ({})'.format(len(df.index))
return tabulate(df.values, headers=headers, **kwargs) | [
"def",
"functions_str",
"(",
"graph",
",",
"examples",
":",
"bool",
"=",
"True",
",",
"add_count",
":",
"bool",
"=",
"True",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"df",
"=",
"function_table_df",
"(",
"graph",
",",
"examples",
"=",
"examples",
")"... | Make a summary string of the functions in the graph. | [
"Make",
"a",
"summary",
"string",
"of",
"the",
"functions",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Make a summary string of the functions in the graph.\"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "examples",
"type": "bool"
},
{
"param": "add_count",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstring_tok... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | namespaces_table_df | pd.DataFrame | def namespaces_table_df(graph: BELGraph, examples: bool = True) -> pd.DataFrame:
"""Create a dataframe describing the namespaces in the graph."""
namespace_mapping = multidict((node.namespace, node) for node in graph if isinstance(node, BaseConcept))
namespace_c = count_namespaces(graph)
if not examples... | Create a dataframe describing the namespaces in the graph. | Create a dataframe describing the namespaces in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"namespaces",
"in",
"the",
"graph",
"."
] | def namespaces_table_df(graph: BELGraph, examples: bool = True) -> pd.DataFrame:
namespace_mapping = multidict((node.namespace, node) for node in graph if isinstance(node, BaseConcept))
namespace_c = count_namespaces(graph)
if not examples:
return pd.DataFrame(namespace_c.most_common(), columns=['Na... | [
"def",
"namespaces_table_df",
"(",
"graph",
":",
"BELGraph",
",",
"examples",
":",
"bool",
"=",
"True",
")",
"->",
"pd",
".",
"DataFrame",
":",
"namespace_mapping",
"=",
"multidict",
"(",
"(",
"node",
".",
"namespace",
",",
"node",
")",
"for",
"node",
"i... | Create a dataframe describing the namespaces in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"namespaces",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Create a dataframe describing the namespaces in the graph.\"\"\"",
"# noqa:S311"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | namespaces_str | None | def namespaces_str(graph: BELGraph, examples: bool = True, add_count: bool = True, **kwargs) -> None:
"""Make a summary string of the namespaces in the graph."""
df = namespaces_table_df(graph, examples=examples)
headers = list(df.columns)
if add_count:
headers[0] += ' ({})'.format(len(df.index)... | Make a summary string of the namespaces in the graph. | Make a summary string of the namespaces in the graph. | [
"Make",
"a",
"summary",
"string",
"of",
"the",
"namespaces",
"in",
"the",
"graph",
"."
] | def namespaces_str(graph: BELGraph, examples: bool = True, add_count: bool = True, **kwargs) -> None:
df = namespaces_table_df(graph, examples=examples)
headers = list(df.columns)
if add_count:
headers[0] += ' ({})'.format(len(df.index))
return tabulate(df.values, headers=headers, **kwargs) | [
"def",
"namespaces_str",
"(",
"graph",
":",
"BELGraph",
",",
"examples",
":",
"bool",
"=",
"True",
",",
"add_count",
":",
"bool",
"=",
"True",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"df",
"=",
"namespaces_table_df",
"(",
"graph",
",",
"examples",
... | Make a summary string of the namespaces in the graph. | [
"Make",
"a",
"summary",
"string",
"of",
"the",
"namespaces",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Make a summary string of the namespaces in the graph.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
},
{
"param": "add_count",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | edge_table_df | pd.DataFrame | def edge_table_df(graph: BELGraph, *, examples: bool = True, minimum: Optional[int] = None) -> pd.DataFrame:
"""Create a dataframe describing the edges in the graph."""
edge_mapping = multidict(
(f'{u.function} {d[RELATION]} {v.function}', graph.edge_to_bel(u, v, d, use_identifiers=True))
for u,... | Create a dataframe describing the edges in the graph. | Create a dataframe describing the edges in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"edges",
"in",
"the",
"graph",
"."
] | def edge_table_df(graph: BELGraph, *, examples: bool = True, minimum: Optional[int] = None) -> pd.DataFrame:
edge_mapping = multidict(
(f'{u.function} {d[RELATION]} {v.function}', graph.edge_to_bel(u, v, d, use_identifiers=True))
for u, v, d in graph.edges(data=True)
if d[RELATION] not in TW... | [
"def",
"edge_table_df",
"(",
"graph",
":",
"BELGraph",
",",
"*",
",",
"examples",
":",
"bool",
"=",
"True",
",",
"minimum",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"pd",
".",
"DataFrame",
":",
"edge_mapping",
"=",
"multidict",
"(",
... | Create a dataframe describing the edges in the graph. | [
"Create",
"a",
"dataframe",
"describing",
"the",
"edges",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Create a dataframe describing the edges in the graph.\"\"\"",
"# noqa:S311"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
},
{
"param": "minimum",
"type": "Optional[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | edges_str | str | def edges_str(
graph: BELGraph,
*,
examples: bool = True,
add_count: bool = True,
minimum: Optional[int] = None,
**kwargs,
) -> str:
"""Make a summary str of the edges in the graph."""
df = edge_table_df(graph, examples=examples, minimum=minimum)
headers = list(df.columns)
if add... | Make a summary str of the edges in the graph. | Make a summary str of the edges in the graph. | [
"Make",
"a",
"summary",
"str",
"of",
"the",
"edges",
"in",
"the",
"graph",
"."
] | def edges_str(
graph: BELGraph,
*,
examples: bool = True,
add_count: bool = True,
minimum: Optional[int] = None,
**kwargs,
) -> str:
df = edge_table_df(graph, examples=examples, minimum=minimum)
headers = list(df.columns)
if add_count:
headers[0] += ' ({})'.format(intword(len... | [
"def",
"edges_str",
"(",
"graph",
":",
"BELGraph",
",",
"*",
",",
"examples",
":",
"bool",
"=",
"True",
",",
"add_count",
":",
"bool",
"=",
"True",
",",
"minimum",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"**",
"kwargs",
",",
")",
"->",
... | Make a summary str of the edges in the graph. | [
"Make",
"a",
"summary",
"str",
"of",
"the",
"edges",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Make a summary str of the edges in the graph.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
},
{
"param": "add_count",
"type": "bool"
},
{
"param": "minimum",
"type": "Optional[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | edges | None | def edges(
graph: BELGraph,
*,
examples: bool = True,
minimum: Optional[int] = None,
file: Optional[TextIO] = None,
**kwargs,
) -> None:
"""Print a summary of the edges in the graph."""
print(edges_str(graph=graph, examples=examples, minimum=minimum, **kwargs), file=file) | Print a summary of the edges in the graph. | Print a summary of the edges in the graph. | [
"Print",
"a",
"summary",
"of",
"the",
"edges",
"in",
"the",
"graph",
"."
] | def edges(
graph: BELGraph,
*,
examples: bool = True,
minimum: Optional[int] = None,
file: Optional[TextIO] = None,
**kwargs,
) -> None:
print(edges_str(graph=graph, examples=examples, minimum=minimum, **kwargs), file=file) | [
"def",
"edges",
"(",
"graph",
":",
"BELGraph",
",",
"*",
",",
"examples",
":",
"bool",
"=",
"True",
",",
"minimum",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"file",
":",
"Optional",
"[",
"TextIO",
"]",
"=",
"None",
",",
"**",
"kwargs",
... | Print a summary of the edges in the graph. | [
"Print",
"a",
"summary",
"of",
"the",
"edges",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Print a summary of the edges in the graph.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "examples",
"type": "bool"
},
{
"param": "minimum",
"type": "Optional[int]"
},
{
"param": "file",
"type": "Optional[TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "examples",
"type": "bool",
"docstring": null,
"docstri... |
dc03ab99c43db7428a177236d6b84c8328d2839d | rpatil524/pybel | src/pybel/struct/summary/supersummary.py | [
"MIT"
] | Python | citations | None | def citations(graph: BELGraph, n: Optional[int] = 15, file: Optional[TextIO] = None) -> None:
"""Print a summary of the citations in the graph."""
edge_mapping = multidict(
((data[CITATION][NAMESPACE], data[CITATION][IDENTIFIER]), graph.edge_to_bel(u, v, data))
for u, v, data in graph.edges(data... | Print a summary of the citations in the graph. | Print a summary of the citations in the graph. | [
"Print",
"a",
"summary",
"of",
"the",
"citations",
"in",
"the",
"graph",
"."
] | def citations(graph: BELGraph, n: Optional[int] = 15, file: Optional[TextIO] = None) -> None:
edge_mapping = multidict(
((data[CITATION][NAMESPACE], data[CITATION][IDENTIFIER]), graph.edge_to_bel(u, v, data))
for u, v, data in graph.edges(data=True)
if CITATION in data
)
edge_c = Cou... | [
"def",
"citations",
"(",
"graph",
":",
"BELGraph",
",",
"n",
":",
"Optional",
"[",
"int",
"]",
"=",
"15",
",",
"file",
":",
"Optional",
"[",
"TextIO",
"]",
"=",
"None",
")",
"->",
"None",
":",
"edge_mapping",
"=",
"multidict",
"(",
"(",
"(",
"data"... | Print a summary of the citations in the graph. | [
"Print",
"a",
"summary",
"of",
"the",
"citations",
"in",
"the",
"graph",
"."
] | [
"\"\"\"Print a summary of the citations in the graph.\"\"\"",
"# noqa:S311"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "n",
"type": "Optional[int]"
},
{
"param": "file",
"type": "Optional[TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": "Optional[int]",
"docstring": null,
"docst... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | md5 | str | def md5(self) -> str:
"""Get the MD5 hash of this node."""
if self._md5 is None:
self._md5 = hashlib.md5(self.as_bel().encode('utf8')).hexdigest() # noqa: S303
return self._md5 | Get the MD5 hash of this node. | Get the MD5 hash of this node. | [
"Get",
"the",
"MD5",
"hash",
"of",
"this",
"node",
"."
] | def md5(self) -> str:
if self._md5 is None:
self._md5 = hashlib.md5(self.as_bel().encode('utf8')).hexdigest()
return self._md5 | [
"def",
"md5",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_md5",
"is",
"None",
":",
"self",
".",
"_md5",
"=",
"hashlib",
".",
"md5",
"(",
"self",
".",
"as_bel",
"(",
")",
".",
"encode",
"(",
"'utf8'",
")",
")",
".",
"hexdigest",
"("... | Get the MD5 hash of this node. | [
"Get",
"the",
"MD5",
"hash",
"of",
"this",
"node",
"."
] | [
"\"\"\"Get the MD5 hash of this node.\"\"\"",
"# noqa: S303"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | safe_label | str | def safe_label(self) -> str:
"""Get the safe label for the node (name or BEL)."""
if isinstance(self, CentralDogma) and self.variants:
return self.as_bel()
if isinstance(self, BaseConcept):
return self.curie
return self.as_bel() | Get the safe label for the node (name or BEL). | Get the safe label for the node (name or BEL). | [
"Get",
"the",
"safe",
"label",
"for",
"the",
"node",
"(",
"name",
"or",
"BEL",
")",
"."
] | def safe_label(self) -> str:
if isinstance(self, CentralDogma) and self.variants:
return self.as_bel()
if isinstance(self, BaseConcept):
return self.curie
return self.as_bel() | [
"def",
"safe_label",
"(",
"self",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"self",
",",
"CentralDogma",
")",
"and",
"self",
".",
"variants",
":",
"return",
"self",
".",
"as_bel",
"(",
")",
"if",
"isinstance",
"(",
"self",
",",
"BaseConcept",
")"... | Get the safe label for the node (name or BEL). | [
"Get",
"the",
"safe",
"label",
"for",
"the",
"node",
"(",
"name",
"or",
"BEL",
")",
"."
] | [
"\"\"\"Get the safe label for the node (name or BEL).\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this node as a BEL string."""
return "{}({})".format(
self._bel_function,
self.obo if use_identifiers and self.entity.identifier and self.entity.name else self.curie,
) | Return this node as a BEL string. | Return this node as a BEL string. | [
"Return",
"this",
"node",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
return "{}({})".format(
self._bel_function,
self.obo if use_identifiers and self.entity.identifier and self.entity.name else self.curie,
) | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"\"{}({})\"",
".",
"format",
"(",
"self",
".",
"_bel_function",
",",
"self",
".",
"obo",
"if",
"use_identifiers",
"and",
"self",
".",
"entity... | Return this node as a BEL string. | [
"Return",
"this",
"node",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this node as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this node as a BEL string."""
if not self.variants:
return super().as_bel(use_identifiers=use_identifiers)
variants_canon = sorted([
variant.as_bel(use_identifiers=use_identifiers)
for variant i... | Return this node as a BEL string. | Return this node as a BEL string. | [
"Return",
"this",
"node",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
if not self.variants:
return super().as_bel(use_identifiers=use_identifiers)
variants_canon = sorted([
variant.as_bel(use_identifiers=use_identifiers)
for variant in self.variants
])
return "{}({},... | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"variants",
":",
"return",
"super",
"(",
")",
".",
"as_bel",
"(",
"use_identifiers",
"=",
"use_identifiers",
")",
"variants_c... | Return this node as a BEL string. | [
"Return",
"this",
"node",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this node as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | with_variants | 'CentralDogma' | def with_variants(self, variants: Union[Variant, List[Variant]]) -> 'CentralDogma':
"""Create a new entity with the given variants.
:param variants: An optional variant or list of variants
>>> from pybel.dsl import Protein, Fragment
>>> app = Protein(name='APP', namespace='HGNC')
... | Create a new entity with the given variants.
:param variants: An optional variant or list of variants
>>> from pybel.dsl import Protein, Fragment
>>> app = Protein(name='APP', namespace='HGNC')
>>> ab42 = app.with_variants([Fragment(start=672, stop=713)])
>>> assert 'p(HGNC:APP... | Create a new entity with the given variants. | [
"Create",
"a",
"new",
"entity",
"with",
"the",
"given",
"variants",
"."
] | def with_variants(self, variants: Union[Variant, List[Variant]]) -> 'CentralDogma':
return self.__class__(
namespace=self.namespace,
name=self.name,
identifier=self.identifier,
xrefs=self.xrefs,
variants=variants,
) | [
"def",
"with_variants",
"(",
"self",
",",
"variants",
":",
"Union",
"[",
"Variant",
",",
"List",
"[",
"Variant",
"]",
"]",
")",
"->",
"'CentralDogma'",
":",
"return",
"self",
".",
"__class__",
"(",
"namespace",
"=",
"self",
".",
"namespace",
",",
"name",... | Create a new entity with the given variants. | [
"Create",
"a",
"new",
"entity",
"with",
"the",
"given",
"variants",
"."
] | [
"\"\"\"Create a new entity with the given variants.\n\n :param variants: An optional variant or list of variants\n\n >>> from pybel.dsl import Protein, Fragment\n >>> app = Protein(name='APP', namespace='HGNC')\n >>> ab42 = app.with_variants([Fragment(start=672, stop=713)])\n >>> ... | [
{
"param": "self",
"type": null
},
{
"param": "variants",
"type": "Union[Variant, List[Variant]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "variants",
"type": "Union[Variant, List[Variant]]",
"docstring": "A... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this protein modification variant as a BEL string."""
if use_identifiers and self.entity.identifier and self.entity.name:
x = self.entity.obo
else:
x = self.entity.curie
return 'pmod({}{})'.format(
... | Return this protein modification variant as a BEL string. | Return this protein modification variant as a BEL string. | [
"Return",
"this",
"protein",
"modification",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
if use_identifiers and self.entity.identifier and self.entity.name:
x = self.entity.obo
else:
x = self.entity.curie
return 'pmod({}{})'.format(
x,
''.join(', {}'.format(self[x]) for x in PMOD_O... | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"use_identifiers",
"and",
"self",
".",
"entity",
".",
"identifier",
"and",
"self",
".",
"entity",
".",
"name",
":",
"x",
"=",
"self",
".",
"e... | Return this protein modification variant as a BEL string. | [
"Return",
"this",
"protein",
"modification",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this protein modification variant as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this gene modification variant as a BEL string."""
if use_identifiers and self.entity.identifier and self.entity.name:
x = self.entity.obo
else:
x = self.entity.curie
return 'gmod({})'.format(x) | Return this gene modification variant as a BEL string. | Return this gene modification variant as a BEL string. | [
"Return",
"this",
"gene",
"modification",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
if use_identifiers and self.entity.identifier and self.entity.name:
x = self.entity.obo
else:
x = self.entity.curie
return 'gmod({})'.format(x) | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"use_identifiers",
"and",
"self",
".",
"entity",
".",
"identifier",
"and",
"self",
".",
"entity",
".",
"name",
":",
"x",
"=",
"self",
".",
"e... | Return this gene modification variant as a BEL string. | [
"Return",
"this",
"gene",
"modification",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this gene modification variant as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | range | str | def range(self) -> str:
"""Get the range of this fragment."""
if FRAGMENT_MISSING in self:
return '?'
return '{}_{}'.format(self[FRAGMENT_START], self[FRAGMENT_STOP]) | Get the range of this fragment. | Get the range of this fragment. | [
"Get",
"the",
"range",
"of",
"this",
"fragment",
"."
] | def range(self) -> str:
if FRAGMENT_MISSING in self:
return '?'
return '{}_{}'.format(self[FRAGMENT_START], self[FRAGMENT_STOP]) | [
"def",
"range",
"(",
"self",
")",
"->",
"str",
":",
"if",
"FRAGMENT_MISSING",
"in",
"self",
":",
"return",
"'?'",
"return",
"'{}_{}'",
".",
"format",
"(",
"self",
"[",
"FRAGMENT_START",
"]",
",",
"self",
"[",
"FRAGMENT_STOP",
"]",
")"
] | Get the range of this fragment. | [
"Get",
"the",
"range",
"of",
"this",
"fragment",
"."
] | [
"\"\"\"Get the range of this fragment.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers=False) -> str:
"""Return this fragment variant as a BEL string."""
res = '"{}"'.format(self.range)
if FRAGMENT_DESCRIPTION in self:
res += ', "{}"'.format(self[FRAGMENT_DESCRIPTION])
return 'frag({})'.format(res) | Return this fragment variant as a BEL string. | Return this fragment variant as a BEL string. | [
"Return",
"this",
"fragment",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers=False) -> str:
res = '"{}"'.format(self.range)
if FRAGMENT_DESCRIPTION in self:
res += ', "{}"'.format(self[FRAGMENT_DESCRIPTION])
return 'frag({})'.format(res) | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
"=",
"False",
")",
"->",
"str",
":",
"res",
"=",
"'\"{}\"'",
".",
"format",
"(",
"self",
".",
"range",
")",
"if",
"FRAGMENT_DESCRIPTION",
"in",
"self",
":",
"res",
"+=",
"', \"{}\"'",
".",
"format",
... | Return this fragment variant as a BEL string. | [
"Return",
"this",
"fragment",
"variant",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this fragment variant as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": null,
"docstring": null,
"docstring... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | _entity_list_as_bel | str | def _entity_list_as_bel(entities: Iterable[BaseEntity], use_identifiers: bool = True) -> str:
"""Stringify a list of BEL entities."""
return ', '.join(
e.as_bel(use_identifiers=use_identifiers)
for e in entities
) | Stringify a list of BEL entities. | Stringify a list of BEL entities. | [
"Stringify",
"a",
"list",
"of",
"BEL",
"entities",
"."
] | def _entity_list_as_bel(entities: Iterable[BaseEntity], use_identifiers: bool = True) -> str:
return ', '.join(
e.as_bel(use_identifiers=use_identifiers)
for e in entities
) | [
"def",
"_entity_list_as_bel",
"(",
"entities",
":",
"Iterable",
"[",
"BaseEntity",
"]",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"', '",
".",
"join",
"(",
"e",
".",
"as_bel",
"(",
"use_identifiers",
"=",
"use_ident... | Stringify a list of BEL entities. | [
"Stringify",
"a",
"list",
"of",
"BEL",
"entities",
"."
] | [
"\"\"\"Stringify a list of BEL entities.\"\"\""
] | [
{
"param": "entities",
"type": "Iterable[BaseEntity]"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "entities",
"type": "Iterable[BaseEntity]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring"... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this reaction as a BEL string."""
return 'rxn(reactants({}), products({}))'.format(
_entity_list_as_bel(self.reactants, use_identifiers=use_identifiers),
_entity_list_as_bel(self.products, use_identifiers=use_identi... | Return this reaction as a BEL string. | Return this reaction as a BEL string. | [
"Return",
"this",
"reaction",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
return 'rxn(reactants({}), products({}))'.format(
_entity_list_as_bel(self.reactants, use_identifiers=use_identifiers),
_entity_list_as_bel(self.products, use_identifiers=use_identifiers),
) | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"'rxn(reactants({}), products({}))'",
".",
"format",
"(",
"_entity_list_as_bel",
"(",
"self",
".",
"reactants",
",",
"use_identifiers",
"=",
"use_ide... | Return this reaction as a BEL string. | [
"Return",
"this",
"reaction",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this reaction as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this list abundance as a BEL string."""
return '{}({})'.format(
self._bel_function,
_entity_list_as_bel(self.members, use_identifiers=use_identifiers),
) | Return this list abundance as a BEL string. | Return this list abundance as a BEL string. | [
"Return",
"this",
"list",
"abundance",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
return '{}({})'.format(
self._bel_function,
_entity_list_as_bel(self.members, use_identifiers=use_identifiers),
) | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"return",
"'{}({})'",
".",
"format",
"(",
"self",
".",
"_bel_function",
",",
"_entity_list_as_bel",
"(",
"self",
".",
"members",
",",
"use_identifiers",
... | Return this list abundance as a BEL string. | [
"Return",
"this",
"list",
"abundance",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this list abundance as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self) -> str:
"""Return this fusion range as a BEL string."""
return '{reference}.{start}_{stop}'.format(
reference=self[FUSION_REFERENCE],
start=self[FUSION_START],
stop=self[FUSION_STOP],
) | Return this fusion range as a BEL string. | Return this fusion range as a BEL string. | [
"Return",
"this",
"fusion",
"range",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self) -> str:
return '{reference}.{start}_{stop}'.format(
reference=self[FUSION_REFERENCE],
start=self[FUSION_START],
stop=self[FUSION_STOP],
) | [
"def",
"as_bel",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'{reference}.{start}_{stop}'",
".",
"format",
"(",
"reference",
"=",
"self",
"[",
"FUSION_REFERENCE",
"]",
",",
"start",
"=",
"self",
"[",
"FUSION_START",
"]",
",",
"stop",
"=",
"self",
"[",
... | Return this fusion range as a BEL string. | [
"Return",
"this",
"fusion",
"range",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this fusion range as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5d18410717233daf8364ba83e2b6c8060ce02fcc | rpatil524/pybel | src/pybel/dsl/node_classes.py | [
"MIT"
] | Python | as_bel | str | def as_bel(self, use_identifiers: bool = True) -> str:
"""Return this fusion as a BEL string."""
if use_identifiers and self.partner_3p.entity.identifier and self.partner_3p.entity.name:
p3p = self.partner_3p.obo
else:
p3p = self.partner_3p.curie
if use_identifie... | Return this fusion as a BEL string. | Return this fusion as a BEL string. | [
"Return",
"this",
"fusion",
"as",
"a",
"BEL",
"string",
"."
] | def as_bel(self, use_identifiers: bool = True) -> str:
if use_identifiers and self.partner_3p.entity.identifier and self.partner_3p.entity.name:
p3p = self.partner_3p.obo
else:
p3p = self.partner_3p.curie
if use_identifiers and self.partner_5p.entity.identifier and self.p... | [
"def",
"as_bel",
"(",
"self",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"use_identifiers",
"and",
"self",
".",
"partner_3p",
".",
"entity",
".",
"identifier",
"and",
"self",
".",
"partner_3p",
".",
"entity",
".",
"nam... | Return this fusion as a BEL string. | [
"Return",
"this",
"fusion",
"as",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Return this fusion as a BEL string.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
"docstri... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | compile | null | def compile(
manager, path, allow_naked_names, disallow_nested, disallow_unqualified_translocations,
no_identifier_validation, no_citation_clearing, required_annotations, upgrade_urls, skip_tqdm,
):
"""Compile a BEL script to a graph."""
logger.debug('using connection: %s', manager.engine.url)
clic... | Compile a BEL script to a graph. | Compile a BEL script to a graph. | [
"Compile",
"a",
"BEL",
"script",
"to",
"a",
"graph",
"."
] | def compile(
manager, path, allow_naked_names, disallow_nested, disallow_unqualified_translocations,
no_identifier_validation, no_citation_clearing, required_annotations, upgrade_urls, skip_tqdm,
):
logger.debug('using connection: %s', manager.engine.url)
click.secho('Compilation', fg='red', bold=True)
... | [
"def",
"compile",
"(",
"manager",
",",
"path",
",",
"allow_naked_names",
",",
"disallow_nested",
",",
"disallow_unqualified_translocations",
",",
"no_identifier_validation",
",",
"no_citation_clearing",
",",
"required_annotations",
",",
"upgrade_urls",
",",
"skip_tqdm",
"... | Compile a BEL script to a graph. | [
"Compile",
"a",
"BEL",
"script",
"to",
"a",
"graph",
"."
] | [
"\"\"\"Compile a BEL script to a graph.\"\"\""
] | [
{
"param": "manager",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "allow_naked_names",
"type": null
},
{
"param": "disallow_nested",
"type": null
},
{
"param": "disallow_unqualified_translocations",
"type": null
},
{
"param": "no_iden... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens"... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | upload | null | def upload(graph: BELGraph, host: str, user: str, password: str):
"""Upload a graph to BEL Commons."""
resp = to_bel_commons(graph, host=host, user=user, password=password)
resp.raise_for_status()
click.echo(json.dumps(resp.json())) | Upload a graph to BEL Commons. | Upload a graph to BEL Commons. | [
"Upload",
"a",
"graph",
"to",
"BEL",
"Commons",
"."
] | def upload(graph: BELGraph, host: str, user: str, password: str):
resp = to_bel_commons(graph, host=host, user=user, password=password)
resp.raise_for_status()
click.echo(json.dumps(resp.json())) | [
"def",
"upload",
"(",
"graph",
":",
"BELGraph",
",",
"host",
":",
"str",
",",
"user",
":",
"str",
",",
"password",
":",
"str",
")",
":",
"resp",
"=",
"to_bel_commons",
"(",
"graph",
",",
"host",
"=",
"host",
",",
"user",
"=",
"user",
",",
"password... | Upload a graph to BEL Commons. | [
"Upload",
"a",
"graph",
"to",
"BEL",
"Commons",
"."
] | [
"\"\"\"Upload a graph to BEL Commons.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "host",
"type": "str"
},
{
"param": "user",
"type": "str"
},
{
"param": "password",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "host",
"type": "str",
"docstring": null,
"docstring_to... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | serialize | null | def serialize(graph: BELGraph, tsv, edgelist, sif, gsea, graphml, nodelink, bel):
"""Serialize a graph to various formats."""
if tsv:
logger.info('Outputting TSV to %s', tsv)
to_triples_file(graph, tsv)
if edgelist:
logger.info('Outputting edgelist to %s', edgelist)
to_edgel... | Serialize a graph to various formats. | Serialize a graph to various formats. | [
"Serialize",
"a",
"graph",
"to",
"various",
"formats",
"."
] | def serialize(graph: BELGraph, tsv, edgelist, sif, gsea, graphml, nodelink, bel):
if tsv:
logger.info('Outputting TSV to %s', tsv)
to_triples_file(graph, tsv)
if edgelist:
logger.info('Outputting edgelist to %s', edgelist)
to_edgelist(graph, edgelist)
if sif:
logger.i... | [
"def",
"serialize",
"(",
"graph",
":",
"BELGraph",
",",
"tsv",
",",
"edgelist",
",",
"sif",
",",
"gsea",
",",
"graphml",
",",
"nodelink",
",",
"bel",
")",
":",
"if",
"tsv",
":",
"logger",
".",
"info",
"(",
"'Outputting TSV to %s'",
",",
"tsv",
")",
"... | Serialize a graph to various formats. | [
"Serialize",
"a",
"graph",
"to",
"various",
"formats",
"."
] | [
"\"\"\"Serialize a graph to various formats.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "tsv",
"type": null
},
{
"param": "edgelist",
"type": null
},
{
"param": "sif",
"type": null
},
{
"param": "gsea",
"type": null
},
{
"param": "graphml",
"type": null
},
{
"param": "nodeli... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tsv",
"type": null,
"docstring": null,
"docstring_toke... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | machine | null | def machine(manager: Manager, agents: List[str], local: bool, host: str):
"""Get content from the INDRA machine and upload to BEL Commons."""
from indra.sources import indra_db_rest
from pybel import from_indra_statements
statements = indra_db_rest.get_statements(agents=agents)
click.echo('got {} s... | Get content from the INDRA machine and upload to BEL Commons. | Get content from the INDRA machine and upload to BEL Commons. | [
"Get",
"content",
"from",
"the",
"INDRA",
"machine",
"and",
"upload",
"to",
"BEL",
"Commons",
"."
] | def machine(manager: Manager, agents: List[str], local: bool, host: str):
from indra.sources import indra_db_rest
from pybel import from_indra_statements
statements = indra_db_rest.get_statements(agents=agents)
click.echo('got {} statements from INDRA'.format(len(statements)))
graph = from_indra_sta... | [
"def",
"machine",
"(",
"manager",
":",
"Manager",
",",
"agents",
":",
"List",
"[",
"str",
"]",
",",
"local",
":",
"bool",
",",
"host",
":",
"str",
")",
":",
"from",
"indra",
".",
"sources",
"import",
"indra_db_rest",
"from",
"pybel",
"import",
"from_in... | Get content from the INDRA machine and upload to BEL Commons. | [
"Get",
"content",
"from",
"the",
"INDRA",
"machine",
"and",
"upload",
"to",
"BEL",
"Commons",
"."
] | [
"\"\"\"Get content from the INDRA machine and upload to BEL Commons.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "agents",
"type": "List[str]"
},
{
"param": "local",
"type": "bool"
},
{
"param": "host",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "agents",
"type": "List[str]",
"docstring": null,
"doc... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | examples | null | def examples(manager: Manager, debug: bool):
"""Load examples to the database."""
level = logging.DEBUG if debug else logging.INFO
logging.basicConfig(level=level)
logging.getLogger('pybel').setLevel(level)
for graph in (sialic_acid_graph, statin_graph, homology_graph, braf_graph, egf_graph):
... | Load examples to the database. | Load examples to the database. | [
"Load",
"examples",
"to",
"the",
"database",
"."
] | def examples(manager: Manager, debug: bool):
level = logging.DEBUG if debug else logging.INFO
logging.basicConfig(level=level)
logging.getLogger('pybel').setLevel(level)
for graph in (sialic_acid_graph, statin_graph, homology_graph, braf_graph, egf_graph):
if manager.has_name_version(graph.name,... | [
"def",
"examples",
"(",
"manager",
":",
"Manager",
",",
"debug",
":",
"bool",
")",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"if",
"debug",
"else",
"logging",
".",
"INFO",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"level",
")",
"logging",
"."... | Load examples to the database. | [
"Load",
"examples",
"to",
"the",
"database",
"."
] | [
"\"\"\"Load examples to the database.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "debug",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "debug",
"type": "bool",
"docstring": null,
"docstring... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | drop | null | def drop(manager: Manager, network_id: Optional[int], yes):
"""Drop a network by its identifier or drop all networks."""
if network_id:
manager.drop_network_by_id(network_id)
elif yes or click.confirm('Drop all networks?'):
manager.drop_networks() | Drop a network by its identifier or drop all networks. | Drop a network by its identifier or drop all networks. | [
"Drop",
"a",
"network",
"by",
"its",
"identifier",
"or",
"drop",
"all",
"networks",
"."
] | def drop(manager: Manager, network_id: Optional[int], yes):
if network_id:
manager.drop_network_by_id(network_id)
elif yes or click.confirm('Drop all networks?'):
manager.drop_networks() | [
"def",
"drop",
"(",
"manager",
":",
"Manager",
",",
"network_id",
":",
"Optional",
"[",
"int",
"]",
",",
"yes",
")",
":",
"if",
"network_id",
":",
"manager",
".",
"drop_network_by_id",
"(",
"network_id",
")",
"elif",
"yes",
"or",
"click",
".",
"confirm",... | Drop a network by its identifier or drop all networks. | [
"Drop",
"a",
"network",
"by",
"its",
"identifier",
"or",
"drop",
"all",
"networks",
"."
] | [
"\"\"\"Drop a network by its identifier or drop all networks.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "network_id",
"type": "Optional[int]"
},
{
"param": "yes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "network_id",
"type": "Optional[int]",
"docstring": null,
... |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | prune | null | def prune(manager: Manager):
"""Prune nodes not belonging to any edges."""
nodes_to_delete = [
node
for node in tqdm(manager.session.query(Node), total=manager.count_nodes())
if not node.networks
]
manager.session.delete(nodes_to_delete)
manager.session.commit() | Prune nodes not belonging to any edges. | Prune nodes not belonging to any edges. | [
"Prune",
"nodes",
"not",
"belonging",
"to",
"any",
"edges",
"."
] | def prune(manager: Manager):
nodes_to_delete = [
node
for node in tqdm(manager.session.query(Node), total=manager.count_nodes())
if not node.networks
]
manager.session.delete(nodes_to_delete)
manager.session.commit() | [
"def",
"prune",
"(",
"manager",
":",
"Manager",
")",
":",
"nodes_to_delete",
"=",
"[",
"node",
"for",
"node",
"in",
"tqdm",
"(",
"manager",
".",
"session",
".",
"query",
"(",
"Node",
")",
",",
"total",
"=",
"manager",
".",
"count_nodes",
"(",
")",
")... | Prune nodes not belonging to any edges. | [
"Prune",
"nodes",
"not",
"belonging",
"to",
"any",
"edges",
"."
] | [
"\"\"\"Prune nodes not belonging to any edges.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | summarize | null | def summarize(manager: Manager):
"""Summarize the contents of the database."""
click.echo('Networks: {}'.format(manager.count_networks()))
click.echo('Edges: {}'.format(manager.count_edges()))
click.echo('Nodes: {}'.format(manager.count_nodes()))
click.echo('Namespaces: {}'.format(manager.count_name... | Summarize the contents of the database. | Summarize the contents of the database. | [
"Summarize",
"the",
"contents",
"of",
"the",
"database",
"."
] | def summarize(manager: Manager):
click.echo('Networks: {}'.format(manager.count_networks()))
click.echo('Edges: {}'.format(manager.count_edges()))
click.echo('Nodes: {}'.format(manager.count_nodes()))
click.echo('Namespaces: {}'.format(manager.count_namespaces()))
click.echo('Namespaces entries: {}'... | [
"def",
"summarize",
"(",
"manager",
":",
"Manager",
")",
":",
"click",
".",
"echo",
"(",
"'Networks: {}'",
".",
"format",
"(",
"manager",
".",
"count_networks",
"(",
")",
")",
")",
"click",
".",
"echo",
"(",
"'Edges: {}'",
".",
"format",
"(",
"manager",
... | Summarize the contents of the database. | [
"Summarize",
"the",
"contents",
"of",
"the",
"database",
"."
] | [
"\"\"\"Summarize the contents of the database.\"\"\""
] | [
{
"param": "manager",
"type": "Manager"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cb5265eca0c5b2997d0c6132edb3587fcc9b4d32 | rpatil524/pybel | src/pybel/cli.py | [
"MIT"
] | Python | echo_warnings_via_pager | None | def echo_warnings_via_pager(warnings: List[WarningTuple], sep: str = '\t') -> None:
"""Output the warnings from a BEL graph with Click and the system's pager."""
# Exit if no warnings
if not warnings:
click.echo('Congratulations! No warnings.')
sys.exit(0)
max_line_width = max(
... | Output the warnings from a BEL graph with Click and the system's pager. | Output the warnings from a BEL graph with Click and the system's pager. | [
"Output",
"the",
"warnings",
"from",
"a",
"BEL",
"graph",
"with",
"Click",
"and",
"the",
"system",
"'",
"s",
"pager",
"."
] | def echo_warnings_via_pager(warnings: List[WarningTuple], sep: str = '\t') -> None:
if not warnings:
click.echo('Congratulations! No warnings.')
sys.exit(0)
max_line_width = max(
len(str(exc.line_number))
for _, exc, _ in warnings
)
max_warning_width = max(
len(ex... | [
"def",
"echo_warnings_via_pager",
"(",
"warnings",
":",
"List",
"[",
"WarningTuple",
"]",
",",
"sep",
":",
"str",
"=",
"'\\t'",
")",
"->",
"None",
":",
"if",
"not",
"warnings",
":",
"click",
".",
"echo",
"(",
"'Congratulations! No warnings.'",
")",
"sys",
... | Output the warnings from a BEL graph with Click and the system's pager. | [
"Output",
"the",
"warnings",
"from",
"a",
"BEL",
"graph",
"with",
"Click",
"and",
"the",
"system",
"'",
"s",
"pager",
"."
] | [
"\"\"\"Output the warnings from a BEL graph with Click and the system's pager.\"\"\"",
"# Exit if no warnings"
] | [
{
"param": "warnings",
"type": "List[WarningTuple]"
},
{
"param": "sep",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "warnings",
"type": "List[WarningTuple]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sep",
"type": "str",
"docstring": null,
"... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | to_json | Mapping[str, str] | def to_json(self, include_id: bool = False) -> Mapping[str, str]:
"""Return the most useful entries as a dictionary.
:param include_id: If true, includes the model identifier
"""
result = {
'keyword': self.keyword,
'name': self.name,
'version'... | Return the most useful entries as a dictionary.
:param include_id: If true, includes the model identifier
| Return the most useful entries as a dictionary. | [
"Return",
"the",
"most",
"useful",
"entries",
"as",
"a",
"dictionary",
"."
] | def to_json(self, include_id: bool = False) -> Mapping[str, str]:
result = {
'keyword': self.keyword,
'name': self.name,
'version': self.version,
}
if self.url:
result['url'] = self.url
else:
result['pattern'] = self.pattern
... | [
"def",
"to_json",
"(",
"self",
",",
"include_id",
":",
"bool",
"=",
"False",
")",
"->",
"Mapping",
"[",
"str",
",",
"str",
"]",
":",
"result",
"=",
"{",
"'keyword'",
":",
"self",
".",
"keyword",
",",
"'name'",
":",
"self",
".",
"name",
",",
"'versi... | Return the most useful entries as a dictionary. | [
"Return",
"the",
"most",
"useful",
"entries",
"as",
"a",
"dictionary",
"."
] | [
"\"\"\"Return the most useful entries as a dictionary.\r\n\r\n :param include_id: If true, includes the model identifier\r\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "include_id",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_id",
"type": "bool",
"docstring": "If true, includes the mo... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | to_json | Mapping[str, str] | def to_json(self, include_id: bool = False) -> Mapping[str, str]:
"""Describe the namespaceEntry as dictionary of Namespace-Keyword and Name.
:param include_id: If true, includes the model identifier
"""
result = {
NAMESPACE: self.namespace.keyword,
}
... | Describe the namespaceEntry as dictionary of Namespace-Keyword and Name.
:param include_id: If true, includes the model identifier
| Describe the namespaceEntry as dictionary of Namespace-Keyword and Name. | [
"Describe",
"the",
"namespaceEntry",
"as",
"dictionary",
"of",
"Namespace",
"-",
"Keyword",
"and",
"Name",
"."
] | def to_json(self, include_id: bool = False) -> Mapping[str, str]:
result = {
NAMESPACE: self.namespace.keyword,
}
if self.name:
result[NAME] = self.name
if self.identifier:
result[IDENTIFIER] = self.identifier
if include_id:
result[... | [
"def",
"to_json",
"(",
"self",
",",
"include_id",
":",
"bool",
"=",
"False",
")",
"->",
"Mapping",
"[",
"str",
",",
"str",
"]",
":",
"result",
"=",
"{",
"NAMESPACE",
":",
"self",
".",
"namespace",
".",
"keyword",
",",
"}",
"if",
"self",
".",
"name"... | Describe the namespaceEntry as dictionary of Namespace-Keyword and Name. | [
"Describe",
"the",
"namespaceEntry",
"as",
"dictionary",
"of",
"Namespace",
"-",
"Keyword",
"and",
"Name",
"."
] | [
"\"\"\"Describe the namespaceEntry as dictionary of Namespace-Keyword and Name.\r\n\r\n :param include_id: If true, includes the model identifier\r\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "include_id",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_id",
"type": "bool",
"docstring": "If true, includes the mo... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | to_json | Mapping[str, Any] | def to_json(self, include_id: bool = False) -> Mapping[str, Any]:
"""Return this network as JSON.
:param include_id: If true, includes the model identifier
"""
result = {
METADATA_NAME: self.name,
METADATA_VERSION: self.version,
}
if se... | Return this network as JSON.
:param include_id: If true, includes the model identifier
| Return this network as JSON. | [
"Return",
"this",
"network",
"as",
"JSON",
"."
] | def to_json(self, include_id: bool = False) -> Mapping[str, Any]:
result = {
METADATA_NAME: self.name,
METADATA_VERSION: self.version,
}
if self.created:
result['created'] = str(self.created)
if include_id:
result['id'] = self.id
if... | [
"def",
"to_json",
"(",
"self",
",",
"include_id",
":",
"bool",
"=",
"False",
")",
"->",
"Mapping",
"[",
"str",
",",
"Any",
"]",
":",
"result",
"=",
"{",
"METADATA_NAME",
":",
"self",
".",
"name",
",",
"METADATA_VERSION",
":",
"self",
".",
"version",
... | Return this network as JSON. | [
"Return",
"this",
"network",
"as",
"JSON",
"."
] | [
"\"\"\"Return this network as JSON.\r\n\r\n :param include_id: If true, includes the model identifier\r\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "include_id",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_id",
"type": "bool",
"docstring": "If true, includes the mo... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | _start_from_base_entity | 'Node' | def _start_from_base_entity(base_entity) -> 'Node':
"""Convert a base entity to a node model.
:type base_entity: pybel.dsl.BaseEntity
"""
return Node(
type=base_entity.function,
bel=base_entity.as_bel(),
md5=base_entity.md5,
data=... | Convert a base entity to a node model.
:type base_entity: pybel.dsl.BaseEntity
| Convert a base entity to a node model. | [
"Convert",
"a",
"base",
"entity",
"to",
"a",
"node",
"model",
"."
] | def _start_from_base_entity(base_entity) -> 'Node':
return Node(
type=base_entity.function,
bel=base_entity.as_bel(),
md5=base_entity.md5,
data=base_entity,
) | [
"def",
"_start_from_base_entity",
"(",
"base_entity",
")",
"->",
"'Node'",
":",
"return",
"Node",
"(",
"type",
"=",
"base_entity",
".",
"function",
",",
"bel",
"=",
"base_entity",
".",
"as_bel",
"(",
")",
",",
"md5",
"=",
"base_entity",
".",
"md5",
",",
... | Convert a base entity to a node model. | [
"Convert",
"a",
"base",
"entity",
"to",
"a",
"node",
"model",
"."
] | [
"\"\"\"Convert a base entity to a node model.\r\n\r\n :type base_entity: pybel.dsl.BaseEntity\r\n \"\"\""
] | [
{
"param": "base_entity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "base_entity",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | as_bel | <not_specific> | def as_bel(self):
"""Serialize this node as a PyBEL DSL object.
:rtype: pybel.dsl.BaseEntity
"""
return parse_result_to_dsl(self.data) | Serialize this node as a PyBEL DSL object.
:rtype: pybel.dsl.BaseEntity
| Serialize this node as a PyBEL DSL object. | [
"Serialize",
"this",
"node",
"as",
"a",
"PyBEL",
"DSL",
"object",
"."
] | def as_bel(self):
return parse_result_to_dsl(self.data) | [
"def",
"as_bel",
"(",
"self",
")",
":",
"return",
"parse_result_to_dsl",
"(",
"self",
".",
"data",
")"
] | Serialize this node as a PyBEL DSL object. | [
"Serialize",
"this",
"node",
"as",
"a",
"PyBEL",
"DSL",
"object",
"."
] | [
"\"\"\"Serialize this node as a PyBEL DSL object.\r\n\r\n :rtype: pybel.dsl.BaseEntity\r\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "pybel.dsl.BaseEntity"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | to_json | Mapping[str, Any] | def to_json(self, include_id: bool = False) -> Mapping[str, Any]:
"""Create a citation dictionary that is used to recreate the edge data dictionary of a :class:`BELGraph`.
:param bool include_id: If true, includes the model identifier
:return: Citation dictionary for the recreation of a :cl... | Create a citation dictionary that is used to recreate the edge data dictionary of a :class:`BELGraph`.
:param bool include_id: If true, includes the model identifier
:return: Citation dictionary for the recreation of a :class:`BELGraph`.
| Create a citation dictionary that is used to recreate the edge data dictionary of a :class:`BELGraph`. | [
"Create",
"a",
"citation",
"dictionary",
"that",
"is",
"used",
"to",
"recreate",
"the",
"edge",
"data",
"dictionary",
"of",
"a",
":",
"class",
":",
"`",
"BELGraph",
"`",
"."
] | def to_json(self, include_id: bool = False) -> Mapping[str, Any]:
result = CitationDict(
namespace=self.db,
identifier=self.db_id,
name=self.title,
)
if include_id:
result['id'] = self.id
if self.title:
result[NAME] = self.title... | [
"def",
"to_json",
"(",
"self",
",",
"include_id",
":",
"bool",
"=",
"False",
")",
"->",
"Mapping",
"[",
"str",
",",
"Any",
"]",
":",
"result",
"=",
"CitationDict",
"(",
"namespace",
"=",
"self",
".",
"db",
",",
"identifier",
"=",
"self",
".",
"db_id"... | Create a citation dictionary that is used to recreate the edge data dictionary of a :class:`BELGraph`. | [
"Create",
"a",
"citation",
"dictionary",
"that",
"is",
"used",
"to",
"recreate",
"the",
"edge",
"data",
"dictionary",
"of",
"a",
":",
"class",
":",
"`",
"BELGraph",
"`",
"."
] | [
"\"\"\"Create a citation dictionary that is used to recreate the edge data dictionary of a :class:`BELGraph`.\r\n\r\n :param bool include_id: If true, includes the model identifier\r\n :return: Citation dictionary for the recreation of a :class:`BELGraph`.\r\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "include_id",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "Citation dictionary for the recreation of a :class:`BELGraph`.",
"docstring_tokens": [
"Citation",
"dictionary",
"for",
"the",
"recreation",
"of",
"a",
":",
"class",
":",
"`",
... |
14f1e332ffb9c0ed5db7036ef567c522c79883de | rpatil524/pybel | src/pybel/manager/models.py | [
"MIT"
] | Python | insert_into_graph | str | def insert_into_graph(self, graph: BELGraph) -> str:
"""Insert this edge into a BEL graph."""
u = self.source.as_bel()
v = self.target.as_bel()
if self.evidence:
return graph.add_qualified_edge(u, v, **self.data)
else:
return graph.add_unqualified... | Insert this edge into a BEL graph. | Insert this edge into a BEL graph. | [
"Insert",
"this",
"edge",
"into",
"a",
"BEL",
"graph",
"."
] | def insert_into_graph(self, graph: BELGraph) -> str:
u = self.source.as_bel()
v = self.target.as_bel()
if self.evidence:
return graph.add_qualified_edge(u, v, **self.data)
else:
return graph.add_unqualified_edge(u, v, self.relation) | [
"def",
"insert_into_graph",
"(",
"self",
",",
"graph",
":",
"BELGraph",
")",
"->",
"str",
":",
"u",
"=",
"self",
".",
"source",
".",
"as_bel",
"(",
")",
"v",
"=",
"self",
".",
"target",
".",
"as_bel",
"(",
")",
"if",
"self",
".",
"evidence",
":",
... | Insert this edge into a BEL graph. | [
"Insert",
"this",
"edge",
"into",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Insert this edge into a BEL graph.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | new | BELGraph | def new(self) -> BELGraph:
"""Generate a new BEL graph with the given metadata."""
graph = BELGraph()
self.update(graph)
return graph | Generate a new BEL graph with the given metadata. | Generate a new BEL graph with the given metadata. | [
"Generate",
"a",
"new",
"BEL",
"graph",
"with",
"the",
"given",
"metadata",
"."
] | def new(self) -> BELGraph:
graph = BELGraph()
self.update(graph)
return graph | [
"def",
"new",
"(",
"self",
")",
"->",
"BELGraph",
":",
"graph",
"=",
"BELGraph",
"(",
")",
"self",
".",
"update",
"(",
"graph",
")",
"return",
"graph"
] | Generate a new BEL graph with the given metadata. | [
"Generate",
"a",
"new",
"BEL",
"graph",
"with",
"the",
"given",
"metadata",
"."
] | [
"\"\"\"Generate a new BEL graph with the given metadata.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | update | None | def update(self, graph: BELGraph) -> None:
"""Update the BEL graph's metadata."""
if self.name:
graph.name = self.name
if self.version:
graph.version = self.version
if self.authors:
graph.authors = self.authors
if self.description:
... | Update the BEL graph's metadata. | Update the BEL graph's metadata. | [
"Update",
"the",
"BEL",
"graph",
"'",
"s",
"metadata",
"."
] | def update(self, graph: BELGraph) -> None:
if self.name:
graph.name = self.name
if self.version:
graph.version = self.version
if self.authors:
graph.authors = self.authors
if self.description:
graph.description = self.description
if... | [
"def",
"update",
"(",
"self",
",",
"graph",
":",
"BELGraph",
")",
"->",
"None",
":",
"if",
"self",
".",
"name",
":",
"graph",
".",
"name",
"=",
"self",
".",
"name",
"if",
"self",
".",
"version",
":",
"graph",
".",
"version",
"=",
"self",
".",
"ve... | Update the BEL graph's metadata. | [
"Update",
"the",
"BEL",
"graph",
"'",
"s",
"metadata",
"."
] | [
"\"\"\"Update the BEL graph's metadata.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | iterate_bel | Iterable[Tuple[str, str]] | def iterate_bel(self) -> Iterable[Tuple[str, str]]:
"""Yield all paths to BEL documents."""
for root, _dirs, file_names in self.walk():
for file_name in sorted(file_names):
if not file_name.startswith('_') and file_name.endswith('.bel'):
yield root, file_n... | Yield all paths to BEL documents. | Yield all paths to BEL documents. | [
"Yield",
"all",
"paths",
"to",
"BEL",
"documents",
"."
] | def iterate_bel(self) -> Iterable[Tuple[str, str]]:
for root, _dirs, file_names in self.walk():
for file_name in sorted(file_names):
if not file_name.startswith('_') and file_name.endswith('.bel'):
yield root, file_name | [
"def",
"iterate_bel",
"(",
"self",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
":",
"for",
"root",
",",
"_dirs",
",",
"file_names",
"in",
"self",
".",
"walk",
"(",
")",
":",
"for",
"file_name",
"in",
"sorted",
"(",
"file_... | Yield all paths to BEL documents. | [
"Yield",
"all",
"paths",
"to",
"BEL",
"documents",
"."
] | [
"\"\"\"Yield all paths to BEL documents.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | clear_local_warned | None | def clear_local_warned(self) -> None:
"""Clear caches for BEL documents with errors."""
for root, file_name in self.iterate_bel():
if self._has_warnings(root, file_name):
self._remove_root_file_name(root, file_name) | Clear caches for BEL documents with errors. | Clear caches for BEL documents with errors. | [
"Clear",
"caches",
"for",
"BEL",
"documents",
"with",
"errors",
"."
] | def clear_local_warned(self) -> None:
for root, file_name in self.iterate_bel():
if self._has_warnings(root, file_name):
self._remove_root_file_name(root, file_name) | [
"def",
"clear_local_warned",
"(",
"self",
")",
"->",
"None",
":",
"for",
"root",
",",
"file_name",
"in",
"self",
".",
"iterate_bel",
"(",
")",
":",
"if",
"self",
".",
"_has_warnings",
"(",
"root",
",",
"file_name",
")",
":",
"self",
".",
"_remove_root_fi... | Clear caches for BEL documents with errors. | [
"Clear",
"caches",
"for",
"BEL",
"documents",
"with",
"errors",
"."
] | [
"\"\"\"Clear caches for BEL documents with errors.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | build_cli | <not_specific> | def build_cli(self): # noqa: D202
"""Build a command line interface."""
@click.group(help=f'Tools for the BEL repository at {self.directory} using PyBEL v{get_version()}')
@click.pass_context
def main(ctx):
"""Group the commands."""
ctx.obj = self
appen... | Build a command line interface. | Build a command line interface. | [
"Build",
"a",
"command",
"line",
"interface",
"."
] | def build_cli(self):
@click.group(help=f'Tools for the BEL repository at {self.directory} using PyBEL v{get_version()}')
@click.pass_context
def main(ctx):
ctx.obj = self
append_click_group(main)
return main | [
"def",
"build_cli",
"(",
"self",
")",
":",
"@",
"click",
".",
"group",
"(",
"help",
"=",
"f'Tools for the BEL repository at {self.directory} using PyBEL v{get_version()}'",
")",
"@",
"click",
".",
"pass_context",
"def",
"main",
"(",
"ctx",
")",
":",
"\"\"\"Group the... | Build a command line interface. | [
"Build",
"a",
"command",
"line",
"interface",
"."
] | [
"# noqa: D202",
"\"\"\"Build a command line interface.\"\"\"",
"\"\"\"Group the commands.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | _iterate_citations | Iterable[Tuple[str, str]] | def _iterate_citations(self, **kwargs) -> Iterable[Tuple[str, str]]:
"""List all citations in documents in this repository."""
for _, _, data in self.get_graph(**kwargs).edges(data=True):
citation = data.get(CITATION)
if citation is not None:
yield citation.namesp... | List all citations in documents in this repository. | List all citations in documents in this repository. | [
"List",
"all",
"citations",
"in",
"documents",
"in",
"this",
"repository",
"."
] | def _iterate_citations(self, **kwargs) -> Iterable[Tuple[str, str]]:
for _, _, data in self.get_graph(**kwargs).edges(data=True):
citation = data.get(CITATION)
if citation is not None:
yield citation.namespace, citation.identifier | [
"def",
"_iterate_citations",
"(",
"self",
",",
"**",
"kwargs",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
":",
"for",
"_",
",",
"_",
",",
"data",
"in",
"self",
".",
"get_graph",
"(",
"**",
"kwargs",
")",
".",
"edges",
... | List all citations in documents in this repository. | [
"List",
"all",
"citations",
"in",
"documents",
"in",
"this",
"repository",
"."
] | [
"\"\"\"List all citations in documents in this repository.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | ls | null | def ls(bel_repository: BELRepository):
"""List the contents of the repository."""
global_caches = bel_repository._get_global_caches()
if global_caches:
click.secho('Global Cache', fg='red', bold=True)
_write_caches(bel_repository, bel_repository.output_directory, bel_repo... | List the contents of the repository. | List the contents of the repository. | [
"List",
"the",
"contents",
"of",
"the",
"repository",
"."
] | def ls(bel_repository: BELRepository):
global_caches = bel_repository._get_global_caches()
if global_caches:
click.secho('Global Cache', fg='red', bold=True)
_write_caches(bel_repository, bel_repository.output_directory, bel_repository.bel_cache_name)
click.secho('Loc... | [
"def",
"ls",
"(",
"bel_repository",
":",
"BELRepository",
")",
":",
"global_caches",
"=",
"bel_repository",
".",
"_get_global_caches",
"(",
")",
"if",
"global_caches",
":",
"click",
".",
"secho",
"(",
"'Global Cache'",
",",
"fg",
"=",
"'red'",
",",
"bold",
"... | List the contents of the repository. | [
"List",
"the",
"contents",
"of",
"the",
"repository",
"."
] | [
"\"\"\"List the contents of the repository.\"\"\""
] | [
{
"param": "bel_repository",
"type": "BELRepository"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bel_repository",
"type": "BELRepository",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
756a97354d1f2bab72f3ef3376712bbc4d0dccd5 | rpatil524/pybel | src/pybel/repository.py | [
"MIT"
] | Python | upload_separate | null | def upload_separate(repository: BELRepository, host: str, user: str, password: str, sleep: int, private: bool):
"""Upload all to BEL Commons."""
it = tqdm(repository.get_graphs().items())
for name, graph in it:
res = to_bel_commons(graph, host=host, user=user, password=password, publ... | Upload all to BEL Commons. | Upload all to BEL Commons. | [
"Upload",
"all",
"to",
"BEL",
"Commons",
"."
] | def upload_separate(repository: BELRepository, host: str, user: str, password: str, sleep: int, private: bool):
it = tqdm(repository.get_graphs().items())
for name, graph in it:
res = to_bel_commons(graph, host=host, user=user, password=password, public=not private)
res_json = re... | [
"def",
"upload_separate",
"(",
"repository",
":",
"BELRepository",
",",
"host",
":",
"str",
",",
"user",
":",
"str",
",",
"password",
":",
"str",
",",
"sleep",
":",
"int",
",",
"private",
":",
"bool",
")",
":",
"it",
"=",
"tqdm",
"(",
"repository",
"... | Upload all to BEL Commons. | [
"Upload",
"all",
"to",
"BEL",
"Commons",
"."
] | [
"\"\"\"Upload all to BEL Commons.\"\"\""
] | [
{
"param": "repository",
"type": "BELRepository"
},
{
"param": "host",
"type": "str"
},
{
"param": "user",
"type": "str"
},
{
"param": "password",
"type": "str"
},
{
"param": "sleep",
"type": "int"
},
{
"param": "private",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repository",
"type": "BELRepository",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "host",
"type": "str",
"docstring": null,
"do... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | map_cbn | <not_specific> | def map_cbn(d):
"""Pre-processes the JSON from the CBN.
- removes statements without evidence, or with placeholder evidence
:param dict d: Raw JGIF from the CBN
:return: Preprocessed JGIF
:rtype: dict
"""
for i, edge in enumerate(d['graph']['edges']):
if 'metadata' not in edge:
... | Pre-processes the JSON from the CBN.
- removes statements without evidence, or with placeholder evidence
:param dict d: Raw JGIF from the CBN
:return: Preprocessed JGIF
:rtype: dict
| Pre-processes the JSON from the CBN.
removes statements without evidence, or with placeholder evidence | [
"Pre",
"-",
"processes",
"the",
"JSON",
"from",
"the",
"CBN",
".",
"removes",
"statements",
"without",
"evidence",
"or",
"with",
"placeholder",
"evidence"
] | def map_cbn(d):
for i, edge in enumerate(d['graph']['edges']):
if 'metadata' not in edge:
continue
if 'evidences' not in edge['metadata']:
continue
for j, evidence in enumerate(edge['metadata']['evidences']):
if EXPERIMENT_CONTEXT not in evidence:
... | [
"def",
"map_cbn",
"(",
"d",
")",
":",
"for",
"i",
",",
"edge",
"in",
"enumerate",
"(",
"d",
"[",
"'graph'",
"]",
"[",
"'edges'",
"]",
")",
":",
"if",
"'metadata'",
"not",
"in",
"edge",
":",
"continue",
"if",
"'evidences'",
"not",
"in",
"edge",
"[",... | Pre-processes the JSON from the CBN. | [
"Pre",
"-",
"processes",
"the",
"JSON",
"from",
"the",
"CBN",
"."
] | [
"\"\"\"Pre-processes the JSON from the CBN.\n\n - removes statements without evidence, or with placeholder evidence\n\n :param dict d: Raw JGIF from the CBN\n :return: Preprocessed JGIF\n :rtype: dict\n \"\"\"",
"# ctx = {k.strip().lower(): v.strip() for k, v in evidence[EXPERIMENT_CONTEXT].items()... | [
{
"param": "d",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "dict"
}
],
"raises": [],
"params": [
{
"identifier": "d",
"type": null,
"docstring": "Raw JGIF from the CBN",
"docstring_tokens": [
"Raw",
"JGIF",
... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | from_cbn_jgif_file | BELGraph | def from_cbn_jgif_file(path: Union[str, TextIO]) -> BELGraph:
"""Build a graph from a file containing the CBN variant of JGIF.
:param path: A path or file-like
"""
return from_cbn_jgif(json.load(path)) | Build a graph from a file containing the CBN variant of JGIF.
:param path: A path or file-like
| Build a graph from a file containing the CBN variant of JGIF. | [
"Build",
"a",
"graph",
"from",
"a",
"file",
"containing",
"the",
"CBN",
"variant",
"of",
"JGIF",
"."
] | def from_cbn_jgif_file(path: Union[str, TextIO]) -> BELGraph:
return from_cbn_jgif(json.load(path)) | [
"def",
"from_cbn_jgif_file",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
")",
"->",
"BELGraph",
":",
"return",
"from_cbn_jgif",
"(",
"json",
".",
"load",
"(",
"path",
")",
")"
] | Build a graph from a file containing the CBN variant of JGIF. | [
"Build",
"a",
"graph",
"from",
"a",
"file",
"containing",
"the",
"CBN",
"variant",
"of",
"JGIF",
"."
] | [
"\"\"\"Build a graph from a file containing the CBN variant of JGIF.\n\n :param path: A path or file-like\n \"\"\""
] | [
{
"param": "path",
"type": "Union[str, TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "Union[str, TextIO]",
"docstring": "A path or file-like",
"docstring_tokens": [
"A",
"path",
"or",
"file",
"-",
"like"
],
"default": null,
"is_op... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | from_cbn_jgif | <not_specific> | def from_cbn_jgif(graph_jgif_dict):
"""Build a BEL graph from CBN JGIF.
Map the JGIF used by the Causal Biological Network Database to standard namespace and annotations, then
builds a BEL graph using :func:`pybel.from_jgif`.
:param dict graph_jgif_dict: The JSON object representing the graph in JGIF ... | Build a BEL graph from CBN JGIF.
Map the JGIF used by the Causal Biological Network Database to standard namespace and annotations, then
builds a BEL graph using :func:`pybel.from_jgif`.
:param dict graph_jgif_dict: The JSON object representing the graph in JGIF format
:rtype: BELGraph
Example:
... | Build a BEL graph from CBN JGIF.
Map the JGIF used by the Causal Biological Network Database to standard namespace and annotations, then
builds a BEL graph using :func:`pybel.from_jgif`. | [
"Build",
"a",
"BEL",
"graph",
"from",
"CBN",
"JGIF",
".",
"Map",
"the",
"JGIF",
"used",
"by",
"the",
"Causal",
"Biological",
"Network",
"Database",
"to",
"standard",
"namespace",
"and",
"annotations",
"then",
"builds",
"a",
"BEL",
"graph",
"using",
":",
"f... | def from_cbn_jgif(graph_jgif_dict):
graph_jgif_dict = map_cbn(graph_jgif_dict)
graph_jgif_dict['graph'][GRAPH_NAMESPACE_URL] = NAMESPACE_URLS
graph_jgif_dict['graph'][GRAPH_ANNOTATION_URL] = ANNOTATION_URLS
graph_jgif_dict['graph']['metadata'].update({
METADATA_AUTHORS: 'Causal Biological Networ... | [
"def",
"from_cbn_jgif",
"(",
"graph_jgif_dict",
")",
":",
"graph_jgif_dict",
"=",
"map_cbn",
"(",
"graph_jgif_dict",
")",
"graph_jgif_dict",
"[",
"'graph'",
"]",
"[",
"GRAPH_NAMESPACE_URL",
"]",
"=",
"NAMESPACE_URLS",
"graph_jgif_dict",
"[",
"'graph'",
"]",
"[",
"... | Build a BEL graph from CBN JGIF. | [
"Build",
"a",
"BEL",
"graph",
"from",
"CBN",
"JGIF",
"."
] | [
"\"\"\"Build a BEL graph from CBN JGIF.\n\n Map the JGIF used by the Causal Biological Network Database to standard namespace and annotations, then\n builds a BEL graph using :func:`pybel.from_jgif`.\n\n :param dict graph_jgif_dict: The JSON object representing the graph in JGIF format\n :rtype: BELGrap... | [
{
"param": "graph_jgif_dict",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "BELGraph\nExample:\n.. code-block:: python\n\n import requests\n from pybel import from_cbn_jgif\n apoptosis_url = 'http://causalbionet.com/Networks/GetJSONGraphFile?networkId=810385422'\n grap... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | from_jgif | <not_specific> | def from_jgif(graph_jgif_dict, parser_kwargs: Optional[Mapping[str, Any]] = None): # noqa:C901
"""Build a BEL graph from a JGIF JSON object.
:param dict graph_jgif_dict: The JSON object representing the graph in JGIF format
:rtype: BELGraph
"""
graph = BELGraph()
root = graph_jgif_dict['graph... | Build a BEL graph from a JGIF JSON object.
:param dict graph_jgif_dict: The JSON object representing the graph in JGIF format
:rtype: BELGraph
| Build a BEL graph from a JGIF JSON object. | [
"Build",
"a",
"BEL",
"graph",
"from",
"a",
"JGIF",
"JSON",
"object",
"."
] | def from_jgif(graph_jgif_dict, parser_kwargs: Optional[Mapping[str, Any]] = None):
graph = BELGraph()
root = graph_jgif_dict['graph']
if 'label' in root:
graph.name = root['label']
if 'metadata' in root:
metadata = root['metadata']
for key in METADATA_INSERT_KEYS:
i... | [
"def",
"from_jgif",
"(",
"graph_jgif_dict",
",",
"parser_kwargs",
":",
"Optional",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
":",
"graph",
"=",
"BELGraph",
"(",
")",
"root",
"=",
"graph_jgif_dict",
"[",
"'graph'",
"]",
"if",
"... | Build a BEL graph from a JGIF JSON object. | [
"Build",
"a",
"BEL",
"graph",
"from",
"a",
"JGIF",
"JSON",
"object",
"."
] | [
"# noqa:C901",
"\"\"\"Build a BEL graph from a JGIF JSON object.\n\n :param dict graph_jgif_dict: The JSON object representing the graph in JGIF format\n :rtype: BELGraph\n \"\"\"",
"# don't need legacy BEL format",
"# FIXME?",
"# is none or is empty list"
] | [
{
"param": "graph_jgif_dict",
"type": null
},
{
"param": "parser_kwargs",
"type": "Optional[Mapping[str, Any]]"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "BELGraph"
}
],
"raises": [],
"params": [
{
"identifier": "graph_jgif_dict",
"type": null,
"docstring": "The JSON object representing the graph in JGIF format",
"docstr... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | from_jgif_file | BELGraph | def from_jgif_file(path: Union[str, TextIO]) -> BELGraph:
"""Build a graph from the JGIF JSON contained in the given file.
:param path: A path or file-like
"""
return from_jgif(json.load(path)) | Build a graph from the JGIF JSON contained in the given file.
:param path: A path or file-like
| Build a graph from the JGIF JSON contained in the given file. | [
"Build",
"a",
"graph",
"from",
"the",
"JGIF",
"JSON",
"contained",
"in",
"the",
"given",
"file",
"."
] | def from_jgif_file(path: Union[str, TextIO]) -> BELGraph:
return from_jgif(json.load(path)) | [
"def",
"from_jgif_file",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
")",
"->",
"BELGraph",
":",
"return",
"from_jgif",
"(",
"json",
".",
"load",
"(",
"path",
")",
")"
] | Build a graph from the JGIF JSON contained in the given file. | [
"Build",
"a",
"graph",
"from",
"the",
"JGIF",
"JSON",
"contained",
"in",
"the",
"given",
"file",
"."
] | [
"\"\"\"Build a graph from the JGIF JSON contained in the given file.\n\n :param path: A path or file-like\n \"\"\""
] | [
{
"param": "path",
"type": "Union[str, TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "Union[str, TextIO]",
"docstring": "A path or file-like",
"docstring_tokens": [
"A",
"path",
"or",
"file",
"-",
"like"
],
"default": null,
"is_op... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | to_jgif | <not_specific> | def to_jgif(graph):
"""Build a JGIF dictionary from a BEL graph.
:param pybel.BELGraph graph: A BEL graph
:return: A JGIF dictionary
:rtype: dict
.. warning::
Untested! This format is not general purpose and is therefore time is not heavily invested. If you want to
use Cytoscape.j... | Build a JGIF dictionary from a BEL graph.
:param pybel.BELGraph graph: A BEL graph
:return: A JGIF dictionary
:rtype: dict
.. warning::
Untested! This format is not general purpose and is therefore time is not heavily invested. If you want to
use Cytoscape.js, we suggest using :func:`... | Build a JGIF dictionary from a BEL graph. | [
"Build",
"a",
"JGIF",
"dictionary",
"from",
"a",
"BEL",
"graph",
"."
] | def to_jgif(graph):
u_v_r_bel = {}
nodes_entry = []
edges_entry = []
for node in sorted(graph, key=methodcaller('as_bel')):
nodes_entry.append({
'id': node.md5,
'label': node.as_bel(),
'bel_function_type': node.function,
})
for u, v in graph.edges(... | [
"def",
"to_jgif",
"(",
"graph",
")",
":",
"u_v_r_bel",
"=",
"{",
"}",
"nodes_entry",
"=",
"[",
"]",
"edges_entry",
"=",
"[",
"]",
"for",
"node",
"in",
"sorted",
"(",
"graph",
",",
"key",
"=",
"methodcaller",
"(",
"'as_bel'",
")",
")",
":",
"nodes_ent... | Build a JGIF dictionary from a BEL graph. | [
"Build",
"a",
"JGIF",
"dictionary",
"from",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Build a JGIF dictionary from a BEL graph.\n\n :param pybel.BELGraph graph: A BEL graph\n :return: A JGIF dictionary\n :rtype: dict\n\n .. warning::\n\n Untested! This format is not general purpose and is therefore time is not heavily invested. If you want to\n use Cytoscape.js, we s... | [
{
"param": "graph",
"type": null
}
] | {
"returns": [
{
"docstring": "A JGIF dictionary",
"docstring_tokens": [
"A",
"JGIF",
"dictionary"
],
"type": "dict\n.. warning::\n\n Untested! This format is not general purpose and is therefore time is not heavily invested. If you want to\n use Cytoscape.js,... |
4566b103adc9c19ec7923696fc9cb0617bb8f244 | rpatil524/pybel | src/pybel/io/jgif.py | [
"MIT"
] | Python | to_jgif_file | None | def to_jgif_file(graph: BELGraph, file: Union[str, TextIO], **kwargs) -> None:
"""Write JGIF to a file.
:param graph: A BEL graph
:param file: A writable file or file-like
The example below shows how to output a BEL graph as JGIF to an open file.
.. code-block:: python
from pybel.examples... | Write JGIF to a file.
:param graph: A BEL graph
:param file: A writable file or file-like
The example below shows how to output a BEL graph as JGIF to an open file.
.. code-block:: python
from pybel.examples import sialic_acid_graph
from pybel import to_jgif_file
with open('grap... | Write JGIF to a file. | [
"Write",
"JGIF",
"to",
"a",
"file",
"."
] | def to_jgif_file(graph: BELGraph, file: Union[str, TextIO], **kwargs) -> None:
json.dump(to_jgif(graph), file, ensure_ascii=False, **kwargs) | [
"def",
"to_jgif_file",
"(",
"graph",
":",
"BELGraph",
",",
"file",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"json",
".",
"dump",
"(",
"to_jgif",
"(",
"graph",
")",
",",
"file",
",",
"ensure_ascii",
... | Write JGIF to a file. | [
"Write",
"JGIF",
"to",
"a",
"file",
"."
] | [
"\"\"\"Write JGIF to a file.\n\n :param graph: A BEL graph\n :param file: A writable file or file-like\n\n The example below shows how to output a BEL graph as JGIF to an open file.\n\n .. code-block:: python\n\n from pybel.examples import sialic_acid_graph\n from pybel import to_jgif_file\n... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "file",
"type": "Union[str, TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "file",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.