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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | from_sbel | BELGraph | def from_sbel(it: Iterable[SBEL], includes_metadata: bool = True) -> BELGraph:
"""Load a BEL graph from an iterable of dictionaries corresponding to lines in BEL JSONL.
:param it: An iterable of dictionaries.
:param includes_metadata: By default, interprets the first element of the iterable as the graph's ... | Load a BEL graph from an iterable of dictionaries corresponding to lines in BEL JSONL.
:param it: An iterable of dictionaries.
:param includes_metadata: By default, interprets the first element of the iterable as the graph's metadata.
Switch to ``False`` to disable.
:return: A BEL graph
| Load a BEL graph from an iterable of dictionaries corresponding to lines in BEL JSONL. | [
"Load",
"a",
"BEL",
"graph",
"from",
"an",
"iterable",
"of",
"dictionaries",
"corresponding",
"to",
"lines",
"in",
"BEL",
"JSONL",
"."
] | def from_sbel(it: Iterable[SBEL], includes_metadata: bool = True) -> BELGraph:
it = iter(it)
rv = BELGraph()
if includes_metadata:
rv.graph.update(next(it))
_recover_graph_dict(rv)
add_sbel(rv, it)
return rv | [
"def",
"from_sbel",
"(",
"it",
":",
"Iterable",
"[",
"SBEL",
"]",
",",
"includes_metadata",
":",
"bool",
"=",
"True",
")",
"->",
"BELGraph",
":",
"it",
"=",
"iter",
"(",
"it",
")",
"rv",
"=",
"BELGraph",
"(",
")",
"if",
"includes_metadata",
":",
"rv"... | Load a BEL graph from an iterable of dictionaries corresponding to lines in BEL JSONL. | [
"Load",
"a",
"BEL",
"graph",
"from",
"an",
"iterable",
"of",
"dictionaries",
"corresponding",
"to",
"lines",
"in",
"BEL",
"JSONL",
"."
] | [
"\"\"\"Load a BEL graph from an iterable of dictionaries corresponding to lines in BEL JSONL.\n\n :param it: An iterable of dictionaries.\n :param includes_metadata: By default, interprets the first element of the iterable as the graph's metadata.\n Switch to ``False`` to disable.\n :return: A BEL grap... | [
{
"param": "it",
"type": "Iterable[SBEL]"
},
{
"param": "includes_metadata",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "it",
"type": "Iterable[SBEL]",
"docstring": "An iterable of dictionaries.",
"... |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | add_sbel | None | def add_sbel(graph: BELGraph, it: Iterable[SBEL]) -> None:
"""Add dictionaries to a BEL graph.
:param graph: A BEL graph
:param it: An iterable of dictionaries.
"""
for data in it:
add_sbel_row(graph, data) | Add dictionaries to a BEL graph.
:param graph: A BEL graph
:param it: An iterable of dictionaries.
| Add dictionaries to a BEL graph. | [
"Add",
"dictionaries",
"to",
"a",
"BEL",
"graph",
"."
] | def add_sbel(graph: BELGraph, it: Iterable[SBEL]) -> None:
for data in it:
add_sbel_row(graph, data) | [
"def",
"add_sbel",
"(",
"graph",
":",
"BELGraph",
",",
"it",
":",
"Iterable",
"[",
"SBEL",
"]",
")",
"->",
"None",
":",
"for",
"data",
"in",
"it",
":",
"add_sbel_row",
"(",
"graph",
",",
"data",
")"
] | Add dictionaries to a BEL graph. | [
"Add",
"dictionaries",
"to",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Add dictionaries to a BEL graph.\n\n :param graph: A BEL graph\n :param it: An iterable of dictionaries.\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "it",
"type": "Iterable[SBEL]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "it",
"... |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | add_sbel_row | str | def add_sbel_row(graph: BELGraph, data: SBEL) -> str:
"""Add a single SBEL data dictionary to a graph."""
u = parse_result_to_dsl(data['source'])
v = parse_result_to_dsl(data['target'])
edge_data = {
k: v
for k, v in data.items()
if k not in {'source', 'target', 'key'}
}
... | Add a single SBEL data dictionary to a graph. | Add a single SBEL data dictionary to a graph. | [
"Add",
"a",
"single",
"SBEL",
"data",
"dictionary",
"to",
"a",
"graph",
"."
] | def add_sbel_row(graph: BELGraph, data: SBEL) -> str:
u = parse_result_to_dsl(data['source'])
v = parse_result_to_dsl(data['target'])
edge_data = {
k: v
for k, v in data.items()
if k not in {'source', 'target', 'key'}
}
for side in (SOURCE_MODIFIER, TARGET_MODIFIER):
... | [
"def",
"add_sbel_row",
"(",
"graph",
":",
"BELGraph",
",",
"data",
":",
"SBEL",
")",
"->",
"str",
":",
"u",
"=",
"parse_result_to_dsl",
"(",
"data",
"[",
"'source'",
"]",
")",
"v",
"=",
"parse_result_to_dsl",
"(",
"data",
"[",
"'target'",
"]",
")",
"ed... | Add a single SBEL data dictionary to a graph. | [
"Add",
"a",
"single",
"SBEL",
"data",
"dictionary",
"to",
"a",
"graph",
"."
] | [
"\"\"\"Add a single SBEL data dictionary to a graph.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "data",
"type": "SBEL"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": "SBEL",
"docstring": null,
"docstring_t... |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | from_sbel_file | BELGraph | def from_sbel_file(path: Union[str, TextIO]) -> BELGraph:
"""Build a graph from the BEL JSONL contained in the given file.
:param path: A path or file-like
"""
return from_sbel((
json.loads(line)
for line in path
)) | Build a graph from the BEL JSONL contained in the given file.
:param path: A path or file-like
| Build a graph from the BEL JSONL contained in the given file. | [
"Build",
"a",
"graph",
"from",
"the",
"BEL",
"JSONL",
"contained",
"in",
"the",
"given",
"file",
"."
] | def from_sbel_file(path: Union[str, TextIO]) -> BELGraph:
return from_sbel((
json.loads(line)
for line in path
)) | [
"def",
"from_sbel_file",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
")",
"->",
"BELGraph",
":",
"return",
"from_sbel",
"(",
"(",
"json",
".",
"loads",
"(",
"line",
")",
"for",
"line",
"in",
"path",
")",
")"
] | Build a graph from the BEL JSONL contained in the given file. | [
"Build",
"a",
"graph",
"from",
"the",
"BEL",
"JSONL",
"contained",
"in",
"the",
"given",
"file",
"."
] | [
"\"\"\"Build a graph from the BEL JSONL 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... |
fb35c6bf6255a853b9650f06b8108d4f8744e13d | rpatil524/pybel | src/pybel/struct/filters/edge_predicates.py | [
"MIT"
] | Python | edge_predicate | EdgePredicate | def edge_predicate(func: DictEdgePredicate) -> EdgePredicate: # noqa: D202
"""Decorate an edge predicate function that only takes a dictionary as its singular argument.
Apply this as a decorator to a function that takes a single argument, a PyBEL node data dictionary, to make
sure that it can also accept ... | Decorate an edge predicate function that only takes a dictionary as its singular argument.
Apply this as a decorator to a function that takes a single argument, a PyBEL node data dictionary, to make
sure that it can also accept a pair of arguments, a BELGraph and a PyBEL node tuple as well.
| Decorate an edge predicate function that only takes a dictionary as its singular argument.
Apply this as a decorator to a function that takes a single argument, a PyBEL node data dictionary, to make
sure that it can also accept a pair of arguments, a BELGraph and a PyBEL node tuple as well. | [
"Decorate",
"an",
"edge",
"predicate",
"function",
"that",
"only",
"takes",
"a",
"dictionary",
"as",
"its",
"singular",
"argument",
".",
"Apply",
"this",
"as",
"a",
"decorator",
"to",
"a",
"function",
"that",
"takes",
"a",
"single",
"argument",
"a",
"PyBEL",... | def edge_predicate(func: DictEdgePredicate) -> EdgePredicate:
@wraps(func)
def _wrapped(*args):
x = args[0]
if isinstance(x, BELGraph):
u, v, k = args[1:4]
return func(x[u][v][k])
return func(*args)
return _wrapped | [
"def",
"edge_predicate",
"(",
"func",
":",
"DictEdgePredicate",
")",
"->",
"EdgePredicate",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_wrapped",
"(",
"*",
"args",
")",
":",
"x",
"=",
"args",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"x",
",",
"BELGr... | Decorate an edge predicate function that only takes a dictionary as its singular argument. | [
"Decorate",
"an",
"edge",
"predicate",
"function",
"that",
"only",
"takes",
"a",
"dictionary",
"as",
"its",
"singular",
"argument",
"."
] | [
"# noqa: D202",
"\"\"\"Decorate an edge predicate function that only takes a dictionary as its singular argument.\n\n Apply this as a decorator to a function that takes a single argument, a PyBEL node data dictionary, to make\n sure that it can also accept a pair of arguments, a BELGraph and a PyBEL node tu... | [
{
"param": "func",
"type": "DictEdgePredicate"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": "DictEdgePredicate",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fb35c6bf6255a853b9650f06b8108d4f8744e13d | rpatil524/pybel | src/pybel/struct/filters/edge_predicates.py | [
"MIT"
] | Python | _has_modifier | bool | def _has_modifier(edge_data: EdgeData, modifier: str) -> bool:
"""Check if the edge has the given modifier.
:param edge_data: The edge data dictionary
:param modifier: The modifier to check. One of :data:`pybel.constants.ACTIVITY`,
:data:`pybel.constants.DEGRADATION`, or :data:`pybe... | Check if the edge has the given modifier.
:param edge_data: The edge data dictionary
:param modifier: The modifier to check. One of :data:`pybel.constants.ACTIVITY`,
:data:`pybel.constants.DEGRADATION`, or :data:`pybel.constants.TRANSLOCATION`.
:return: Does either the subject or ob... | Check if the edge has the given modifier. | [
"Check",
"if",
"the",
"edge",
"has",
"the",
"given",
"modifier",
"."
] | def _has_modifier(edge_data: EdgeData, modifier: str) -> bool:
return (
part_has_modifier(edge_data, SOURCE_MODIFIER, modifier)
or part_has_modifier(edge_data, TARGET_MODIFIER, modifier)
) | [
"def",
"_has_modifier",
"(",
"edge_data",
":",
"EdgeData",
",",
"modifier",
":",
"str",
")",
"->",
"bool",
":",
"return",
"(",
"part_has_modifier",
"(",
"edge_data",
",",
"SOURCE_MODIFIER",
",",
"modifier",
")",
"or",
"part_has_modifier",
"(",
"edge_data",
","... | Check if the edge has the given modifier. | [
"Check",
"if",
"the",
"edge",
"has",
"the",
"given",
"modifier",
"."
] | [
"\"\"\"Check if the edge has the given modifier.\n\n :param edge_data: The edge data dictionary\n :param modifier: The modifier to check. One of :data:`pybel.constants.ACTIVITY`,\n :data:`pybel.constants.DEGRADATION`, or :data:`pybel.constants.TRANSLOCATION`.\n :return: Does either t... | [
{
"param": "edge_data",
"type": "EdgeData"
},
{
"param": "modifier",
"type": "str"
}
] | {
"returns": [
{
"docstring": "Does either the subject or object have the given modifier",
"docstring_tokens": [
"Does",
"either",
"the",
"subject",
"or",
"object",
"have",
"the",
"given",
"modifier"
],
"type":... |
fb35c6bf6255a853b9650f06b8108d4f8744e13d | rpatil524/pybel | src/pybel/struct/filters/edge_predicates.py | [
"MIT"
] | Python | edge_has_annotation | Optional[Any] | def edge_has_annotation(edge_data: EdgeData, key: str) -> Optional[Any]:
"""Check if an edge has the given annotation.
:param edge_data: The data dictionary from a BELGraph's edge
:param key: An annotation key
:return: If the annotation key is present in the current data dictionary
For example, it... | Check if an edge has the given annotation.
:param edge_data: The data dictionary from a BELGraph's edge
:param key: An annotation key
:return: If the annotation key is present in the current data dictionary
For example, it might be useful to print all edges that are annotated with 'Subgraph':
>>>... | Check if an edge has the given annotation. | [
"Check",
"if",
"an",
"edge",
"has",
"the",
"given",
"annotation",
"."
] | def edge_has_annotation(edge_data: EdgeData, key: str) -> Optional[Any]:
annotations = edge_data.get(ANNOTATIONS)
if annotations is None:
return None
return annotations.get(key) | [
"def",
"edge_has_annotation",
"(",
"edge_data",
":",
"EdgeData",
",",
"key",
":",
"str",
")",
"->",
"Optional",
"[",
"Any",
"]",
":",
"annotations",
"=",
"edge_data",
".",
"get",
"(",
"ANNOTATIONS",
")",
"if",
"annotations",
"is",
"None",
":",
"return",
... | Check if an edge has the given annotation. | [
"Check",
"if",
"an",
"edge",
"has",
"the",
"given",
"annotation",
"."
] | [
"\"\"\"Check if an edge has the given annotation.\n\n :param edge_data: The data dictionary from a BELGraph's edge\n :param key: An annotation key\n :return: If the annotation key is present in the current data dictionary\n\n For example, it might be useful to print all edges that are annotated with 'Su... | [
{
"param": "edge_data",
"type": "EdgeData"
},
{
"param": "key",
"type": "str"
}
] | {
"returns": [
{
"docstring": "If the annotation key is present in the current data dictionary\nFor example, it might be useful to print all edges that are annotated with 'Subgraph'.\n\n>>> from pybel.examples import sialic_acid_graph\n>>> from pybel.examples.sialic_acid_example import sialic_acid_cd33_comp... |
fb35c6bf6255a853b9650f06b8108d4f8744e13d | rpatil524/pybel | src/pybel/struct/filters/edge_predicates.py | [
"MIT"
] | Python | has_pathology_causal | bool | def has_pathology_causal(graph: BELGraph, u: BaseEntity, v: BaseEntity, k: str) -> bool:
"""Check if the subject is a pathology and has a causal relationship with a non bioprocess/pathology.
:return: If the subject of this edge is a pathology and it participates in a causal reaction.
"""
return (
... | Check if the subject is a pathology and has a causal relationship with a non bioprocess/pathology.
:return: If the subject of this edge is a pathology and it participates in a causal reaction.
| Check if the subject is a pathology and has a causal relationship with a non bioprocess/pathology. | [
"Check",
"if",
"the",
"subject",
"is",
"a",
"pathology",
"and",
"has",
"a",
"causal",
"relationship",
"with",
"a",
"non",
"bioprocess",
"/",
"pathology",
"."
] | def has_pathology_causal(graph: BELGraph, u: BaseEntity, v: BaseEntity, k: str) -> bool:
return (
isinstance(u, Pathology)
and is_causal_relation(graph, u, v, k)
and not isinstance(v, (Pathology, BiologicalProcess))
) | [
"def",
"has_pathology_causal",
"(",
"graph",
":",
"BELGraph",
",",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"k",
":",
"str",
")",
"->",
"bool",
":",
"return",
"(",
"isinstance",
"(",
"u",
",",
"Pathology",
")",
"and",
"is_causal_relation... | Check if the subject is a pathology and has a causal relationship with a non bioprocess/pathology. | [
"Check",
"if",
"the",
"subject",
"is",
"a",
"pathology",
"and",
"has",
"a",
"causal",
"relationship",
"with",
"a",
"non",
"bioprocess",
"/",
"pathology",
"."
] | [
"\"\"\"Check if the subject is a pathology and has a causal relationship with a non bioprocess/pathology.\n\n :return: If the subject of this edge is a pathology and it participates in a causal reaction.\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "k",
"type": "str"
}
] | {
"returns": [
{
"docstring": "If the subject of this edge is a pathology and it participates in a causal reaction.",
"docstring_tokens": [
"If",
"the",
"subject",
"of",
"this",
"edge",
"is",
"a",
"pathology",
"and",
... |
18dd8a05fa23b5a019188bcda24b99d99e2ac54e | rpatil524/pybel | src/pybel/manager/base_manager.py | [
"MIT"
] | Python | build_engine_session | Tuple | def build_engine_session(
connection: str,
echo: bool = False,
autoflush: Optional[bool] = None,
autocommit: Optional[bool] = None,
expire_on_commit: Optional[bool] = None,
scopefunc=None,
) -> Tuple:
"""Build an engine and a session.
:param connection: An RFC-1738 database connection s... | Build an engine and a session.
:param connection: An RFC-1738 database connection string
:param echo: Turn on echoing SQL
:param autoflush: Defaults to True if not specified in kwargs or configuration.
:param autocommit: Defaults to False if not specified in kwargs or configuration.
:param expire_o... | Build an engine and a session. | [
"Build",
"an",
"engine",
"and",
"a",
"session",
"."
] | def build_engine_session(
connection: str,
echo: bool = False,
autoflush: Optional[bool] = None,
autocommit: Optional[bool] = None,
expire_on_commit: Optional[bool] = None,
scopefunc=None,
) -> Tuple:
if connection is None:
raise ValueError('can not build engine when connection is No... | [
"def",
"build_engine_session",
"(",
"connection",
":",
"str",
",",
"echo",
":",
"bool",
"=",
"False",
",",
"autoflush",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"autocommit",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None",
",",
"expire_on_com... | Build an engine and a session. | [
"Build",
"an",
"engine",
"and",
"a",
"session",
"."
] | [
"\"\"\"Build an engine and a session.\n\n :param connection: An RFC-1738 database connection string\n :param echo: Turn on echoing SQL\n :param autoflush: Defaults to True if not specified in kwargs or configuration.\n :param autocommit: Defaults to False if not specified in kwargs or configuration.\n ... | [
{
"param": "connection",
"type": "str"
},
{
"param": "echo",
"type": "bool"
},
{
"param": "autoflush",
"type": "Optional[bool]"
},
{
"param": "autocommit",
"type": "Optional[bool]"
},
{
"param": "expire_on_commit",
"type": "Optional[bool]"
},
{
"param"... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "tuple[Engine,Session]\nFrom the Flask-SQLAlchemy documentation:\n\nAn extra key ``'scopefunc'`` can be set on the ``options`` dict to\nspecify a custom scope function. If it's not provided, Flask's app\nc... |
18dd8a05fa23b5a019188bcda24b99d99e2ac54e | rpatil524/pybel | src/pybel/manager/base_manager.py | [
"MIT"
] | Python | create_all | None | def create_all(self, checkfirst: bool = True) -> None:
"""Create the PyBEL cache's database and tables.
:param checkfirst: Check if the database exists before trying to re-make it
"""
self.base.metadata.create_all(bind=self.engine, checkfirst=checkfirst) | Create the PyBEL cache's database and tables.
:param checkfirst: Check if the database exists before trying to re-make it
| Create the PyBEL cache's database and tables. | [
"Create",
"the",
"PyBEL",
"cache",
"'",
"s",
"database",
"and",
"tables",
"."
] | def create_all(self, checkfirst: bool = True) -> None:
self.base.metadata.create_all(bind=self.engine, checkfirst=checkfirst) | [
"def",
"create_all",
"(",
"self",
",",
"checkfirst",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"self",
".",
"base",
".",
"metadata",
".",
"create_all",
"(",
"bind",
"=",
"self",
".",
"engine",
",",
"checkfirst",
"=",
"checkfirst",
")"
] | Create the PyBEL cache's database and tables. | [
"Create",
"the",
"PyBEL",
"cache",
"'",
"s",
"database",
"and",
"tables",
"."
] | [
"\"\"\"Create the PyBEL cache's database and tables.\n\n :param checkfirst: Check if the database exists before trying to re-make it\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "checkfirst",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "checkfirst",
"type": "bool",
"docstring": "Check if the database ex... |
18dd8a05fa23b5a019188bcda24b99d99e2ac54e | rpatil524/pybel | src/pybel/manager/base_manager.py | [
"MIT"
] | Python | drop_all | None | def drop_all(self, checkfirst: bool = True) -> None:
"""Drop all data, tables, and databases for the PyBEL cache.
:param checkfirst: Check if the database exists before trying to drop it
"""
self.session.close()
self.base.metadata.drop_all(bind=self.engine, checkfirst=checkfirst... | Drop all data, tables, and databases for the PyBEL cache.
:param checkfirst: Check if the database exists before trying to drop it
| Drop all data, tables, and databases for the PyBEL cache. | [
"Drop",
"all",
"data",
"tables",
"and",
"databases",
"for",
"the",
"PyBEL",
"cache",
"."
] | def drop_all(self, checkfirst: bool = True) -> None:
self.session.close()
self.base.metadata.drop_all(bind=self.engine, checkfirst=checkfirst) | [
"def",
"drop_all",
"(",
"self",
",",
"checkfirst",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"self",
".",
"session",
".",
"close",
"(",
")",
"self",
".",
"base",
".",
"metadata",
".",
"drop_all",
"(",
"bind",
"=",
"self",
".",
"engine",
","... | Drop all data, tables, and databases for the PyBEL cache. | [
"Drop",
"all",
"data",
"tables",
"and",
"databases",
"for",
"the",
"PyBEL",
"cache",
"."
] | [
"\"\"\"Drop all data, tables, and databases for the PyBEL cache.\n\n :param checkfirst: Check if the database exists before trying to drop it\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "checkfirst",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "checkfirst",
"type": "bool",
"docstring": "Check if the database ex... |
8b5924102d718e338ac4f7ca81533a1acf7d6d59 | rpatil524/pybel | tests/test_manager/test_manager_graph.py | [
"MIT"
] | Python | assert_unqualified_edge | None | def assert_unqualified_edge(test_case, u: BaseEntity, v: BaseEntity, rel: str) -> None:
"""Assert there's only one edge and get the data for it"""
test_case.assertIn(u, test_case.graph)
test_case.assertIn(v, test_case.graph[u])
edges = list(test_case.graph[u][v].values())
test_case.assertEqual(1, le... | Assert there's only one edge and get the data for it | Assert there's only one edge and get the data for it | [
"Assert",
"there",
"'",
"s",
"only",
"one",
"edge",
"and",
"get",
"the",
"data",
"for",
"it"
] | def assert_unqualified_edge(test_case, u: BaseEntity, v: BaseEntity, rel: str) -> None:
test_case.assertIn(u, test_case.graph)
test_case.assertIn(v, test_case.graph[u])
edges = list(test_case.graph[u][v].values())
test_case.assertEqual(1, len(edges))
data = edges[0]
test_case.assertEqual(rel, da... | [
"def",
"assert_unqualified_edge",
"(",
"test_case",
",",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"rel",
":",
"str",
")",
"->",
"None",
":",
"test_case",
".",
"assertIn",
"(",
"u",
",",
"test_case",
".",
"graph",
")",
"test_case",
".",
... | Assert there's only one edge and get the data for it | [
"Assert",
"there",
"'",
"s",
"only",
"one",
"edge",
"and",
"get",
"the",
"data",
"for",
"it"
] | [
"\"\"\"Assert there's only one edge and get the data for it\"\"\""
] | [
{
"param": "test_case",
"type": null
},
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "rel",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"docstring_... |
8b5924102d718e338ac4f7ca81533a1acf7d6d59 | rpatil524/pybel | tests/test_manager/test_manager_graph.py | [
"MIT"
] | Python | _help_reconstitute | null | def _help_reconstitute(self, node: BaseEntity, number_nodes: int, number_edges: int):
"""Help test the round-trip conversion from PyBEL data dictionary to node model."""
self.assertIsInstance(node, BaseEntity)
graph = BELGraph(name='test', version='0.0.0')
graph.add_node_from_data(node)... | Help test the round-trip conversion from PyBEL data dictionary to node model. | Help test the round-trip conversion from PyBEL data dictionary to node model. | [
"Help",
"test",
"the",
"round",
"-",
"trip",
"conversion",
"from",
"PyBEL",
"data",
"dictionary",
"to",
"node",
"model",
"."
] | def _help_reconstitute(self, node: BaseEntity, number_nodes: int, number_edges: int):
self.assertIsInstance(node, BaseEntity)
graph = BELGraph(name='test', version='0.0.0')
graph.add_node_from_data(node)
make_dummy_namespaces(self.manager, graph)
self.manager.insert_graph(graph)
... | [
"def",
"_help_reconstitute",
"(",
"self",
",",
"node",
":",
"BaseEntity",
",",
"number_nodes",
":",
"int",
",",
"number_edges",
":",
"int",
")",
":",
"self",
".",
"assertIsInstance",
"(",
"node",
",",
"BaseEntity",
")",
"graph",
"=",
"BELGraph",
"(",
"name... | Help test the round-trip conversion from PyBEL data dictionary to node model. | [
"Help",
"test",
"the",
"round",
"-",
"trip",
"conversion",
"from",
"PyBEL",
"data",
"dictionary",
"to",
"node",
"model",
"."
] | [
"\"\"\"Help test the round-trip conversion from PyBEL data dictionary to node model.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "number_nodes",
"type": "int"
},
{
"param": "number_edges",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_to... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | graph_from_edges | BELGraph | def graph_from_edges(edges: Iterable[Edge], **kwargs) -> BELGraph:
"""Build a BEL graph from edges."""
graph = BELGraph(**kwargs)
graph.raise_on_missing_annotations = False
for edge in edges:
edge.insert_into_graph(graph)
graph.raise_on_missing_annotations = True
return graph | Build a BEL graph from edges. | Build a BEL graph from edges. | [
"Build",
"a",
"BEL",
"graph",
"from",
"edges",
"."
] | def graph_from_edges(edges: Iterable[Edge], **kwargs) -> BELGraph:
graph = BELGraph(**kwargs)
graph.raise_on_missing_annotations = False
for edge in edges:
edge.insert_into_graph(graph)
graph.raise_on_missing_annotations = True
return graph | [
"def",
"graph_from_edges",
"(",
"edges",
":",
"Iterable",
"[",
"Edge",
"]",
",",
"**",
"kwargs",
")",
"->",
"BELGraph",
":",
"graph",
"=",
"BELGraph",
"(",
"**",
"kwargs",
")",
"graph",
".",
"raise_on_missing_annotations",
"=",
"False",
"for",
"edge",
"in"... | Build a BEL graph from edges. | [
"Build",
"a",
"BEL",
"graph",
"from",
"edges",
"."
] | [
"\"\"\"Build a BEL graph from edges.\"\"\""
] | [
{
"param": "edges",
"type": "Iterable[Edge]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "edges",
"type": "Iterable[Edge]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | query_nodes | List[Node] | def query_nodes(
self,
bel: Optional[str] = None,
type: Optional[str] = None,
namespace: Optional[str] = None,
name: Optional[str] = None,
) -> List[Node]:
"""Query nodes in the database.
:param bel: BEL term that describes the biological entity. e.g. ``p(HGN... | Query nodes in the database.
:param bel: BEL term that describes the biological entity. e.g. ``p(HGNC:APP)``
:param type: Type of the biological entity. e.g. Protein
:param namespace: Namespace keyword that is used in BEL. e.g. HGNC
:param name: Name of the biological entity. e.g. APP
... | Query nodes in the database. | [
"Query",
"nodes",
"in",
"the",
"database",
"."
] | def query_nodes(
self,
bel: Optional[str] = None,
type: Optional[str] = None,
namespace: Optional[str] = None,
name: Optional[str] = None,
) -> List[Node]:
q = self.session.query(Node)
if bel:
q = q.filter(Node.bel.ilike(f'%{bel}%'))
if typ... | [
"def",
"query_nodes",
"(",
"self",
",",
"bel",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"type",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"namespace",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"name",
":",
"Optional",... | Query nodes in the database. | [
"Query",
"nodes",
"in",
"the",
"database",
"."
] | [
"\"\"\"Query nodes in the database.\n\n :param bel: BEL term that describes the biological entity. e.g. ``p(HGNC:APP)``\n :param type: Type of the biological entity. e.g. Protein\n :param namespace: Namespace keyword that is used in BEL. e.g. HGNC\n :param name: Name of the biological en... | [
{
"param": "self",
"type": null
},
{
"param": "bel",
"type": "Optional[str]"
},
{
"param": "type",
"type": "Optional[str]"
},
{
"param": "namespace",
"type": "Optional[str]"
},
{
"param": "name",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bel",
"type": "Optional[str]",
"docstring": "BEL term that describe... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | search_edges_with_evidence | List[Edge] | def search_edges_with_evidence(self, evidence: str) -> List[Edge]:
"""Search edges with the given evidence.
:param evidence: A string to search evidences. Can use wildcard percent symbol (%).
"""
return self.session.query(Edge).join(Evidence).filter(Evidence.text.like(evidence)).all() | Search edges with the given evidence.
:param evidence: A string to search evidences. Can use wildcard percent symbol (%).
| Search edges with the given evidence. | [
"Search",
"edges",
"with",
"the",
"given",
"evidence",
"."
] | def search_edges_with_evidence(self, evidence: str) -> List[Edge]:
return self.session.query(Edge).join(Evidence).filter(Evidence.text.like(evidence)).all() | [
"def",
"search_edges_with_evidence",
"(",
"self",
",",
"evidence",
":",
"str",
")",
"->",
"List",
"[",
"Edge",
"]",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"Edge",
")",
".",
"join",
"(",
"Evidence",
")",
".",
"filter",
"(",
"Evidence"... | Search edges with the given evidence. | [
"Search",
"edges",
"with",
"the",
"given",
"evidence",
"."
] | [
"\"\"\"Search edges with the given evidence.\n\n :param evidence: A string to search evidences. Can use wildcard percent symbol (%).\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "evidence",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "evidence",
"type": "str",
"docstring": "A string to search evidence... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | search_edges_with_bel | List[Edge] | def search_edges_with_bel(self, bel: str) -> List[Edge]:
"""Search edges with given BEL.
:param bel: A BEL string to use as a search
"""
return self.session.query(Edge).filter(Edge.bel.like(bel)) | Search edges with given BEL.
:param bel: A BEL string to use as a search
| Search edges with given BEL. | [
"Search",
"edges",
"with",
"given",
"BEL",
"."
] | def search_edges_with_bel(self, bel: str) -> List[Edge]:
return self.session.query(Edge).filter(Edge.bel.like(bel)) | [
"def",
"search_edges_with_bel",
"(",
"self",
",",
"bel",
":",
"str",
")",
"->",
"List",
"[",
"Edge",
"]",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"Edge",
")",
".",
"filter",
"(",
"Edge",
".",
"bel",
".",
"like",
"(",
"bel",
")",
... | Search edges with given BEL. | [
"Search",
"edges",
"with",
"given",
"BEL",
"."
] | [
"\"\"\"Search edges with given BEL.\n\n :param bel: A BEL string to use as a search\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "bel",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bel",
"type": "str",
"docstring": "A BEL string to use as a search"... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | query_edges | <not_specific> | def query_edges(
self,
bel: Optional[str] = None,
source_function: Optional[str] = None,
source: Union[None, str, Node] = None,
target_function: Optional[str] = None,
target: Union[None, str, Node] = None,
relation: Optional[str] = None,
):
"""Return a... | Return a query over the edges in the database.
Usually this means that you should call ``list()`` or ``.all()`` on this result.
:param bel: BEL statement that represents the desired edge.
:param source_function: Filter source nodes with the given BEL function
:param source: BEL term of... | Return a query over the edges in the database. | [
"Return",
"a",
"query",
"over",
"the",
"edges",
"in",
"the",
"database",
"."
] | def query_edges(
self,
bel: Optional[str] = None,
source_function: Optional[str] = None,
source: Union[None, str, Node] = None,
target_function: Optional[str] = None,
target: Union[None, str, Node] = None,
relation: Optional[str] = None,
):
if bel:
... | [
"def",
"query_edges",
"(",
"self",
",",
"bel",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"source_function",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"source",
":",
"Union",
"[",
"None",
",",
"str",
",",
"Node",
"]",
"=",
"None"... | Return a query over the edges in the database. | [
"Return",
"a",
"query",
"over",
"the",
"edges",
"in",
"the",
"database",
"."
] | [
"\"\"\"Return a query over the edges in the database.\n\n Usually this means that you should call ``list()`` or ``.all()`` on this result.\n\n :param bel: BEL statement that represents the desired edge.\n :param source_function: Filter source nodes with the given BEL function\n :param so... | [
{
"param": "self",
"type": null
},
{
"param": "bel",
"type": "Optional[str]"
},
{
"param": "source_function",
"type": "Optional[str]"
},
{
"param": "source",
"type": "Union[None, str, Node]"
},
{
"param": "target_function",
"type": "Optional[str]"
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "bel",
"type": "Optional[str]",
"docstring": "BEL statement that rep... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | query_citations | List[Citation] | def query_citations(
self,
db: Optional[str] = None,
db_id: Optional[str] = None,
name: Optional[str] = None,
author: Union[None, str, List[str]] = None,
date: Union[None, str, datetime.date] = None,
evidence_text: Optional[str] = None,
) -> List[Citation]:
... | Query citations in the database.
:param db: Type of the citation. e.g. PubMed
:param db_id: The identifier used for the citation. e.g. PubMed_ID
:param name: Title of the citation.
:param author: The name or a list of names of authors participated in the citation.
:param date: P... | Query citations in the database. | [
"Query",
"citations",
"in",
"the",
"database",
"."
] | def query_citations(
self,
db: Optional[str] = None,
db_id: Optional[str] = None,
name: Optional[str] = None,
author: Union[None, str, List[str]] = None,
date: Union[None, str, datetime.date] = None,
evidence_text: Optional[str] = None,
) -> List[Citation]:
... | [
"def",
"query_citations",
"(",
"self",
",",
"db",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"db_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"author",
":",
"Union",
... | Query citations in the database. | [
"Query",
"citations",
"in",
"the",
"database",
"."
] | [
"\"\"\"Query citations in the database.\n\n :param db: Type of the citation. e.g. PubMed\n :param db_id: The identifier used for the citation. e.g. PubMed_ID\n :param name: Title of the citation.\n :param author: The name or a list of names of authors participated in the citation.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "db",
"type": "Optional[str]"
},
{
"param": "db_id",
"type": "Optional[str]"
},
{
"param": "name",
"type": "Optional[str]"
},
{
"param": "author",
"type": "Union[None, str, List[str]]"
},
{
"param": "date",... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "db",
"type": "Optional[str]",
"docstring": "Type of the citation. e... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | _edge_both_nodes | <not_specific> | def _edge_both_nodes(nodes: List[Node]):
"""Get edges where both the source and target are in the list of nodes."""
node_ids = [node.id for node in nodes]
return and_(
Edge.source_id.in_(node_ids),
Edge.target_id.in_(node_ids),
) | Get edges where both the source and target are in the list of nodes. | Get edges where both the source and target are in the list of nodes. | [
"Get",
"edges",
"where",
"both",
"the",
"source",
"and",
"target",
"are",
"in",
"the",
"list",
"of",
"nodes",
"."
] | def _edge_both_nodes(nodes: List[Node]):
node_ids = [node.id for node in nodes]
return and_(
Edge.source_id.in_(node_ids),
Edge.target_id.in_(node_ids),
) | [
"def",
"_edge_both_nodes",
"(",
"nodes",
":",
"List",
"[",
"Node",
"]",
")",
":",
"node_ids",
"=",
"[",
"node",
".",
"id",
"for",
"node",
"in",
"nodes",
"]",
"return",
"and_",
"(",
"Edge",
".",
"source_id",
".",
"in_",
"(",
"node_ids",
")",
",",
"E... | Get edges where both the source and target are in the list of nodes. | [
"Get",
"edges",
"where",
"both",
"the",
"source",
"and",
"target",
"are",
"in",
"the",
"list",
"of",
"nodes",
"."
] | [
"\"\"\"Get edges where both the source and target are in the list of nodes.\"\"\""
] | [
{
"param": "nodes",
"type": "List[Node]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "nodes",
"type": "List[Node]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | query_induction | List[Edge] | def query_induction(self, nodes: List[Node]) -> List[Edge]:
"""Get all edges between any of the given nodes (minimum length of 2)."""
if len(nodes) < 2:
raise ValueError('not enough nodes given to induce over')
return self.session.query(Edge).filter(self._edge_both_nodes(nodes)).all... | Get all edges between any of the given nodes (minimum length of 2). | Get all edges between any of the given nodes (minimum length of 2). | [
"Get",
"all",
"edges",
"between",
"any",
"of",
"the",
"given",
"nodes",
"(",
"minimum",
"length",
"of",
"2",
")",
"."
] | def query_induction(self, nodes: List[Node]) -> List[Edge]:
if len(nodes) < 2:
raise ValueError('not enough nodes given to induce over')
return self.session.query(Edge).filter(self._edge_both_nodes(nodes)).all() | [
"def",
"query_induction",
"(",
"self",
",",
"nodes",
":",
"List",
"[",
"Node",
"]",
")",
"->",
"List",
"[",
"Edge",
"]",
":",
"if",
"len",
"(",
"nodes",
")",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'not enough nodes given to induce over'",
")",
"retu... | Get all edges between any of the given nodes (minimum length of 2). | [
"Get",
"all",
"edges",
"between",
"any",
"of",
"the",
"given",
"nodes",
"(",
"minimum",
"length",
"of",
"2",
")",
"."
] | [
"\"\"\"Get all edges between any of the given nodes (minimum length of 2).\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "nodes",
"type": "List[Node]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nodes",
"type": "List[Node]",
"docstring": null,
"docstring_t... |
911cfb04fd59608ef7a95aa4cf16a1a3f65d423e | rpatil524/pybel | src/pybel/manager/query_manager.py | [
"MIT"
] | Python | _edge_one_node | <not_specific> | def _edge_one_node(nodes: List[Node]):
"""Get edges where either the source or target are in the list of nodes.
Note: doing this with the nodes directly is not yet supported by SQLAlchemy
.. code-block:: python
return or_(
Edge.source.in_(nodes),
Ed... | Get edges where either the source or target are in the list of nodes.
Note: doing this with the nodes directly is not yet supported by SQLAlchemy
.. code-block:: python
return or_(
Edge.source.in_(nodes),
Edge.target.in_(nodes),
)
| Get edges where either the source or target are in the list of nodes.
Note: doing this with the nodes directly is not yet supported by SQLAlchemy
code-block:: python
| [
"Get",
"edges",
"where",
"either",
"the",
"source",
"or",
"target",
"are",
"in",
"the",
"list",
"of",
"nodes",
".",
"Note",
":",
"doing",
"this",
"with",
"the",
"nodes",
"directly",
"is",
"not",
"yet",
"supported",
"by",
"SQLAlchemy",
"code",
"-",
"block... | def _edge_one_node(nodes: List[Node]):
node_ids = [node.id for node in nodes]
return or_(
Edge.source_id.in_(node_ids),
Edge.target_id.in_(node_ids),
) | [
"def",
"_edge_one_node",
"(",
"nodes",
":",
"List",
"[",
"Node",
"]",
")",
":",
"node_ids",
"=",
"[",
"node",
".",
"id",
"for",
"node",
"in",
"nodes",
"]",
"return",
"or_",
"(",
"Edge",
".",
"source_id",
".",
"in_",
"(",
"node_ids",
")",
",",
"Edge... | Get edges where either the source or target are in the list of nodes. | [
"Get",
"edges",
"where",
"either",
"the",
"source",
"or",
"target",
"are",
"in",
"the",
"list",
"of",
"nodes",
"."
] | [
"\"\"\"Get edges where either the source or target are in the list of nodes.\n\n Note: doing this with the nodes directly is not yet supported by SQLAlchemy\n\n .. code-block:: python\n\n return or_(\n Edge.source.in_(nodes),\n Edge.target.in_(nodes),\n ... | [
{
"param": "nodes",
"type": "List[Node]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "nodes",
"type": "List[Node]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d6a89bb475cada04714eff7ec0d5e56b51d55f7 | rpatil524/pybel | src/pybel/language.py | [
"MIT"
] | Python | curie | str | def curie(self) -> str:
"""Return this entity as a CURIE."""
return '{}:{}'.format(
self.namespace,
ensure_quotes(self.identifier if self.identifier else self.name),
) | Return this entity as a CURIE. | Return this entity as a CURIE. | [
"Return",
"this",
"entity",
"as",
"a",
"CURIE",
"."
] | def curie(self) -> str:
return '{}:{}'.format(
self.namespace,
ensure_quotes(self.identifier if self.identifier else self.name),
) | [
"def",
"curie",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'{}:{}'",
".",
"format",
"(",
"self",
".",
"namespace",
",",
"ensure_quotes",
"(",
"self",
".",
"identifier",
"if",
"self",
".",
"identifier",
"else",
"self",
".",
"name",
")",
",",
")"
] | Return this entity as a CURIE. | [
"Return",
"this",
"entity",
"as",
"a",
"CURIE",
"."
] | [
"\"\"\"Return this entity as a CURIE.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d6a89bb475cada04714eff7ec0d5e56b51d55f7 | rpatil524/pybel | src/pybel/language.py | [
"MIT"
] | Python | obo | str | def obo(self) -> str:
"""Return this entity as an OBO-style CURIE."""
return '{}:{} ! {}'.format(
self.namespace,
ensure_quotes(self.identifier),
ensure_quotes(self.name),
) | Return this entity as an OBO-style CURIE. | Return this entity as an OBO-style CURIE. | [
"Return",
"this",
"entity",
"as",
"an",
"OBO",
"-",
"style",
"CURIE",
"."
] | def obo(self) -> str:
return '{}:{} ! {}'.format(
self.namespace,
ensure_quotes(self.identifier),
ensure_quotes(self.name),
) | [
"def",
"obo",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'{}:{} ! {}'",
".",
"format",
"(",
"self",
".",
"namespace",
",",
"ensure_quotes",
"(",
"self",
".",
"identifier",
")",
",",
"ensure_quotes",
"(",
"self",
".",
"name",
")",
",",
")"
] | Return this entity as an OBO-style CURIE. | [
"Return",
"this",
"entity",
"as",
"an",
"OBO",
"-",
"style",
"CURIE",
"."
] | [
"\"\"\"Return this entity as an OBO-style CURIE.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d073890732c90c4efbf1e38d875ec12669043c80 | rpatil524/pybel | src/pybel/io/indra.py | [
"MIT"
] | Python | from_indra_statements_json | <not_specific> | def from_indra_statements_json(stmts_json: List[Mapping[str, Any]], **kwargs):
"""Get a BEL graph from INDRA statements JSON.
:rtype: BELGraph
Other kwargs are passed to :func:`from_indra_statements`.
"""
from indra.statements import stmts_from_json
statements = stmts_from_json(stmts_json)
... | Get a BEL graph from INDRA statements JSON.
:rtype: BELGraph
Other kwargs are passed to :func:`from_indra_statements`.
| Get a BEL graph from INDRA statements JSON. | [
"Get",
"a",
"BEL",
"graph",
"from",
"INDRA",
"statements",
"JSON",
"."
] | def from_indra_statements_json(stmts_json: List[Mapping[str, Any]], **kwargs):
from indra.statements import stmts_from_json
statements = stmts_from_json(stmts_json)
return from_indra_statements(statements, **kwargs) | [
"def",
"from_indra_statements_json",
"(",
"stmts_json",
":",
"List",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"**",
"kwargs",
")",
":",
"from",
"indra",
".",
"statements",
"import",
"stmts_from_json",
"statements",
"=",
"stmts_from_json",
"(",
... | Get a BEL graph from INDRA statements JSON. | [
"Get",
"a",
"BEL",
"graph",
"from",
"INDRA",
"statements",
"JSON",
"."
] | [
"\"\"\"Get a BEL graph from INDRA statements JSON.\n\n :rtype: BELGraph\n\n Other kwargs are passed to :func:`from_indra_statements`.\n \"\"\""
] | [
{
"param": "stmts_json",
"type": "List[Mapping[str, Any]]"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "BELGraph\nOther kwargs are passed to :func:`from_indra_statements`."
}
],
"raises": [],
"params": [
{
"identifier": "stmts_json",
"type": "List[Mapping[str, Any]]",
"docstri... |
d073890732c90c4efbf1e38d875ec12669043c80 | rpatil524/pybel | src/pybel/io/indra.py | [
"MIT"
] | Python | from_indra_statements_json_file | <not_specific> | def from_indra_statements_json_file(file, **kwargs):
"""Get a BEL graph from INDRA statements JSON file.
:rtype: BELGraph
Other kwargs are passed to :func:`from_indra_statements`.
"""
return from_indra_statements_json(json.load(file), **kwargs) | Get a BEL graph from INDRA statements JSON file.
:rtype: BELGraph
Other kwargs are passed to :func:`from_indra_statements`.
| Get a BEL graph from INDRA statements JSON file. | [
"Get",
"a",
"BEL",
"graph",
"from",
"INDRA",
"statements",
"JSON",
"file",
"."
] | def from_indra_statements_json_file(file, **kwargs):
return from_indra_statements_json(json.load(file), **kwargs) | [
"def",
"from_indra_statements_json_file",
"(",
"file",
",",
"**",
"kwargs",
")",
":",
"return",
"from_indra_statements_json",
"(",
"json",
".",
"load",
"(",
"file",
")",
",",
"**",
"kwargs",
")"
] | Get a BEL graph from INDRA statements JSON file. | [
"Get",
"a",
"BEL",
"graph",
"from",
"INDRA",
"statements",
"JSON",
"file",
"."
] | [
"\"\"\"Get a BEL graph from INDRA statements JSON file.\n\n :rtype: BELGraph\n\n Other kwargs are passed to :func:`from_indra_statements`.\n \"\"\""
] | [
{
"param": "file",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "BELGraph\nOther kwargs are passed to :func:`from_indra_statements`."
}
],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring... |
d073890732c90c4efbf1e38d875ec12669043c80 | rpatil524/pybel | src/pybel/io/indra.py | [
"MIT"
] | Python | to_indra_statements | <not_specific> | def to_indra_statements(graph):
"""Export this graph as a list of INDRA statements using the :py:class:`indra.sources.pybel.PybelProcessor`.
:param pybel.BELGraph graph: A BEL graph
:rtype: list[indra.statements.Statement]
"""
from indra.sources.bel import process_pybel_graph
pbp = process_pyb... | Export this graph as a list of INDRA statements using the :py:class:`indra.sources.pybel.PybelProcessor`.
:param pybel.BELGraph graph: A BEL graph
:rtype: list[indra.statements.Statement]
| Export this graph as a list of INDRA statements using the :py:class:`indra.sources.pybel.PybelProcessor`. | [
"Export",
"this",
"graph",
"as",
"a",
"list",
"of",
"INDRA",
"statements",
"using",
"the",
":",
"py",
":",
"class",
":",
"`",
"indra",
".",
"sources",
".",
"pybel",
".",
"PybelProcessor",
"`",
"."
] | def to_indra_statements(graph):
from indra.sources.bel import process_pybel_graph
pbp = process_pybel_graph(graph)
return pbp.statements | [
"def",
"to_indra_statements",
"(",
"graph",
")",
":",
"from",
"indra",
".",
"sources",
".",
"bel",
"import",
"process_pybel_graph",
"pbp",
"=",
"process_pybel_graph",
"(",
"graph",
")",
"return",
"pbp",
".",
"statements"
] | Export this graph as a list of INDRA statements using the :py:class:`indra.sources.pybel.PybelProcessor`. | [
"Export",
"this",
"graph",
"as",
"a",
"list",
"of",
"INDRA",
"statements",
"using",
"the",
":",
"py",
":",
"class",
":",
"`",
"indra",
".",
"sources",
".",
"pybel",
".",
"PybelProcessor",
"`",
"."
] | [
"\"\"\"Export this graph as a list of INDRA statements using the :py:class:`indra.sources.pybel.PybelProcessor`.\n\n :param pybel.BELGraph graph: A BEL graph\n :rtype: list[indra.statements.Statement]\n \"\"\""
] | [
{
"param": "graph",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "list[indra.statements.Statement]"
}
],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
... |
d073890732c90c4efbf1e38d875ec12669043c80 | rpatil524/pybel | src/pybel/io/indra.py | [
"MIT"
] | Python | to_indra_statements_json | List[Mapping[str, Any]] | def to_indra_statements_json(graph) -> List[Mapping[str, Any]]:
"""Export this graph as INDRA JSON list.
:param pybel.BELGraph graph: A BEL graph
"""
return [
statement.to_json()
for statement in to_indra_statements(graph)
] | Export this graph as INDRA JSON list.
:param pybel.BELGraph graph: A BEL graph
| Export this graph as INDRA JSON list. | [
"Export",
"this",
"graph",
"as",
"INDRA",
"JSON",
"list",
"."
] | def to_indra_statements_json(graph) -> List[Mapping[str, Any]]:
return [
statement.to_json()
for statement in to_indra_statements(graph)
] | [
"def",
"to_indra_statements_json",
"(",
"graph",
")",
"->",
"List",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"[",
"statement",
".",
"to_json",
"(",
")",
"for",
"statement",
"in",
"to_indra_statements",
"(",
"graph",
")",
"]"
] | Export this graph as INDRA JSON list. | [
"Export",
"this",
"graph",
"as",
"INDRA",
"JSON",
"list",
"."
] | [
"\"\"\"Export this graph as INDRA JSON list.\n\n :param pybel.BELGraph graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
}
],
"outlier_params": [],
"others": []
} |
d073890732c90c4efbf1e38d875ec12669043c80 | rpatil524/pybel | src/pybel/io/indra.py | [
"MIT"
] | Python | to_indra_statements_json_file | null | def to_indra_statements_json_file(graph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs):
"""Export this graph as INDRA statement JSON.
:param pybel.BELGraph graph: A BEL graph
:param path: A writable file or file-like
Other kwargs are passed to :func:`json.dump`.
"""
json.dump(... | Export this graph as INDRA statement JSON.
:param pybel.BELGraph graph: A BEL graph
:param path: A writable file or file-like
Other kwargs are passed to :func:`json.dump`.
| Export this graph as INDRA statement JSON. | [
"Export",
"this",
"graph",
"as",
"INDRA",
"statement",
"JSON",
"."
] | def to_indra_statements_json_file(graph, path: Union[str, TextIO], indent: Optional[int] = 2, **kwargs):
json.dump(to_indra_statements_json(graph), path, indent=indent, **kwargs) | [
"def",
"to_indra_statements_json_file",
"(",
"graph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"indent",
":",
"Optional",
"[",
"int",
"]",
"=",
"2",
",",
"**",
"kwargs",
")",
":",
"json",
".",
"dump",
"(",
"to_indra_statements_json... | Export this graph as INDRA statement JSON. | [
"Export",
"this",
"graph",
"as",
"INDRA",
"statement",
"JSON",
"."
] | [
"\"\"\"Export this graph as INDRA statement JSON.\n\n :param pybel.BELGraph graph: A BEL graph\n :param path: A writable file or file-like\n\n Other kwargs are passed to :func:`json.dump`.\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "indent",
"type": "Optional[int]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
},
{
"identifier": "path",
"typ... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | ground | BELGraph | def ground(
graph: BELGraph,
remove_ungrounded: bool = True,
skip_namespaces: Optional[Collection[str]] = None,
) -> BELGraph:
"""Ground all entities in a BEL graph."""
j = to_nodelink(graph)
ground_nodelink(j, skip_namespaces=skip_namespaces)
graph = from_nodelink(j)
remove_unused_anno... | Ground all entities in a BEL graph. | Ground all entities in a BEL graph. | [
"Ground",
"all",
"entities",
"in",
"a",
"BEL",
"graph",
"."
] | def ground(
graph: BELGraph,
remove_ungrounded: bool = True,
skip_namespaces: Optional[Collection[str]] = None,
) -> BELGraph:
j = to_nodelink(graph)
ground_nodelink(j, skip_namespaces=skip_namespaces)
graph = from_nodelink(j)
remove_unused_annotation_metadata(graph)
if remove_ungrounded... | [
"def",
"ground",
"(",
"graph",
":",
"BELGraph",
",",
"remove_ungrounded",
":",
"bool",
"=",
"True",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
",",
")",
"->",
"BELGraph",
":",
"j",
"=",
"to_nodelink",
... | Ground all entities in a BEL graph. | [
"Ground",
"all",
"entities",
"in",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Ground all entities in a BEL graph.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "remove_ungrounded",
"type": "bool"
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "remove_ungrounded",
"type": "bool",
"docstring": null,
... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | ground_nodelink | None | def ground_nodelink(graph_nodelink_dict, skip_namespaces: Optional[Collection[str]] = None) -> None:
"""Ground entities in a nodelink data structure."""
name = graph_nodelink_dict.get('graph', {}).get('name', 'graph')
for data in tqdm(graph_nodelink_dict['links'], desc='grounding edges in {}'.format(name))... | Ground entities in a nodelink data structure. | Ground entities in a nodelink data structure. | [
"Ground",
"entities",
"in",
"a",
"nodelink",
"data",
"structure",
"."
] | def ground_nodelink(graph_nodelink_dict, skip_namespaces: Optional[Collection[str]] = None) -> None:
name = graph_nodelink_dict.get('graph', {}).get('name', 'graph')
for data in tqdm(graph_nodelink_dict['links'], desc='grounding edges in {}'.format(name)):
_process_edge_side(data.get(SOURCE_MODIFIER), s... | [
"def",
"ground_nodelink",
"(",
"graph_nodelink_dict",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"None",
":",
"name",
"=",
"graph_nodelink_dict",
".",
"get",
"(",
"'graph'",
",",
"{",
"}",
")",... | Ground entities in a nodelink data structure. | [
"Ground",
"entities",
"in",
"a",
"nodelink",
"data",
"structure",
"."
] | [
"\"\"\"Ground entities in a nodelink data structure.\"\"\""
] | [
{
"param": "graph_nodelink_dict",
"type": null
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph_nodelink_dict",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "skip_namespaces",
"type": "Optional[Collection[str]]",
... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | _process_annotations | None | def _process_annotations(
data,
remove_ungrounded: bool = False,
skip_namespaces: Optional[Collection[str]] = None,
) -> None:
"""Process the annotations in a PyBEL edge data dictionary."""
cell_line_entities = data[ANNOTATIONS].get('CellLine')
if cell_line_entities:
ne = []
for ... | Process the annotations in a PyBEL edge data dictionary. | Process the annotations in a PyBEL edge data dictionary. | [
"Process",
"the",
"annotations",
"in",
"a",
"PyBEL",
"edge",
"data",
"dictionary",
"."
] | def _process_annotations(
data,
remove_ungrounded: bool = False,
skip_namespaces: Optional[Collection[str]] = None,
) -> None:
cell_line_entities = data[ANNOTATIONS].get('CellLine')
if cell_line_entities:
ne = []
for entity in cell_line_entities:
if entity[NAMESPACE] == '... | [
"def",
"_process_annotations",
"(",
"data",
",",
"remove_ungrounded",
":",
"bool",
"=",
"False",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"cell_line_entities",
"=",
"data",
... | Process the annotations in a PyBEL edge data dictionary. | [
"Process",
"the",
"annotations",
"in",
"a",
"PyBEL",
"edge",
"data",
"dictionary",
"."
] | [
"\"\"\"Process the annotations in a PyBEL edge data dictionary.\"\"\"",
"# 'clo', # FIXME implement CLO in PyOBO then uncomment",
"# fix text locations",
"# remap category names",
"# fix namespaces that were categories before"
] | [
{
"param": "data",
"type": null
},
{
"param": "remove_ungrounded",
"type": "bool"
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "remove_ungrounded",
"type": "bool",
"docstring": null,
"docst... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | _process_edge_side | bool | def _process_edge_side(side_data, skip_namespaces: Optional[Collection[str]] = None) -> bool:
"""Process an edge JSON object, in place."""
if side_data is None:
return True
modifier = side_data.get(MODIFIER)
effect = side_data.get(EFFECT)
if modifier == ACTIVITY and effect is not None:
... | Process an edge JSON object, in place. | Process an edge JSON object, in place. | [
"Process",
"an",
"edge",
"JSON",
"object",
"in",
"place",
"."
] | def _process_edge_side(side_data, skip_namespaces: Optional[Collection[str]] = None) -> bool:
if side_data is None:
return True
modifier = side_data.get(MODIFIER)
effect = side_data.get(EFFECT)
if modifier == ACTIVITY and effect is not None:
_process_concept(concept=effect, skip_namespac... | [
"def",
"_process_edge_side",
"(",
"side_data",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"side_data",
"is",
"None",
":",
"return",
"True",
"modifier",
"=",
"side_data",
".",... | Process an edge JSON object, in place. | [
"Process",
"an",
"edge",
"JSON",
"object",
"in",
"place",
"."
] | [
"\"\"\"Process an edge JSON object, in place.\"\"\""
] | [
{
"param": "side_data",
"type": null
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "side_data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "skip_namespaces",
"type": "Optional[Collection[str]]",
"docstr... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | _process_node | bool | def _process_node(node: Mapping[str, Any], skip_namespaces: Optional[Collection[str]] = None) -> bool:
"""Process a node JSON object, in place.
:return: If all parts of the node were successfully grounded
"""
success = True
if CONCEPT in node:
success = success and _process_concept(concept=... | Process a node JSON object, in place.
:return: If all parts of the node were successfully grounded
| Process a node JSON object, in place. | [
"Process",
"a",
"node",
"JSON",
"object",
"in",
"place",
"."
] | def _process_node(node: Mapping[str, Any], skip_namespaces: Optional[Collection[str]] = None) -> bool:
success = True
if CONCEPT in node:
success = success and _process_concept(concept=node[CONCEPT], node=node, skip_namespaces=skip_namespaces)
if VARIANTS in node:
success = success and _proc... | [
"def",
"_process_node",
"(",
"node",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"success",
"=",
"True",
"if",
"CONCEPT",
"in",
"n... | Process a node JSON object, in place. | [
"Process",
"a",
"node",
"JSON",
"object",
"in",
"place",
"."
] | [
"\"\"\"Process a node JSON object, in place.\n\n :return: If all parts of the node were successfully grounded\n \"\"\""
] | [
{
"param": "node",
"type": "Mapping[str, Any]"
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [
{
"docstring": "If all parts of the node were successfully grounded",
"docstring_tokens": [
"If",
"all",
"parts",
"of",
"the",
"node",
"were",
"successfully",
"grounded"
],
"type": null
}
],
"rai... |
952bdb2fc14989ac8dbf2f334a395583dd6c10ab | rpatil524/pybel | src/pybel/grounding.py | [
"MIT"
] | Python | _process_concept | bool | def _process_concept(*, concept, node=None, skip_namespaces: Optional[Collection[str]] = None) -> bool:
"""Process a node JSON object."""
namespace = concept[NAMESPACE]
if namespace.lower() in {'text', 'fixme'}:
return False
if skip_namespaces and namespace in skip_namespaces:
return Tr... | Process a node JSON object. | Process a node JSON object. | [
"Process",
"a",
"node",
"JSON",
"object",
"."
] | def _process_concept(*, concept, node=None, skip_namespaces: Optional[Collection[str]] = None) -> bool:
namespace = concept[NAMESPACE]
if namespace.lower() in {'text', 'fixme'}:
return False
if skip_namespaces and namespace in skip_namespaces:
return True
prefix = normalize_prefix(namesp... | [
"def",
"_process_concept",
"(",
"*",
",",
"concept",
",",
"node",
"=",
"None",
",",
"skip_namespaces",
":",
"Optional",
"[",
"Collection",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"bool",
":",
"namespace",
"=",
"concept",
"[",
"NAMESPACE",
"]",
"i... | Process a node JSON object. | [
"Process",
"a",
"node",
"JSON",
"object",
"."
] | [
"\"\"\"Process a node JSON object.\"\"\"",
"# don't trust whatever was put for the name, even if it's available",
"# just in case the name gets put in the identifier"
] | [
{
"param": "concept",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "skip_namespaces",
"type": "Optional[Collection[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "concept",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": null,
"docstring": null,
"docstring_tokens"... |
686b4c819916f23657157a6420c55dfe80e149a3 | rpatil524/pybel | src/pybel/parser/parse_metadata.py | [
"MIT"
] | Python | raise_for_redefined_namespace | None | def raise_for_redefined_namespace(self, line: str, position: int, namespace: str) -> None:
"""Raise an exception if a namespace is already defined.
:raises: RedefinedNamespaceError
"""
if self.disallow_redefinition and self.has_namespace(namespace):
raise RedefinedNamespaceE... | Raise an exception if a namespace is already defined.
:raises: RedefinedNamespaceError
| Raise an exception if a namespace is already defined. | [
"Raise",
"an",
"exception",
"if",
"a",
"namespace",
"is",
"already",
"defined",
"."
] | def raise_for_redefined_namespace(self, line: str, position: int, namespace: str) -> None:
if self.disallow_redefinition and self.has_namespace(namespace):
raise RedefinedNamespaceError(self.get_line_number(), line, position, namespace) | [
"def",
"raise_for_redefined_namespace",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"namespace",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"disallow_redefinition",
"and",
"self",
".",
"has_namespace",
"(",
"namespace"... | Raise an exception if a namespace is already defined. | [
"Raise",
"an",
"exception",
"if",
"a",
"namespace",
"is",
"already",
"defined",
"."
] | [
"\"\"\"Raise an exception if a namespace is already defined.\n\n :raises: RedefinedNamespaceError\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "namespace",
"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
... |
686b4c819916f23657157a6420c55dfe80e149a3 | rpatil524/pybel | src/pybel/parser/parse_metadata.py | [
"MIT"
] | Python | ensure_resources | <not_specific> | def ensure_resources(self):
"""Load all namespaces/annotations that have been encountered so far during parsing."""
if self.skip_validation:
return
if self.namespace_url_dict:
keywords, urls = zip(*self.namespace_url_dict.items())
namespaces = self.manager._e... | Load all namespaces/annotations that have been encountered so far during parsing. | Load all namespaces/annotations that have been encountered so far during parsing. | [
"Load",
"all",
"namespaces",
"/",
"annotations",
"that",
"have",
"been",
"encountered",
"so",
"far",
"during",
"parsing",
"."
] | def ensure_resources(self):
if self.skip_validation:
return
if self.namespace_url_dict:
keywords, urls = zip(*self.namespace_url_dict.items())
namespaces = self.manager._ensure_namespace_urls(urls)
for keyword, namespace in zip(keywords, namespaces):
... | [
"def",
"ensure_resources",
"(",
"self",
")",
":",
"if",
"self",
".",
"skip_validation",
":",
"return",
"if",
"self",
".",
"namespace_url_dict",
":",
"keywords",
",",
"urls",
"=",
"zip",
"(",
"*",
"self",
".",
"namespace_url_dict",
".",
"items",
"(",
")",
... | Load all namespaces/annotations that have been encountered so far during parsing. | [
"Load",
"all",
"namespaces",
"/",
"annotations",
"that",
"have",
"been",
"encountered",
"so",
"far",
"during",
"parsing",
"."
] | [
"\"\"\"Load all namespaces/annotations that have been encountered so far during parsing.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
686b4c819916f23657157a6420c55dfe80e149a3 | rpatil524/pybel | src/pybel/parser/parse_metadata.py | [
"MIT"
] | Python | raise_for_redefined_annotation | None | def raise_for_redefined_annotation(self, line: str, position: int, annotation: str) -> None:
"""Raise an exception if the given annotation is already defined.
:raises: RedefinedAnnotationError
"""
if self.disallow_redefinition and self.has_annotation(annotation):
raise Redef... | Raise an exception if the given annotation is already defined.
:raises: RedefinedAnnotationError
| Raise an exception if the given annotation is already defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"given",
"annotation",
"is",
"already",
"defined",
"."
] | def raise_for_redefined_annotation(self, line: str, position: int, annotation: str) -> None:
if self.disallow_redefinition and self.has_annotation(annotation):
raise RedefinedAnnotationError(self.get_line_number(), line, position, annotation) | [
"def",
"raise_for_redefined_annotation",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"annotation",
":",
"str",
")",
"->",
"None",
":",
"if",
"self",
".",
"disallow_redefinition",
"and",
"self",
".",
"has_annotation",
"(",
"annotat... | Raise an exception if the given annotation is already defined. | [
"Raise",
"an",
"exception",
"if",
"the",
"given",
"annotation",
"is",
"already",
"defined",
"."
] | [
"\"\"\"Raise an exception if the given annotation is already defined.\n\n :raises: RedefinedAnnotationError\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
... |
686b4c819916f23657157a6420c55dfe80e149a3 | rpatil524/pybel | src/pybel/parser/parse_metadata.py | [
"MIT"
] | Python | has_annotation | bool | def has_annotation(self, annotation: str) -> bool:
"""Check if this annotation is defined."""
return (
self.has_enumerated_annotation(annotation)
or self.has_regex_annotation(annotation)
or self.has_local_annotation(annotation)
) | Check if this annotation is defined. | Check if this annotation is defined. | [
"Check",
"if",
"this",
"annotation",
"is",
"defined",
"."
] | def has_annotation(self, annotation: str) -> bool:
return (
self.has_enumerated_annotation(annotation)
or self.has_regex_annotation(annotation)
or self.has_local_annotation(annotation)
) | [
"def",
"has_annotation",
"(",
"self",
",",
"annotation",
":",
"str",
")",
"->",
"bool",
":",
"return",
"(",
"self",
".",
"has_enumerated_annotation",
"(",
"annotation",
")",
"or",
"self",
".",
"has_regex_annotation",
"(",
"annotation",
")",
"or",
"self",
"."... | Check if this annotation is defined. | [
"Check",
"if",
"this",
"annotation",
"is",
"defined",
"."
] | [
"\"\"\"Check if this annotation is defined.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "annotation",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "annotation",
"type": "str",
"docstring": null,
"docstring_tok... |
686b4c819916f23657157a6420c55dfe80e149a3 | rpatil524/pybel | src/pybel/parser/parse_metadata.py | [
"MIT"
] | Python | raise_for_version | None | def raise_for_version(self, line: str, position: int, version: str) -> None:
"""Check that a version string is valid for BEL documents.
This means it's either in the YYYYMMDD or semantic version format.
:param line: The line being parsed
:param position: The position in the line being ... | Check that a version string is valid for BEL documents.
This means it's either in the YYYYMMDD or semantic version format.
:param line: The line being parsed
:param position: The position in the line being parsed
:param str version: A version string
:raises: VersionFormatWarnin... | Check that a version string is valid for BEL documents.
This means it's either in the YYYYMMDD or semantic version format. | [
"Check",
"that",
"a",
"version",
"string",
"is",
"valid",
"for",
"BEL",
"documents",
".",
"This",
"means",
"it",
"'",
"s",
"either",
"in",
"the",
"YYYYMMDD",
"or",
"semantic",
"version",
"format",
"."
] | def raise_for_version(self, line: str, position: int, version: str) -> None:
if valid_date_version(version):
return
if not SEMANTIC_VERSION_STRING_RE.match(version):
raise VersionFormatWarning(self.get_line_number(), line, position, version) | [
"def",
"raise_for_version",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"version",
":",
"str",
")",
"->",
"None",
":",
"if",
"valid_date_version",
"(",
"version",
")",
":",
"return",
"if",
"not",
"SEMANTIC_VERSION_STRING_RE",
".... | Check that a version string is valid for BEL documents. | [
"Check",
"that",
"a",
"version",
"string",
"is",
"valid",
"for",
"BEL",
"documents",
"."
] | [
"\"\"\"Check that a version string is valid for BEL documents.\n\n This means it's either in the YYYYMMDD or semantic version format.\n\n :param line: The line being parsed\n :param position: The position in the line being parsed\n :param str version: A version string\n :raises: V... | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "version",
"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
... |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | parse_datetime | datetime.date | def parse_datetime(s: str) -> datetime.date:
"""Try to parse a datetime object from a standard datetime format or date format."""
for fmt in (CREATION_DATE_FMT, PUBLISHED_DATE_FMT, PUBLISHED_DATE_FMT_2):
try:
dt = datetime.strptime(s, fmt)
except ValueError:
pass
... | Try to parse a datetime object from a standard datetime format or date format. | Try to parse a datetime object from a standard datetime format or date format. | [
"Try",
"to",
"parse",
"a",
"datetime",
"object",
"from",
"a",
"standard",
"datetime",
"format",
"or",
"date",
"format",
"."
] | def parse_datetime(s: str) -> datetime.date:
for fmt in (CREATION_DATE_FMT, PUBLISHED_DATE_FMT, PUBLISHED_DATE_FMT_2):
try:
dt = datetime.strptime(s, fmt)
except ValueError:
pass
else:
return dt
raise ValueError('Incorrect datetime format for {}'.forma... | [
"def",
"parse_datetime",
"(",
"s",
":",
"str",
")",
"->",
"datetime",
".",
"date",
":",
"for",
"fmt",
"in",
"(",
"CREATION_DATE_FMT",
",",
"PUBLISHED_DATE_FMT",
",",
"PUBLISHED_DATE_FMT_2",
")",
":",
"try",
":",
"dt",
"=",
"datetime",
".",
"strptime",
"(",... | Try to parse a datetime object from a standard datetime format or date format. | [
"Try",
"to",
"parse",
"a",
"datetime",
"object",
"from",
"a",
"standard",
"datetime",
"format",
"or",
"date",
"format",
"."
] | [
"\"\"\"Try to parse a datetime object from a standard datetime format or date format.\"\"\""
] | [
{
"param": "s",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | hash_edge | str | def hash_edge(source, target, edge_data: EdgeData) -> str:
"""Convert an edge tuple to a MD5 hash.
:param BaseEntity source: The source BEL node
:param BaseEntity target: The target BEL node
:param edge_data: The edge's data dictionary
:return: A hashed version of the edge tuple using MD5 hash of t... | Convert an edge tuple to a MD5 hash.
:param BaseEntity source: The source BEL node
:param BaseEntity target: The target BEL node
:param edge_data: The edge's data dictionary
:return: A hashed version of the edge tuple using MD5 hash of the binary pickle dump of u, v, and the json dump
of d
| Convert an edge tuple to a MD5 hash. | [
"Convert",
"an",
"edge",
"tuple",
"to",
"a",
"MD5",
"hash",
"."
] | def hash_edge(source, target, edge_data: EdgeData) -> str:
edge_tuple = _get_edge_tuple(source, target, edge_data)
edge_tuple_bytes = pickle.dumps(edge_tuple)
return hashlib.md5(edge_tuple_bytes).hexdigest() | [
"def",
"hash_edge",
"(",
"source",
",",
"target",
",",
"edge_data",
":",
"EdgeData",
")",
"->",
"str",
":",
"edge_tuple",
"=",
"_get_edge_tuple",
"(",
"source",
",",
"target",
",",
"edge_data",
")",
"edge_tuple_bytes",
"=",
"pickle",
".",
"dumps",
"(",
"ed... | Convert an edge tuple to a MD5 hash. | [
"Convert",
"an",
"edge",
"tuple",
"to",
"a",
"MD5",
"hash",
"."
] | [
"\"\"\"Convert an edge tuple to a MD5 hash.\n\n :param BaseEntity source: The source BEL node\n :param BaseEntity target: The target BEL node\n :param edge_data: The edge's data dictionary\n :return: A hashed version of the edge tuple using MD5 hash of the binary pickle dump of u, v, and the json dump\n... | [
{
"param": "source",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [
{
"docstring": "A hashed version of the edge tuple using MD5 hash of the binary pickle dump of u, v, and the json dump\nof d",
"docstring_tokens": [
"A",
"hashed",
"version",
"of",
"the",
"edge",
"tuple",
"using",
"... |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | _get_edge_tuple | Tuple[str, str, Optional[str], Optional[str], CanonicalEdge] | def _get_edge_tuple(
source,
target,
edge_data: EdgeData,
) -> Tuple[str, str, Optional[str], Optional[str], CanonicalEdge]:
"""Convert an edge to a consistent tuple.
:param BaseEntity source: The source BEL node
:param BaseEntity target: The target BEL node
:param edge_data: The edge's dat... | Convert an edge to a consistent tuple.
:param BaseEntity source: The source BEL node
:param BaseEntity target: The target BEL node
:param edge_data: The edge's data dictionary
:return: A tuple that can be hashed representing this edge. Makes no promises to its structure.
| Convert an edge to a consistent tuple. | [
"Convert",
"an",
"edge",
"to",
"a",
"consistent",
"tuple",
"."
] | def _get_edge_tuple(
source,
target,
edge_data: EdgeData,
) -> Tuple[str, str, Optional[str], Optional[str], CanonicalEdge]:
return (
source.as_bel(),
target.as_bel(),
_get_citation_str(edge_data),
edge_data.get(EVIDENCE),
canonicalize_edge(edge_data),
) | [
"def",
"_get_edge_tuple",
"(",
"source",
",",
"target",
",",
"edge_data",
":",
"EdgeData",
",",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
",",
"Optional",
"[",
"str",
"]",
",",
"Optional",
"[",
"str",
"]",
",",
"CanonicalEdge",
"]",
":",
"return",
... | Convert an edge to a consistent tuple. | [
"Convert",
"an",
"edge",
"to",
"a",
"consistent",
"tuple",
"."
] | [
"\"\"\"Convert an edge to a consistent tuple.\n\n :param BaseEntity source: The source BEL node\n :param BaseEntity target: The target BEL node\n :param edge_data: The edge's data dictionary\n :return: A tuple that can be hashed representing this edge. Makes no promises to its structure.\n \"\"\""
] | [
{
"param": "source",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [
{
"docstring": "A tuple that can be hashed representing this edge. Makes no promises to its structure.",
"docstring_tokens": [
"A",
"tuple",
"that",
"can",
"be",
"hashed",
"representing",
"this",
"edge",
"."... |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | subdict_matches | bool | def subdict_matches(target: Mapping, query: Mapping, partial_match: bool = True) -> bool:
"""Check if all the keys in the query dict are in the target dict, and that their values match.
1. Checks that all keys in the query dict are in the target dict
2. Matches the values of the keys in the query dict
... | Check if all the keys in the query dict are in the target dict, and that their values match.
1. Checks that all keys in the query dict are in the target dict
2. Matches the values of the keys in the query dict
a. If the value is a string, then must match exactly
b. If the value is a set/list/tu... | Check if all the keys in the query dict are in the target dict, and that their values match.
1. Checks that all keys in the query dict are in the target dict
2. Matches the values of the keys in the query dict
a. If the value is a string, then must match exactly
b. If the value is a set/list/tuple, then will match any ... | [
"Check",
"if",
"all",
"the",
"keys",
"in",
"the",
"query",
"dict",
"are",
"in",
"the",
"target",
"dict",
"and",
"that",
"their",
"values",
"match",
".",
"1",
".",
"Checks",
"that",
"all",
"keys",
"in",
"the",
"query",
"dict",
"are",
"in",
"the",
"tar... | def subdict_matches(target: Mapping, query: Mapping, partial_match: bool = True) -> bool:
for k, v in query.items():
if k not in target:
return False
elif not isinstance(v, (int, str, dict, Iterable)):
raise ValueError('invalid value: {}'.format(v))
elif isinstance(v,... | [
"def",
"subdict_matches",
"(",
"target",
":",
"Mapping",
",",
"query",
":",
"Mapping",
",",
"partial_match",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"for",
"k",
",",
"v",
"in",
"query",
".",
"items",
"(",
")",
":",
"if",
"k",
"not",
"in",... | Check if all the keys in the query dict are in the target dict, and that their values match. | [
"Check",
"if",
"all",
"the",
"keys",
"in",
"the",
"query",
"dict",
"are",
"in",
"the",
"target",
"dict",
"and",
"that",
"their",
"values",
"match",
"."
] | [
"\"\"\"Check if all the keys in the query dict are in the target dict, and that their values match.\n\n 1. Checks that all keys in the query dict are in the target dict\n 2. Matches the values of the keys in the query dict\n a. If the value is a string, then must match exactly\n b. If the value ... | [
{
"param": "target",
"type": "Mapping"
},
{
"param": "query",
"type": "Mapping"
},
{
"param": "partial_match",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "if all keys in b are in target_dict and their values match",
"docstring_tokens": [
"if",
"all",
"keys",
"in",
"b",
"are",
"in",
"target_dict",
"and",
"their",
"values",
"match... |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | hash_dump | str | def hash_dump(data) -> str:
"""Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes.
:param data: An arbitrary JSON-serializable object
:type data: dict or list or tuple
"""
return hashlib.md5(json.dumps(data, sort_keys=True).encode('utf-8'))... | Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes.
:param data: An arbitrary JSON-serializable object
:type data: dict or list or tuple
| Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes. | [
"Hash",
"an",
"arbitrary",
"JSON",
"dictionary",
"by",
"dumping",
"it",
"in",
"sorted",
"order",
"encoding",
"it",
"in",
"UTF",
"-",
"8",
"then",
"hashing",
"the",
"bytes",
"."
] | def hash_dump(data) -> str:
return hashlib.md5(json.dumps(data, sort_keys=True).encode('utf-8')).hexdigest() | [
"def",
"hash_dump",
"(",
"data",
")",
"->",
"str",
":",
"return",
"hashlib",
".",
"md5",
"(",
"json",
".",
"dumps",
"(",
"data",
",",
"sort_keys",
"=",
"True",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"hexdigest",
"(",
")"
] | Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes. | [
"Hash",
"an",
"arbitrary",
"JSON",
"dictionary",
"by",
"dumping",
"it",
"in",
"sorted",
"order",
"encoding",
"it",
"in",
"UTF",
"-",
"8",
"then",
"hashing",
"the",
"bytes",
"."
] | [
"\"\"\"Hash an arbitrary JSON dictionary by dumping it in sorted order, encoding it in UTF-8, then hashing the bytes.\n\n :param data: An arbitrary JSON-serializable object\n :type data: dict or list or tuple\n \"\"\""
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": "An arbitrary JSON-serializable object",
"docstring_tokens": [
"An",
"arbitrary",
"JSON",
"-",
"serializable",
"object"
],
"default"... |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | canonicalize_edge | CanonicalEdge | def canonicalize_edge(edge_data: EdgeData) -> CanonicalEdge:
"""Canonicalize the edge to a tuple based on the relation, subject modifications, and object modifications."""
return (
edge_data[RELATION],
_canonicalize_edge_modifications(edge_data.get(SOURCE_MODIFIER)),
_canonicalize_edge_m... | Canonicalize the edge to a tuple based on the relation, subject modifications, and object modifications. | Canonicalize the edge to a tuple based on the relation, subject modifications, and object modifications. | [
"Canonicalize",
"the",
"edge",
"to",
"a",
"tuple",
"based",
"on",
"the",
"relation",
"subject",
"modifications",
"and",
"object",
"modifications",
"."
] | def canonicalize_edge(edge_data: EdgeData) -> CanonicalEdge:
return (
edge_data[RELATION],
_canonicalize_edge_modifications(edge_data.get(SOURCE_MODIFIER)),
_canonicalize_edge_modifications(edge_data.get(TARGET_MODIFIER)),
) | [
"def",
"canonicalize_edge",
"(",
"edge_data",
":",
"EdgeData",
")",
"->",
"CanonicalEdge",
":",
"return",
"(",
"edge_data",
"[",
"RELATION",
"]",
",",
"_canonicalize_edge_modifications",
"(",
"edge_data",
".",
"get",
"(",
"SOURCE_MODIFIER",
")",
")",
",",
"_cano... | Canonicalize the edge to a tuple based on the relation, subject modifications, and object modifications. | [
"Canonicalize",
"the",
"edge",
"to",
"a",
"tuple",
"based",
"on",
"the",
"relation",
"subject",
"modifications",
"and",
"object",
"modifications",
"."
] | [
"\"\"\"Canonicalize the edge to a tuple based on the relation, subject modifications, and object modifications.\"\"\""
] | [
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "edge_data",
"type": "EdgeData",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | _canonicalize_edge_modifications | Optional[Tuple] | def _canonicalize_edge_modifications(edge_data: EdgeData) -> Optional[Tuple]:
"""Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple."""
if edge_data is None:
return
modifier = edge_data.get(MODIFIER)
location = edge_data.get(LOCATION)
effect = edge_data.... | Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple. | Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple. | [
"Return",
"the",
"SUBJECT",
"or",
"OBJECT",
"entry",
"of",
"a",
"PyBEL",
"edge",
"data",
"dictionary",
"as",
"a",
"canonical",
"tuple",
"."
] | def _canonicalize_edge_modifications(edge_data: EdgeData) -> Optional[Tuple]:
if edge_data is None:
return
modifier = edge_data.get(MODIFIER)
location = edge_data.get(LOCATION)
effect = edge_data.get(EFFECT)
if modifier is None and location is None:
return
result = []
if modi... | [
"def",
"_canonicalize_edge_modifications",
"(",
"edge_data",
":",
"EdgeData",
")",
"->",
"Optional",
"[",
"Tuple",
"]",
":",
"if",
"edge_data",
"is",
"None",
":",
"return",
"modifier",
"=",
"edge_data",
".",
"get",
"(",
"MODIFIER",
")",
"location",
"=",
"edg... | Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple. | [
"Return",
"the",
"SUBJECT",
"or",
"OBJECT",
"entry",
"of",
"a",
"PyBEL",
"edge",
"data",
"dictionary",
"as",
"a",
"canonical",
"tuple",
"."
] | [
"\"\"\"Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple.\"\"\""
] | [
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "edge_data",
"type": "EdgeData",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba07f14df13c34e764db27e00c63c095245f3658 | rpatil524/pybel | src/pybel/utils.py | [
"MIT"
] | Python | multidict | Mapping[X, List[Y]] | def multidict(pairs: typing.Iterable[Tuple[X, Y]]) -> Mapping[X, List[Y]]:
"""Accumulate a multidict from a list of pairs."""
rv = defaultdict(list)
for key, value in pairs:
rv[key].append(value)
return dict(rv) | Accumulate a multidict from a list of pairs. | Accumulate a multidict from a list of pairs. | [
"Accumulate",
"a",
"multidict",
"from",
"a",
"list",
"of",
"pairs",
"."
] | def multidict(pairs: typing.Iterable[Tuple[X, Y]]) -> Mapping[X, List[Y]]:
rv = defaultdict(list)
for key, value in pairs:
rv[key].append(value)
return dict(rv) | [
"def",
"multidict",
"(",
"pairs",
":",
"typing",
".",
"Iterable",
"[",
"Tuple",
"[",
"X",
",",
"Y",
"]",
"]",
")",
"->",
"Mapping",
"[",
"X",
",",
"List",
"[",
"Y",
"]",
"]",
":",
"rv",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"key",
",",
... | Accumulate a multidict from a list of pairs. | [
"Accumulate",
"a",
"multidict",
"from",
"a",
"list",
"of",
"pairs",
"."
] | [
"\"\"\"Accumulate a multidict from a list of pairs.\"\"\""
] | [
{
"param": "pairs",
"type": "typing.Iterable[Tuple[X, Y]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pairs",
"type": "typing.Iterable[Tuple[X, Y]]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | update_provenance | None | def update_provenance(control_parser: ControlParser) -> None:
"""Put a default evidence and citation in a BEL parser."""
control_parser.citation_db = test_citation_dict.namespace
control_parser.citation_db_id = test_citation_dict.identifier
control_parser.evidence = test_evidence_text | Put a default evidence and citation in a BEL parser. | Put a default evidence and citation in a BEL parser. | [
"Put",
"a",
"default",
"evidence",
"and",
"citation",
"in",
"a",
"BEL",
"parser",
"."
] | def update_provenance(control_parser: ControlParser) -> None:
control_parser.citation_db = test_citation_dict.namespace
control_parser.citation_db_id = test_citation_dict.identifier
control_parser.evidence = test_evidence_text | [
"def",
"update_provenance",
"(",
"control_parser",
":",
"ControlParser",
")",
"->",
"None",
":",
"control_parser",
".",
"citation_db",
"=",
"test_citation_dict",
".",
"namespace",
"control_parser",
".",
"citation_db_id",
"=",
"test_citation_dict",
".",
"identifier",
"... | Put a default evidence and citation in a BEL parser. | [
"Put",
"a",
"default",
"evidence",
"and",
"citation",
"in",
"a",
"BEL",
"parser",
"."
] | [
"\"\"\"Put a default evidence and citation in a BEL parser.\"\"\""
] | [
{
"param": "control_parser",
"type": "ControlParser"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "control_parser",
"type": "ControlParser",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | assert_has_node | null | def assert_has_node(self: unittest.TestCase, node: BaseEntity, graph: BELGraph, **kwargs):
"""Check if a node with the given properties is contained within a graph."""
self.assertIsInstance(node, BaseEntity)
self.assertIn(
node,
graph,
msg='{} not found in graph. Other nodes:\n{}'.f... | Check if a node with the given properties is contained within a graph. | Check if a node with the given properties is contained within a graph. | [
"Check",
"if",
"a",
"node",
"with",
"the",
"given",
"properties",
"is",
"contained",
"within",
"a",
"graph",
"."
] | def assert_has_node(self: unittest.TestCase, node: BaseEntity, graph: BELGraph, **kwargs):
self.assertIsInstance(node, BaseEntity)
self.assertIn(
node,
graph,
msg='{} not found in graph. Other nodes:\n{}'.format(node.as_bel(), '\n'.join(
n.as_bel()
for n in graph
... | [
"def",
"assert_has_node",
"(",
"self",
":",
"unittest",
".",
"TestCase",
",",
"node",
":",
"BaseEntity",
",",
"graph",
":",
"BELGraph",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"assertIsInstance",
"(",
"node",
",",
"BaseEntity",
")",
"self",
".",
"ass... | Check if a node with the given properties is contained within a graph. | [
"Check",
"if",
"a",
"node",
"with",
"the",
"given",
"properties",
"is",
"contained",
"within",
"a",
"graph",
"."
] | [
"\"\"\"Check if a node with the given properties is contained within a graph.\"\"\""
] | [
{
"param": "self",
"type": "unittest.TestCase"
},
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "unittest.TestCase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | any_subdict_matches | bool | def any_subdict_matches(dict_of_dicts, query_dict) -> bool:
"""Checks if dictionary target_dict matches one of the subdictionaries of a
:param dict[any,dict] dict_of_dicts: dictionary of dictionaries
:param dict query_dict: dictionary
:return: if dictionary target_dict matches one of the subdictionarie... | Checks if dictionary target_dict matches one of the subdictionaries of a
:param dict[any,dict] dict_of_dicts: dictionary of dictionaries
:param dict query_dict: dictionary
:return: if dictionary target_dict matches one of the subdictionaries of a
| Checks if dictionary target_dict matches one of the subdictionaries of a | [
"Checks",
"if",
"dictionary",
"target_dict",
"matches",
"one",
"of",
"the",
"subdictionaries",
"of",
"a"
] | def any_subdict_matches(dict_of_dicts, query_dict) -> bool:
return any(
subdict_matches(sub_dict, query_dict)
for sub_dict in dict_of_dicts.values()
) | [
"def",
"any_subdict_matches",
"(",
"dict_of_dicts",
",",
"query_dict",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"subdict_matches",
"(",
"sub_dict",
",",
"query_dict",
")",
"for",
"sub_dict",
"in",
"dict_of_dicts",
".",
"values",
"(",
")",
")"
] | Checks if dictionary target_dict matches one of the subdictionaries of a | [
"Checks",
"if",
"dictionary",
"target_dict",
"matches",
"one",
"of",
"the",
"subdictionaries",
"of",
"a"
] | [
"\"\"\"Checks if dictionary target_dict matches one of the subdictionaries of a\n\n :param dict[any,dict] dict_of_dicts: dictionary of dictionaries\n :param dict query_dict: dictionary\n :return: if dictionary target_dict matches one of the subdictionaries of a\n \"\"\""
] | [
{
"param": "dict_of_dicts",
"type": null
},
{
"param": "query_dict",
"type": null
}
] | {
"returns": [
{
"docstring": "if dictionary target_dict matches one of the subdictionaries of a",
"docstring_tokens": [
"if",
"dictionary",
"target_dict",
"matches",
"one",
"of",
"the",
"subdictionaries",
"of",
"a"
... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | assert_has_edge | <not_specific> | def assert_has_edge(
self: unittest.TestCase,
u: BaseEntity,
v: BaseEntity,
graph: BELGraph,
*,
only: bool = False,
permissive: bool = True,
use_identifiers: bool = False,
**expected_edge_data
):
"""A helper function for checking if an edge with the given properties is contained ... | A helper function for checking if an edge with the given properties is contained within a graph. | A helper function for checking if an edge with the given properties is contained within a graph. | [
"A",
"helper",
"function",
"for",
"checking",
"if",
"an",
"edge",
"with",
"the",
"given",
"properties",
"is",
"contained",
"within",
"a",
"graph",
"."
] | def assert_has_edge(
self: unittest.TestCase,
u: BaseEntity,
v: BaseEntity,
graph: BELGraph,
*,
only: bool = False,
permissive: bool = True,
use_identifiers: bool = False,
**expected_edge_data
):
self.assertIsInstance(u, BaseEntity)
self.assertIsInstance(v, BaseEntity)
se... | [
"def",
"assert_has_edge",
"(",
"self",
":",
"unittest",
".",
"TestCase",
",",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"graph",
":",
"BELGraph",
",",
"*",
",",
"only",
":",
"bool",
"=",
"False",
",",
"permissive",
":",
"bool",
"=",
"... | A helper function for checking if an edge with the given properties is contained within a graph. | [
"A",
"helper",
"function",
"for",
"checking",
"if",
"an",
"edge",
"with",
"the",
"given",
"properties",
"is",
"contained",
"within",
"a",
"graph",
"."
] | [
"\"\"\"A helper function for checking if an edge with the given properties is contained within a graph.\"\"\""
] | [
{
"param": "self",
"type": "unittest.TestCase"
},
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "only",
"type": "bool"
},
{
"param": "permissive",
"type": "bool"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": "unittest.TestCase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | help_check_hgnc | None | def help_check_hgnc(test_case: unittest.TestCase, namespace_dict) -> None:
"""Assert that the namespace dictionary is correct."""
test_case.assertIn(HGNC_KEYWORD, namespace_dict)
mhs2 = '7071', 'MHS2'
test_case.assertIn(mhs2, namespace_dict[HGNC_KEYWORD])
test_case.assertEqual(set('G'), set(namespa... | Assert that the namespace dictionary is correct. | Assert that the namespace dictionary is correct. | [
"Assert",
"that",
"the",
"namespace",
"dictionary",
"is",
"correct",
"."
] | def help_check_hgnc(test_case: unittest.TestCase, namespace_dict) -> None:
test_case.assertIn(HGNC_KEYWORD, namespace_dict)
mhs2 = '7071', 'MHS2'
test_case.assertIn(mhs2, namespace_dict[HGNC_KEYWORD])
test_case.assertEqual(set('G'), set(namespace_dict[HGNC_KEYWORD][mhs2]))
miatnb = '50731', 'MIATNB'... | [
"def",
"help_check_hgnc",
"(",
"test_case",
":",
"unittest",
".",
"TestCase",
",",
"namespace_dict",
")",
"->",
"None",
":",
"test_case",
".",
"assertIn",
"(",
"HGNC_KEYWORD",
",",
"namespace_dict",
")",
"mhs2",
"=",
"'7071'",
",",
"'MHS2'",
"test_case",
".",
... | Assert that the namespace dictionary is correct. | [
"Assert",
"that",
"the",
"namespace",
"dictionary",
"is",
"correct",
"."
] | [
"\"\"\"Assert that the namespace dictionary is correct.\"\"\""
] | [
{
"param": "test_case",
"type": "unittest.TestCase"
},
{
"param": "namespace_dict",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_case",
"type": "unittest.TestCase",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "namespace_dict",
"type": null,
"docstring": nul... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | bel_simple_reconstituted | null | def bel_simple_reconstituted(self, graph: BELGraph, check_metadata: bool = True):
"""Check that test_bel.bel was loaded properly."""
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
if check_metadata:
self.assertIsNotNone(graph.document)
self.as... | Check that test_bel.bel was loaded properly. | Check that test_bel.bel was loaded properly. | [
"Check",
"that",
"test_bel",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | def bel_simple_reconstituted(self, graph: BELGraph, check_metadata: bool = True):
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
if check_metadata:
self.assertIsNotNone(graph.document)
self.assertEqual(expected_test_simple_metadata[METADATA_NAME], grap... | [
"def",
"bel_simple_reconstituted",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"check_metadata",
":",
"bool",
"=",
"True",
")",
":",
"self",
".",
"assertIsNotNone",
"(",
"graph",
")",
"self",
".",
"assertIsInstance",
"(",
"graph",
",",
"BELGraph",
")",
... | Check that test_bel.bel was loaded properly. | [
"Check",
"that",
"test_bel",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | [
"\"\"\"Check that test_bel.bel was loaded properly.\"\"\"",
"# FIXME this should work, but is getting 8 for the upgrade function",
"# self.assertEqual(6, graph.number_of_edges(),",
"# msg='Edges:\\n{}'.format('\\n'.join(map(str, graph.edges(keys=True, data=True)))))"
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "check_metadata",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | bel_thorough_reconstituted | null | def bel_thorough_reconstituted(
self,
graph: BELGraph,
check_metadata: bool = True,
check_warnings: bool = True,
check_provenance: bool = True,
check_citation_name: bool = True,
check_path: bool = True,
):
"""Check that thorough.bel was loaded properly... | Check that thorough.bel was loaded properly.
:param graph: A BEL graph
:param check_metadata: Check the graph's document section is correct
:param check_warnings: Check the graph produced the expected warnings
:param check_provenance: Check the graph's definition section is correct
... | Check that thorough.bel was loaded properly. | [
"Check",
"that",
"thorough",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | def bel_thorough_reconstituted(
self,
graph: BELGraph,
check_metadata: bool = True,
check_warnings: bool = True,
check_provenance: bool = True,
check_citation_name: bool = True,
check_path: bool = True,
):
self.assertIsNotNone(graph)
self.asser... | [
"def",
"bel_thorough_reconstituted",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"check_metadata",
":",
"bool",
"=",
"True",
",",
"check_warnings",
":",
"bool",
"=",
"True",
",",
"check_provenance",
":",
"bool",
"=",
"True",
",",
"check_citation_name",
":... | Check that thorough.bel was loaded properly. | [
"Check",
"that",
"thorough",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | [
"\"\"\"Check that thorough.bel was loaded properly.\n\n :param graph: A BEL graph\n :param check_metadata: Check the graph's document section is correct\n :param check_warnings: Check the graph produced the expected warnings\n :param check_provenance: Check the graph's definition section... | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "check_metadata",
"type": "bool"
},
{
"param": "check_warnings",
"type": "bool"
},
{
"param": "check_provenance",
"type": "bool"
},
{
"param": "check_citation_name"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docs... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | bel_slushy_reconstituted | null | def bel_slushy_reconstituted(self, graph: BELGraph, check_metadata: bool = True, check_warnings: bool = True):
"""Check that slushy.bel was loaded properly."""
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
if check_metadata:
self.assertIsNotNone(graph.do... | Check that slushy.bel was loaded properly. | Check that slushy.bel was loaded properly. | [
"Check",
"that",
"slushy",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | def bel_slushy_reconstituted(self, graph: BELGraph, check_metadata: bool = True, check_warnings: bool = True):
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
if check_metadata:
self.assertIsNotNone(graph.document)
self.assertIsInstance(graph.document, ... | [
"def",
"bel_slushy_reconstituted",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"check_metadata",
":",
"bool",
"=",
"True",
",",
"check_warnings",
":",
"bool",
"=",
"True",
")",
":",
"self",
".",
"assertIsNotNone",
"(",
"graph",
")",
"self",
".",
"asse... | Check that slushy.bel was loaded properly. | [
"Check",
"that",
"slushy",
".",
"bel",
"was",
"loaded",
"properly",
"."
] | [
"\"\"\"Check that slushy.bel was loaded properly.\"\"\"",
"# (95, Exception),"
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "check_metadata",
"type": "bool"
},
{
"param": "check_warnings",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
67cdd4102a935f03f99c3f76e22ef0dfe1fb3b4f | rpatil524/pybel | tests/constants.py | [
"MIT"
] | Python | bel_isolated_reconstituted | null | def bel_isolated_reconstituted(self, graph: BELGraph):
"""Run the isolated node test."""
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
adgrb1 = Protein(namespace='HGNC', name='ADGRB1')
adgrb2 = Protein(namespace='HGNC', name='ADGRB2')
adgrb_complex =... | Run the isolated node test. | Run the isolated node test. | [
"Run",
"the",
"isolated",
"node",
"test",
"."
] | def bel_isolated_reconstituted(self, graph: BELGraph):
self.assertIsNotNone(graph)
self.assertIsInstance(graph, BELGraph)
adgrb1 = Protein(namespace='HGNC', name='ADGRB1')
adgrb2 = Protein(namespace='HGNC', name='ADGRB2')
adgrb_complex = ComplexAbundance([adgrb1, adgrb2])
... | [
"def",
"bel_isolated_reconstituted",
"(",
"self",
",",
"graph",
":",
"BELGraph",
")",
":",
"self",
".",
"assertIsNotNone",
"(",
"graph",
")",
"self",
".",
"assertIsInstance",
"(",
"graph",
",",
"BELGraph",
")",
"adgrb1",
"=",
"Protein",
"(",
"namespace",
"="... | Run the isolated node test. | [
"Run",
"the",
"isolated",
"node",
"test",
"."
] | [
"\"\"\"Run the isolated node test.\"\"\""
] | [
{
"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... |
7c523fa018e3c8047c3854debe8045cc377c69d6 | rpatil524/pybel | src/pybel/io/triples/api.py | [
"MIT"
] | Python | to_triples_file | None | def to_triples_file(
graph: BELGraph,
path: Union[str, TextIO],
*,
use_tqdm: bool = False,
sep='\t',
raise_on_none: bool = False
) -> None:
"""Write the graph as a TSV.
:param graph: A BEL graph
:param path: A path or file-like
:param use_tqdm: Should a progress bar be shown?
... | Write the graph as a TSV.
:param graph: A BEL graph
:param path: A path or file-like
:param use_tqdm: Should a progress bar be shown?
:param sep: The separator to use
:param raise_on_none: Should an exception be raised if no triples are returned?
:raises: NoTriplesValueError
| Write the graph as a TSV. | [
"Write",
"the",
"graph",
"as",
"a",
"TSV",
"."
] | def to_triples_file(
graph: BELGraph,
path: Union[str, TextIO],
*,
use_tqdm: bool = False,
sep='\t',
raise_on_none: bool = False
) -> None:
for h, r, t in to_triples(graph, use_tqdm=use_tqdm, raise_on_none=raise_on_none):
print(h, r, t, sep=sep, file=path) | [
"def",
"to_triples_file",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"*",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
",",
"sep",
"=",
"'\\t'",
",",
"raise_on_none",
":",
"bool",
"=",
"False",
")",
... | Write the graph as a TSV. | [
"Write",
"the",
"graph",
"as",
"a",
"TSV",
"."
] | [
"\"\"\"Write the graph as a TSV.\n\n :param graph: A BEL graph\n :param path: A path or file-like\n :param use_tqdm: Should a progress bar be shown?\n :param sep: The separator to use\n :param raise_on_none: Should an exception be raised if no triples are returned?\n :raises: NoTriplesValueError\n... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "use_tqdm",
"type": "bool"
},
{
"param": "sep",
"type": null
},
{
"param": "raise_on_none",
"type": "bool"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"... |
7c523fa018e3c8047c3854debe8045cc377c69d6 | rpatil524/pybel | src/pybel/io/triples/api.py | [
"MIT"
] | Python | to_edgelist | None | def to_edgelist(
graph: BELGraph,
path: Union[str, TextIO],
*,
use_tqdm: bool = False,
sep='\t',
raise_on_none: bool = False
) -> None:
"""Write the graph as an edgelist.
:param graph: A BEL graph
:param path: A path or file-like
:param use_tqdm: Should a progress bar be shown?
... | Write the graph as an edgelist.
:param graph: A BEL graph
:param path: A path or file-like
:param use_tqdm: Should a progress bar be shown?
:param sep: The separator to use
:param raise_on_none: Should an exception be raised if no triples are returned?
:raises: NoTriplesValueError
| Write the graph as an edgelist. | [
"Write",
"the",
"graph",
"as",
"an",
"edgelist",
"."
] | def to_edgelist(
graph: BELGraph,
path: Union[str, TextIO],
*,
use_tqdm: bool = False,
sep='\t',
raise_on_none: bool = False
) -> None:
for h, r, t in to_triples(graph, use_tqdm=use_tqdm, raise_on_none=raise_on_none):
print(h, t, json.dumps(dict(relation=r)), sep=sep, file=path) | [
"def",
"to_edgelist",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"*",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
",",
"sep",
"=",
"'\\t'",
",",
"raise_on_none",
":",
"bool",
"=",
"False",
")",
"-... | Write the graph as an edgelist. | [
"Write",
"the",
"graph",
"as",
"an",
"edgelist",
"."
] | [
"\"\"\"Write the graph as an edgelist.\n\n :param graph: A BEL graph\n :param path: A path or file-like\n :param use_tqdm: Should a progress bar be shown?\n :param sep: The separator to use\n :param raise_on_none: Should an exception be raised if no triples are returned?\n :raises: NoTriplesValueE... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "use_tqdm",
"type": "bool"
},
{
"param": "sep",
"type": null
},
{
"param": "raise_on_none",
"type": "bool"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"... |
7c523fa018e3c8047c3854debe8045cc377c69d6 | rpatil524/pybel | src/pybel/io/triples/api.py | [
"MIT"
] | Python | to_triples | List[Tuple[str, str, str]] | def to_triples(graph: BELGraph, use_tqdm: bool = False, raise_on_none: bool = False) -> List[Tuple[str, str, str]]:
"""Get a non-redundant list of triples representing the graph.
:param graph: A BEL graph
:param use_tqdm: Should a progress bar be shown?
:param raise_on_none: Should an exception be rais... | Get a non-redundant list of triples representing the graph.
:param graph: A BEL graph
:param use_tqdm: Should a progress bar be shown?
:param raise_on_none: Should an exception be raised if no triples are returned?
:raises: NoTriplesValueError
| Get a non-redundant list of triples representing the graph. | [
"Get",
"a",
"non",
"-",
"redundant",
"list",
"of",
"triples",
"representing",
"the",
"graph",
"."
] | def to_triples(graph: BELGraph, use_tqdm: bool = False, raise_on_none: bool = False) -> List[Tuple[str, str, str]]:
it = graph.edges(keys=True)
if use_tqdm:
it = tqdm(
it,
total=graph.number_of_edges(),
desc='Preparing TSV for {}'.format(graph),
unit_scale... | [
"def",
"to_triples",
"(",
"graph",
":",
"BELGraph",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
",",
"raise_on_none",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
"]",
":",
"it",
"=",
"graph",... | Get a non-redundant list of triples representing the graph. | [
"Get",
"a",
"non",
"-",
"redundant",
"list",
"of",
"triples",
"representing",
"the",
"graph",
"."
] | [
"\"\"\"Get a non-redundant list of triples representing the graph.\n\n :param graph: A BEL graph\n :param use_tqdm: Should a progress bar be shown?\n :param raise_on_none: Should an exception be raised if no triples are returned?\n :raises: NoTriplesValueError\n \"\"\"",
"# clean duplicates and Non... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "use_tqdm",
"type": "bool"
},
{
"param": "raise_on_none",
"type": "bool"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"... |
7c523fa018e3c8047c3854debe8045cc377c69d6 | rpatil524/pybel | src/pybel/io/triples/api.py | [
"MIT"
] | Python | to_triple | Optional[Tuple[str, str, str]] | def to_triple(
graph: BELGraph,
u: BaseEntity,
v: BaseEntity,
key: str,
) -> Optional[Tuple[str, str, str]]: # noqa: C901
"""Get the triples' strings that should be written to the file."""
data = graph[u][v][key]
# order is important
_converters = [
converters.ListComplexHasCom... | Get the triples' strings that should be written to the file. | Get the triples' strings that should be written to the file. | [
"Get",
"the",
"triples",
"'",
"strings",
"that",
"should",
"be",
"written",
"to",
"the",
"file",
"."
] | def to_triple(
graph: BELGraph,
u: BaseEntity,
v: BaseEntity,
key: str,
) -> Optional[Tuple[str, str, str]]:
data = graph[u][v][key]
_converters = [
converters.ListComplexHasComponentConverter,
converters.PartOfNamedComplexConverter,
converters.SubprocessPartOfBiologica... | [
"def",
"to_triple",
"(",
"graph",
":",
"BELGraph",
",",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"key",
":",
"str",
",",
")",
"->",
"Optional",
"[",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
"]",
":",
"data",
"=",
"graph"... | Get the triples' strings that should be written to the file. | [
"Get",
"the",
"triples",
"'",
"strings",
"that",
"should",
"be",
"written",
"to",
"the",
"file",
"."
] | [
"# noqa: C901",
"\"\"\"Get the triples' strings that should be written to the file.\"\"\"",
"# order is important"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "key",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"docstrin... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | to_bel_script | None | def to_bel_script(graph, path: Union[str, TextIO], use_identifiers: bool = True) -> None:
"""Write the BELGraph as a canonical BEL script.
:param BELGraph graph: the BEL Graph to output as a BEL Script
:param path: A path or file-like.
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.... | Write the BELGraph as a canonical BEL script.
:param BELGraph graph: the BEL Graph to output as a BEL Script
:param path: A path or file-like.
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
| Write the BELGraph as a canonical BEL script. | [
"Write",
"the",
"BELGraph",
"as",
"a",
"canonical",
"BEL",
"script",
"."
] | def to_bel_script(graph, path: Union[str, TextIO], use_identifiers: bool = True) -> None:
for line in to_bel_script_lines(graph, use_identifiers=use_identifiers):
print(line, file=path) | [
"def",
"to_bel_script",
"(",
"graph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"for",
"line",
"in",
"to_bel_script_lines",
"(",
"graph",
",",
"use_identifiers",
"... | Write the BELGraph as a canonical BEL script. | [
"Write",
"the",
"BELGraph",
"as",
"a",
"canonical",
"BEL",
"script",
"."
] | [
"\"\"\"Write the BELGraph as a canonical BEL script.\n\n :param BELGraph graph: the BEL Graph to output as a BEL Script\n :param path: A path or file-like.\n :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "the BEL Graph to output as a BEL Script",
"docstring_tokens": [
"the",
"BEL",
"Graph",
"to",
"output",
"as",
"a",
"BEL",
... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | to_bel_script_lines | Iterable[str] | def to_bel_script_lines(graph, use_identifiers: bool = True) -> Iterable[str]:
"""Iterate over the lines of the BEL graph as a canonical BEL script.
:param pybel.BELGraph graph: A BEL Graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
"""
... | Iterate over the lines of the BEL graph as a canonical BEL script.
:param pybel.BELGraph graph: A BEL Graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
| Iterate over the lines of the BEL graph as a canonical BEL script. | [
"Iterate",
"over",
"the",
"lines",
"of",
"the",
"BEL",
"graph",
"as",
"a",
"canonical",
"BEL",
"script",
"."
] | def to_bel_script_lines(graph, use_identifiers: bool = True) -> Iterable[str]:
return itt.chain(
_to_bel_lines_header(graph),
_to_bel_lines_body(graph, use_identifiers=use_identifiers),
_to_bel_lines_footer(graph, use_identifiers=use_identifiers),
) | [
"def",
"to_bel_script_lines",
"(",
"graph",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"return",
"itt",
".",
"chain",
"(",
"_to_bel_lines_header",
"(",
"graph",
")",
",",
"_to_bel_lines_body",
"(",
"graph",... | Iterate over the lines of the BEL graph as a canonical BEL script. | [
"Iterate",
"over",
"the",
"lines",
"of",
"the",
"BEL",
"graph",
"as",
"a",
"canonical",
"BEL",
"script",
"."
] | [
"\"\"\"Iterate over the lines of the BEL graph as a canonical BEL script.\n\n :param pybel.BELGraph graph: A BEL Graph\n :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL Graph",
"docstring_tokens": [
"A",
"BEL",
"Graph"
],
"default": null,
"is_optional": false
},
{
"identifier": "use_identifiers",... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | postpend_location | str | def postpend_location(bel_string: str, location_model) -> str:
"""Rip off the closing parentheses and adds canonicalized modification.
I did this because writing a whole new parsing model for the data would be sad and difficult
:param bel_string: BEL string representing node
:param dict location_model... | Rip off the closing parentheses and adds canonicalized modification.
I did this because writing a whole new parsing model for the data would be sad and difficult
:param bel_string: BEL string representing node
:param dict location_model: A dictionary containing keys :code:`pybel.constants.TO_LOC` and
... | Rip off the closing parentheses and adds canonicalized modification.
I did this because writing a whole new parsing model for the data would be sad and difficult | [
"Rip",
"off",
"the",
"closing",
"parentheses",
"and",
"adds",
"canonicalized",
"modification",
".",
"I",
"did",
"this",
"because",
"writing",
"a",
"whole",
"new",
"parsing",
"model",
"for",
"the",
"data",
"would",
"be",
"sad",
"and",
"difficult"
] | def postpend_location(bel_string: str, location_model) -> str:
if not all(k in location_model for k in {NAMESPACE, NAME}):
raise ValueError('Location model missing namespace and/or name keys: {}'.format(location_model))
return "{}, loc({}:{}))".format(
bel_string[:-1],
location_model[NAM... | [
"def",
"postpend_location",
"(",
"bel_string",
":",
"str",
",",
"location_model",
")",
"->",
"str",
":",
"if",
"not",
"all",
"(",
"k",
"in",
"location_model",
"for",
"k",
"in",
"{",
"NAMESPACE",
",",
"NAME",
"}",
")",
":",
"raise",
"ValueError",
"(",
"... | Rip off the closing parentheses and adds canonicalized modification. | [
"Rip",
"off",
"the",
"closing",
"parentheses",
"and",
"adds",
"canonicalized",
"modification",
"."
] | [
"\"\"\"Rip off the closing parentheses and adds canonicalized modification.\n\n I did this because writing a whole new parsing model for the data would be sad and difficult\n\n :param bel_string: BEL string representing node\n :param dict location_model: A dictionary containing keys :code:`pybel.constants.... | [
{
"param": "bel_string",
"type": "str"
},
{
"param": "location_model",
"type": null
}
] | {
"returns": [
{
"docstring": "A part of a BEL string representing the location",
"docstring_tokens": [
"A",
"part",
"of",
"a",
"BEL",
"string",
"representing",
"the",
"location"
],
"type": null
}
],
"raises": ... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _decanonicalize_edge_node | str | def _decanonicalize_edge_node(
node: BaseEntity,
edge_data: EdgeData,
node_position: str,
*,
use_identifiers: bool = True
) -> str:
"""Canonicalize a node with its modifiers stored in the given edge to a BEL string.
:param node: A PyBEL node data dictionary
:param edge_data: A PyBEL edg... | Canonicalize a node with its modifiers stored in the given edge to a BEL string.
:param node: A PyBEL node data dictionary
:param edge_data: A PyBEL edge data dictionary
:param node_position: Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`
:param use_identifiers: Enables extend... | Canonicalize a node with its modifiers stored in the given edge to a BEL string. | [
"Canonicalize",
"a",
"node",
"with",
"its",
"modifiers",
"stored",
"in",
"the",
"given",
"edge",
"to",
"a",
"BEL",
"string",
"."
] | def _decanonicalize_edge_node(
node: BaseEntity,
edge_data: EdgeData,
node_position: str,
*,
use_identifiers: bool = True
) -> str:
node_str = node.as_bel(use_identifiers=use_identifiers)
if node_position not in edge_data:
return node_str
node_edge_data = edge_data[node_position]... | [
"def",
"_decanonicalize_edge_node",
"(",
"node",
":",
"BaseEntity",
",",
"edge_data",
":",
"EdgeData",
",",
"node_position",
":",
"str",
",",
"*",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"node_str",
"=",
"node",
".",
"as_be... | Canonicalize a node with its modifiers stored in the given edge to a BEL string. | [
"Canonicalize",
"a",
"node",
"with",
"its",
"modifiers",
"stored",
"in",
"the",
"given",
"edge",
"to",
"a",
"BEL",
"string",
"."
] | [
"\"\"\"Canonicalize a node with its modifiers stored in the given edge to a BEL string.\n\n :param node: A PyBEL node data dictionary\n :param edge_data: A PyBEL edge data dictionary\n :param node_position: Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`\n :param use_identifiers... | [
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "edge_data",
"type": "EdgeData"
},
{
"param": "node_position",
"type": "str"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "BaseEntity",
"docstring": "A PyBEL node data dictionary",
"docstring_tokens": [
"A",
"PyBEL",
"node",
"data",
"dictionary"
],
"default": null,
"is_optio... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | edge_to_tuple | Tuple[str, str, str] | def edge_to_tuple(
source: BaseEntity,
target: BaseEntity,
data: EdgeData,
use_identifiers: bool = True,
) -> Tuple[str, str, str]:
"""Take two nodes and gives back a BEL string representing the statement.
:param source: The edge's source's PyBEL node data dictionary
:param target: The edge... | Take two nodes and gives back a BEL string representing the statement.
:param source: The edge's source's PyBEL node data dictionary
:param target: The edge's target's PyBEL node data dictionary
:param data: The edge's data dictionary
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.b... | Take two nodes and gives back a BEL string representing the statement. | [
"Take",
"two",
"nodes",
"and",
"gives",
"back",
"a",
"BEL",
"string",
"representing",
"the",
"statement",
"."
] | def edge_to_tuple(
source: BaseEntity,
target: BaseEntity,
data: EdgeData,
use_identifiers: bool = True,
) -> Tuple[str, str, str]:
u_str = _decanonicalize_edge_node(source, data, node_position=SOURCE_MODIFIER, use_identifiers=use_identifiers)
v_str = _decanonicalize_edge_node(target, data, node... | [
"def",
"edge_to_tuple",
"(",
"source",
":",
"BaseEntity",
",",
"target",
":",
"BaseEntity",
",",
"data",
":",
"EdgeData",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
":",
"u_str",
... | Take two nodes and gives back a BEL string representing the statement. | [
"Take",
"two",
"nodes",
"and",
"gives",
"back",
"a",
"BEL",
"string",
"representing",
"the",
"statement",
"."
] | [
"\"\"\"Take two nodes and gives back a BEL string representing the statement.\n\n :param source: The edge's source's PyBEL node data dictionary\n :param target: The edge's target's PyBEL node data dictionary\n :param data: The edge's data dictionary\n :param use_identifiers: Enables extended `BEP-0008 <... | [
{
"param": "source",
"type": "BaseEntity"
},
{
"param": "target",
"type": "BaseEntity"
},
{
"param": "data",
"type": "EdgeData"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": "BaseEntity",
"docstring": "The edge's source's PyBEL node data dictionary",
"docstring_tokens": [
"The",
"edge",
"'",
"s",
"source",
"'",
"s",
"... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | edge_to_bel | str | def edge_to_bel(
source: BaseEntity,
target: BaseEntity,
data: EdgeData,
sep: Optional[str] = None,
use_identifiers: bool = True,
) -> str:
"""Take two nodes and gives back a BEL string representing the statement.
:param source: The edge's source's PyBEL node data dictionary
:param targ... | Take two nodes and gives back a BEL string representing the statement.
:param source: The edge's source's PyBEL node data dictionary
:param target: The edge's target's PyBEL node data dictionary
:param data: The edge's data dictionary
:param sep: The separator between the source, relation, and target. ... | Take two nodes and gives back a BEL string representing the statement. | [
"Take",
"two",
"nodes",
"and",
"gives",
"back",
"a",
"BEL",
"string",
"representing",
"the",
"statement",
"."
] | def edge_to_bel(
source: BaseEntity,
target: BaseEntity,
data: EdgeData,
sep: Optional[str] = None,
use_identifiers: bool = True,
) -> str:
sep = sep or ' '
return sep.join(edge_to_tuple(source=source, target=target, data=data, use_identifiers=use_identifiers)) | [
"def",
"edge_to_bel",
"(",
"source",
":",
"BaseEntity",
",",
"target",
":",
"BaseEntity",
",",
"data",
":",
"EdgeData",
",",
"sep",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
")",
"->",
"str",
... | Take two nodes and gives back a BEL string representing the statement. | [
"Take",
"two",
"nodes",
"and",
"gives",
"back",
"a",
"BEL",
"string",
"representing",
"the",
"statement",
"."
] | [
"\"\"\"Take two nodes and gives back a BEL string representing the statement.\n\n :param source: The edge's source's PyBEL node data dictionary\n :param target: The edge's target's PyBEL node data dictionary\n :param data: The edge's data dictionary\n :param sep: The separator between the source, relati... | [
{
"param": "source",
"type": "BaseEntity"
},
{
"param": "target",
"type": "BaseEntity"
},
{
"param": "data",
"type": "EdgeData"
},
{
"param": "sep",
"type": "Optional[str]"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": "BaseEntity",
"docstring": "The edge's source's PyBEL node data dictionary",
"docstring_tokens": [
"The",
"edge",
"'",
"s",
"source",
"'",
"s",
"... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | sort_qualified_edges | Iterable[EdgeTuple] | def sort_qualified_edges(graph) -> Iterable[EdgeTuple]:
"""Return the qualified edges, sorted first by citation, then by evidence, then by annotations.
:param BELGraph graph: A BEL graph
"""
qualified_edges = (
(u, v, k, d)
for u, v, k, d in graph.edges(keys=True, data=True)
if ... | Return the qualified edges, sorted first by citation, then by evidence, then by annotations.
:param BELGraph graph: A BEL graph
| Return the qualified edges, sorted first by citation, then by evidence, then by annotations. | [
"Return",
"the",
"qualified",
"edges",
"sorted",
"first",
"by",
"citation",
"then",
"by",
"evidence",
"then",
"by",
"annotations",
"."
] | def sort_qualified_edges(graph) -> Iterable[EdgeTuple]:
qualified_edges = (
(u, v, k, d)
for u, v, k, d in graph.edges(keys=True, data=True)
if graph.has_edge_citation(u, v, k) and graph.has_edge_evidence(u, v, k)
)
return sorted(qualified_edges, key=_sort_qualified_edges_helper) | [
"def",
"sort_qualified_edges",
"(",
"graph",
")",
"->",
"Iterable",
"[",
"EdgeTuple",
"]",
":",
"qualified_edges",
"=",
"(",
"(",
"u",
",",
"v",
",",
"k",
",",
"d",
")",
"for",
"u",
",",
"v",
",",
"k",
",",
"d",
"in",
"graph",
".",
"edges",
"(",
... | Return the qualified edges, sorted first by citation, then by evidence, then by annotations. | [
"Return",
"the",
"qualified",
"edges",
"sorted",
"first",
"by",
"citation",
"then",
"by",
"evidence",
"then",
"by",
"annotations",
"."
] | [
"\"\"\"Return the qualified edges, sorted first by citation, then by evidence, then by annotations.\n\n :param BELGraph graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
}
],
"outlier_params": [],
"others": []
} |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _set_annotation_to_str | str | def _set_annotation_to_str(annotation_data: Mapping[str, List[Entity]], key: str, use_curie: bool = False) -> str:
"""Return a set annotation string."""
value = annotation_data[key]
if len(value) == 1:
value = list(value)[0]
return f'SET {key} = "{value if use_curie else value.identifier}"'... | Return a set annotation string. | Return a set annotation string. | [
"Return",
"a",
"set",
"annotation",
"string",
"."
] | def _set_annotation_to_str(annotation_data: Mapping[str, List[Entity]], key: str, use_curie: bool = False) -> str:
value = annotation_data[key]
if len(value) == 1:
value = list(value)[0]
return f'SET {key} = "{value if use_curie else value.identifier}"'
value_strings = ', '.join(
f'"... | [
"def",
"_set_annotation_to_str",
"(",
"annotation_data",
":",
"Mapping",
"[",
"str",
",",
"List",
"[",
"Entity",
"]",
"]",
",",
"key",
":",
"str",
",",
"use_curie",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"value",
"=",
"annotation_data",
"[",
... | Return a set annotation string. | [
"Return",
"a",
"set",
"annotation",
"string",
"."
] | [
"\"\"\"Return a set annotation string.\"\"\""
] | [
{
"param": "annotation_data",
"type": "Mapping[str, List[Entity]]"
},
{
"param": "key",
"type": "str"
},
{
"param": "use_curie",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "annotation_data",
"type": "Mapping[str, List[Entity]]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "str",
"docstring"... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _unset_annotation_to_str | str | def _unset_annotation_to_str(keys: List[str]) -> str:
"""Return an unset annotation string."""
if len(keys) == 1:
return 'UNSET {}'.format(list(keys)[0])
return 'UNSET {{{}}}'.format(', '.join('{}'.format(key) for key in keys)) | Return an unset annotation string. | Return an unset annotation string. | [
"Return",
"an",
"unset",
"annotation",
"string",
"."
] | def _unset_annotation_to_str(keys: List[str]) -> str:
if len(keys) == 1:
return 'UNSET {}'.format(list(keys)[0])
return 'UNSET {{{}}}'.format(', '.join('{}'.format(key) for key in keys)) | [
"def",
"_unset_annotation_to_str",
"(",
"keys",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"1",
":",
"return",
"'UNSET {}'",
".",
"format",
"(",
"list",
"(",
"keys",
")",
"[",
"0",
"]",
")",
"return",
... | Return an unset annotation string. | [
"Return",
"an",
"unset",
"annotation",
"string",
"."
] | [
"\"\"\"Return an unset annotation string.\"\"\""
] | [
{
"param": "keys",
"type": "List[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "keys",
"type": "List[str]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _to_bel_lines_header | Iterable[str] | def _to_bel_lines_header(graph) -> Iterable[str]:
"""Iterate the lines of a BEL graph's corresponding BEL script's header.
:param pybel.BELGraph graph: A BEL graph
"""
yield '# This document was created by PyBEL v{} and bel-resources v{} on {}\n'.format(
VERSION, bel_resources.constants.VERSION... | Iterate the lines of a BEL graph's corresponding BEL script's header.
:param pybel.BELGraph graph: A BEL graph
| Iterate the lines of a BEL graph's corresponding BEL script's header. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"header",
"."
] | def _to_bel_lines_header(graph) -> Iterable[str]:
yield '# This document was created by PyBEL v{} and bel-resources v{} on {}\n'.format(
VERSION, bel_resources.constants.VERSION, time.asctime(),
)
yield from make_knowledge_header(
namespace_url=graph.namespace_url,
namespace_patterns... | [
"def",
"_to_bel_lines_header",
"(",
"graph",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"yield",
"'# This document was created by PyBEL v{} and bel-resources v{} on {}\\n'",
".",
"format",
"(",
"VERSION",
",",
"bel_resources",
".",
"constants",
".",
"VERSION",
",",
... | Iterate the lines of a BEL graph's corresponding BEL script's header. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"header",
"."
] | [
"\"\"\"Iterate the lines of a BEL graph's corresponding BEL script's header.\n\n :param pybel.BELGraph graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
}
],
"outlier_params": [],
"others": []
} |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _to_bel_lines_body | Iterable[str] | def _to_bel_lines_body(graph, use_identifiers: bool = False) -> Iterable[str]:
"""Iterate the lines of a BEL graph's corresponding BEL script's body.
:param pybel.BELGraph graph: A BEL graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
"""
... | Iterate the lines of a BEL graph's corresponding BEL script's body.
:param pybel.BELGraph graph: A BEL graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
| Iterate the lines of a BEL graph's corresponding BEL script's body. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"body",
"."
] | def _to_bel_lines_body(graph, use_identifiers: bool = False) -> Iterable[str]:
qualified_edges = sort_qualified_edges(graph)
for (citation_db, citation_id), citation_edges in group_citation_edges(qualified_edges):
yield SET_CITATION_FMT.format(citation_db, citation_id) + '\n'
for evidence, evide... | [
"def",
"_to_bel_lines_body",
"(",
"graph",
",",
"use_identifiers",
":",
"bool",
"=",
"False",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"qualified_edges",
"=",
"sort_qualified_edges",
"(",
"graph",
")",
"for",
"(",
"citation_db",
",",
"citation_id",
")",
... | Iterate the lines of a BEL graph's corresponding BEL script's body. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"body",
"."
] | [
"\"\"\"Iterate the lines of a BEL graph's corresponding BEL script's body.\n\n :param pybel.BELGraph graph: A BEL graph\n :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
},
{
"identifier": "use_identifiers",... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | _to_bel_lines_footer | Iterable[str] | def _to_bel_lines_footer(graph, use_identifiers: bool = False) -> Iterable[str]:
"""Iterate the lines of a BEL graph's corresponding BEL script's footer.
:param pybel.BELGraph graph: A BEL graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
"""... | Iterate the lines of a BEL graph's corresponding BEL script's footer.
:param pybel.BELGraph graph: A BEL graph
:param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
| Iterate the lines of a BEL graph's corresponding BEL script's footer. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"footer",
"."
] | def _to_bel_lines_footer(graph, use_identifiers: bool = False) -> Iterable[str]:
unqualified_edges_to_serialize = [
(u, v, d)
for u, v, d in graph.edges(data=True)
if d[RELATION] in UNQUALIFIED_EDGES and EVIDENCE not in d
]
isolated_nodes_to_serialize = [
node
for nod... | [
"def",
"_to_bel_lines_footer",
"(",
"graph",
",",
"use_identifiers",
":",
"bool",
"=",
"False",
")",
"->",
"Iterable",
"[",
"str",
"]",
":",
"unqualified_edges_to_serialize",
"=",
"[",
"(",
"u",
",",
"v",
",",
"d",
")",
"for",
"u",
",",
"v",
",",
"d",
... | Iterate the lines of a BEL graph's corresponding BEL script's footer. | [
"Iterate",
"the",
"lines",
"of",
"a",
"BEL",
"graph",
"'",
"s",
"corresponding",
"BEL",
"script",
"'",
"s",
"footer",
"."
] | [
"\"\"\"Iterate the lines of a BEL graph's corresponding BEL script's footer.\n\n :param pybel.BELGraph graph: A BEL graph\n :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": false
},
{
"identifier": "use_identifiers",... |
7408e23b2210559254c932e947aa55f871355929 | rpatil524/pybel | src/pybel/canonicalize.py | [
"MIT"
] | Python | calculate_canonical_name | str | def calculate_canonical_name(node: BaseEntity, use_identifiers: bool = True) -> str:
"""Calculate the canonical name for a given node.
If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
"""
if isinstance(node, (Reaction, ListAbundance, FusionBase)):
return n... | Calculate the canonical name for a given node.
If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
| Calculate the canonical name for a given node.
If it is a simple node, uses the already given name. Otherwise, it uses the BEL string. | [
"Calculate",
"the",
"canonical",
"name",
"for",
"a",
"given",
"node",
".",
"If",
"it",
"is",
"a",
"simple",
"node",
"uses",
"the",
"already",
"given",
"name",
".",
"Otherwise",
"it",
"uses",
"the",
"BEL",
"string",
"."
] | def calculate_canonical_name(node: BaseEntity, use_identifiers: bool = True) -> str:
if isinstance(node, (Reaction, ListAbundance, FusionBase)):
return node.as_bel(use_identifiers=True)
elif isinstance(node, BaseAbundance):
if VARIANTS in node:
return node.as_bel(use_identifiers=True... | [
"def",
"calculate_canonical_name",
"(",
"node",
":",
"BaseEntity",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"node",
",",
"(",
"Reaction",
",",
"ListAbundance",
",",
"FusionBase",
")",
")",
":",
"retu... | Calculate the canonical name for a given node. | [
"Calculate",
"the",
"canonical",
"name",
"for",
"a",
"given",
"node",
"."
] | [
"\"\"\"Calculate the canonical name for a given node.\n\n If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.\n \"\"\""
] | [
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
"type": "bool",
"docstring": null,
... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | child | 'BELGraph' | def child(self) -> 'BELGraph':
"""Create an empty graph with a "parent" reference back to this one."""
rv = BELGraph()
rv.parent = self
update_metadata(source=self, target=rv)
return rv | Create an empty graph with a "parent" reference back to this one. | Create an empty graph with a "parent" reference back to this one. | [
"Create",
"an",
"empty",
"graph",
"with",
"a",
"\"",
"parent",
"\"",
"reference",
"back",
"to",
"this",
"one",
"."
] | def child(self) -> 'BELGraph':
rv = BELGraph()
rv.parent = self
update_metadata(source=self, target=rv)
return rv | [
"def",
"child",
"(",
"self",
")",
"->",
"'BELGraph'",
":",
"rv",
"=",
"BELGraph",
"(",
")",
"rv",
".",
"parent",
"=",
"self",
"update_metadata",
"(",
"source",
"=",
"self",
",",
"target",
"=",
"rv",
")",
"return",
"rv"
] | Create an empty graph with a "parent" reference back to this one. | [
"Create",
"an",
"empty",
"graph",
"with",
"a",
"\"",
"parent",
"\"",
"reference",
"back",
"to",
"this",
"one",
"."
] | [
"\"\"\"Create an empty graph with a \"parent\" reference back to this one.\"\"\""
] | [
{
"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 | document | Dict[str, Any] | def document(self) -> Dict[str, Any]: # noqa: D401
"""The dictionary holding the metadata from the ``SET DOCUMENT`` statements in the source BEL script.
All keys are normalized according to :data:`pybel.constants.DOCUMENT_KEYS`.
"""
return self.graph[GRAPH_METADATA] | The dictionary holding the metadata from the ``SET DOCUMENT`` statements in the source BEL script.
All keys are normalized according to :data:`pybel.constants.DOCUMENT_KEYS`.
| The dictionary holding the metadata from the ``SET DOCUMENT`` statements in the source BEL script.
All keys are normalized according to :data:`pybel.constants.DOCUMENT_KEYS`. | [
"The",
"dictionary",
"holding",
"the",
"metadata",
"from",
"the",
"`",
"`",
"SET",
"DOCUMENT",
"`",
"`",
"statements",
"in",
"the",
"source",
"BEL",
"script",
".",
"All",
"keys",
"are",
"normalized",
"according",
"to",
":",
"data",
":",
"`",
"pybel",
"."... | def document(self) -> Dict[str, Any]:
return self.graph[GRAPH_METADATA] | [
"def",
"document",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"self",
".",
"graph",
"[",
"GRAPH_METADATA",
"]"
] | The dictionary holding the metadata from the ``SET DOCUMENT`` statements in the source BEL script. | [
"The",
"dictionary",
"holding",
"the",
"metadata",
"from",
"the",
"`",
"`",
"SET",
"DOCUMENT",
"`",
"`",
"statements",
"in",
"the",
"source",
"BEL",
"script",
"."
] | [
"# noqa: D401",
"\"\"\"The dictionary holding the metadata from the ``SET DOCUMENT`` statements in the source BEL script.\n\n All keys are normalized according to :data:`pybel.constants.DOCUMENT_KEYS`.\n \"\"\""
] | [
{
"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 | namespace_url | Dict[str, str] | def namespace_url(self) -> Dict[str, str]: # noqa: D401
"""The mapping from the keywords used in this graph to their respective BEL namespace URLs.
.. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS URL "[value]"`` entries in the definitions
section of the source BEL docu... | The mapping from the keywords used in this graph to their respective BEL namespace URLs.
.. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS URL "[value]"`` entries in the definitions
section of the source BEL document.
| The mapping from the keywords used in this graph to their respective BEL namespace URLs.
hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS URL "[value]"`` entries in the definitions
section of the source BEL document. | [
"The",
"mapping",
"from",
"the",
"keywords",
"used",
"in",
"this",
"graph",
"to",
"their",
"respective",
"BEL",
"namespace",
"URLs",
".",
"hint",
"::",
"Can",
"be",
"appended",
"with",
"the",
"`",
"`",
"DEFINE",
"NAMESPACE",
"[",
"key",
"]",
"AS",
"URL",... | def namespace_url(self) -> Dict[str, str]:
return self.graph[GRAPH_NAMESPACE_URL] | [
"def",
"namespace_url",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"return",
"self",
".",
"graph",
"[",
"GRAPH_NAMESPACE_URL",
"]"
] | The mapping from the keywords used in this graph to their respective BEL namespace URLs. | [
"The",
"mapping",
"from",
"the",
"keywords",
"used",
"in",
"this",
"graph",
"to",
"their",
"respective",
"BEL",
"namespace",
"URLs",
"."
] | [
"# noqa: D401",
"\"\"\"The mapping from the keywords used in this graph to their respective BEL namespace URLs.\n\n .. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS URL \"[value]\"`` entries in the definitions\n section of the source BEL document.\n \"\"\""
] | [
{
"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 | namespace_pattern | Dict[str, str] | def namespace_pattern(self) -> Dict[str, str]: # noqa: D401
"""The mapping from the namespace keywords used to create this graph to their regex patterns.
.. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS PATTERN "[value]"`` entries in the definitions
section of the sourc... | The mapping from the namespace keywords used to create this graph to their regex patterns.
.. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS PATTERN "[value]"`` entries in the definitions
section of the source BEL document.
| The mapping from the namespace keywords used to create this graph to their regex patterns.
hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS PATTERN "[value]"`` entries in the definitions
section of the source BEL document. | [
"The",
"mapping",
"from",
"the",
"namespace",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"their",
"regex",
"patterns",
".",
"hint",
"::",
"Can",
"be",
"appended",
"with",
"the",
"`",
"`",
"DEFINE",
"NAMESPACE",
"[",
"key",
"]",
"AS",
"PAT... | def namespace_pattern(self) -> Dict[str, str]:
return self.graph[GRAPH_NAMESPACE_PATTERN] | [
"def",
"namespace_pattern",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"return",
"self",
".",
"graph",
"[",
"GRAPH_NAMESPACE_PATTERN",
"]"
] | The mapping from the namespace keywords used to create this graph to their regex patterns. | [
"The",
"mapping",
"from",
"the",
"namespace",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"their",
"regex",
"patterns",
"."
] | [
"# noqa: D401",
"\"\"\"The mapping from the namespace keywords used to create this graph to their regex patterns.\n\n .. hint:: Can be appended with the ``DEFINE NAMESPACE [key] AS PATTERN \"[value]\"`` entries in the definitions\n section of the source BEL document.\n \"\"\""
] | [
{
"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 | annotation_url | Dict[str, str] | def annotation_url(self) -> Dict[str, str]: # noqa: D401
"""The mapping from the annotation keywords used to create this graph to the URLs of the BELANNO files.
.. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS URL "[value]"`` entries in the definitions
section of the s... | The mapping from the annotation keywords used to create this graph to the URLs of the BELANNO files.
.. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS URL "[value]"`` entries in the definitions
section of the source BEL document.
| The mapping from the annotation keywords used to create this graph to the URLs of the BELANNO files.
hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS URL "[value]"`` entries in the definitions
section of the source BEL document. | [
"The",
"mapping",
"from",
"the",
"annotation",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"the",
"URLs",
"of",
"the",
"BELANNO",
"files",
".",
"hint",
"::",
"Can",
"be",
"appended",
"with",
"the",
"`",
"`",
"DEFINE",
"ANNOTATION",
"[",
"k... | def annotation_url(self) -> Dict[str, str]:
return self.graph[GRAPH_ANNOTATION_URL] | [
"def",
"annotation_url",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"return",
"self",
".",
"graph",
"[",
"GRAPH_ANNOTATION_URL",
"]"
] | The mapping from the annotation keywords used to create this graph to the URLs of the BELANNO files. | [
"The",
"mapping",
"from",
"the",
"annotation",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"the",
"URLs",
"of",
"the",
"BELANNO",
"files",
"."
] | [
"# noqa: D401",
"\"\"\"The mapping from the annotation keywords used to create this graph to the URLs of the BELANNO files.\n\n .. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS URL \"[value]\"`` entries in the definitions\n section of the source BEL document.\n \"\"\"... | [
{
"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 | annotation_miriam | Set[str] | def annotation_miriam(self) -> Set[str]: # noqa: D401
"""The set of annotations defined by MIRIAM."""
if GRAPH_ANNOTATION_MIRIAM not in self.graph:
self.graph[GRAPH_ANNOTATION_MIRIAM] = set()
return self.graph[GRAPH_ANNOTATION_MIRIAM] | The set of annotations defined by MIRIAM. | The set of annotations defined by MIRIAM. | [
"The",
"set",
"of",
"annotations",
"defined",
"by",
"MIRIAM",
"."
] | def annotation_miriam(self) -> Set[str]:
if GRAPH_ANNOTATION_MIRIAM not in self.graph:
self.graph[GRAPH_ANNOTATION_MIRIAM] = set()
return self.graph[GRAPH_ANNOTATION_MIRIAM] | [
"def",
"annotation_miriam",
"(",
"self",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"if",
"GRAPH_ANNOTATION_MIRIAM",
"not",
"in",
"self",
".",
"graph",
":",
"self",
".",
"graph",
"[",
"GRAPH_ANNOTATION_MIRIAM",
"]",
"=",
"set",
"(",
")",
"return",
"self",
"... | The set of annotations defined by MIRIAM. | [
"The",
"set",
"of",
"annotations",
"defined",
"by",
"MIRIAM",
"."
] | [
"# noqa: D401",
"\"\"\"The set of annotations defined by MIRIAM.\"\"\""
] | [
{
"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 | annotation_curie | Set[str] | def annotation_curie(self) -> Set[str]: # noqa: D401
"""The set of annotations defined by CURIE."""
if GRAPH_ANNOTATION_CURIE not in self.graph:
self.graph[GRAPH_ANNOTATION_CURIE] = set()
return self.graph[GRAPH_ANNOTATION_CURIE] | The set of annotations defined by CURIE. | The set of annotations defined by CURIE. | [
"The",
"set",
"of",
"annotations",
"defined",
"by",
"CURIE",
"."
] | def annotation_curie(self) -> Set[str]:
if GRAPH_ANNOTATION_CURIE not in self.graph:
self.graph[GRAPH_ANNOTATION_CURIE] = set()
return self.graph[GRAPH_ANNOTATION_CURIE] | [
"def",
"annotation_curie",
"(",
"self",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"if",
"GRAPH_ANNOTATION_CURIE",
"not",
"in",
"self",
".",
"graph",
":",
"self",
".",
"graph",
"[",
"GRAPH_ANNOTATION_CURIE",
"]",
"=",
"set",
"(",
")",
"return",
"self",
".",... | The set of annotations defined by CURIE. | [
"The",
"set",
"of",
"annotations",
"defined",
"by",
"CURIE",
"."
] | [
"# noqa: D401",
"\"\"\"The set of annotations defined by CURIE.\"\"\""
] | [
{
"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 | annotation_pattern | Dict[str, str] | def annotation_pattern(self) -> Dict[str, str]: # noqa: D401
"""The mapping from the annotation keywords used to create this graph to their regex patterns as strings.
.. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS PATTERN "[value]"`` entries in the definitions
sectio... | The mapping from the annotation keywords used to create this graph to their regex patterns as strings.
.. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS PATTERN "[value]"`` entries in the definitions
section of the source BEL document.
| The mapping from the annotation keywords used to create this graph to their regex patterns as strings.
hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS PATTERN "[value]"`` entries in the definitions
section of the source BEL document. | [
"The",
"mapping",
"from",
"the",
"annotation",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"their",
"regex",
"patterns",
"as",
"strings",
".",
"hint",
"::",
"Can",
"be",
"appended",
"with",
"the",
"`",
"`",
"DEFINE",
"ANNOTATION",
"[",
"key"... | def annotation_pattern(self) -> Dict[str, str]:
return self.graph[GRAPH_ANNOTATION_PATTERN] | [
"def",
"annotation_pattern",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"return",
"self",
".",
"graph",
"[",
"GRAPH_ANNOTATION_PATTERN",
"]"
] | The mapping from the annotation keywords used to create this graph to their regex patterns as strings. | [
"The",
"mapping",
"from",
"the",
"annotation",
"keywords",
"used",
"to",
"create",
"this",
"graph",
"to",
"their",
"regex",
"patterns",
"as",
"strings",
"."
] | [
"# noqa: D401",
"\"\"\"The mapping from the annotation keywords used to create this graph to their regex patterns as strings.\n\n .. hint:: Can be appended with the ``DEFINE ANNOTATION [key] AS PATTERN \"[value]\"`` entries in the definitions\n section of the source BEL document.\n ... | [
{
"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 | defined_annotation_keywords | Set[str] | def defined_annotation_keywords(self) -> Set[str]:
"""Get the set of all keywords defined as annotations in this graph."""
return (
set(self.annotation_pattern)
| set(self.annotation_url)
| set(self.annotation_list)
) | Get the set of all keywords defined as annotations in this graph. | Get the set of all keywords defined as annotations in this graph. | [
"Get",
"the",
"set",
"of",
"all",
"keywords",
"defined",
"as",
"annotations",
"in",
"this",
"graph",
"."
] | def defined_annotation_keywords(self) -> Set[str]:
return (
set(self.annotation_pattern)
| set(self.annotation_url)
| set(self.annotation_list)
) | [
"def",
"defined_annotation_keywords",
"(",
"self",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"return",
"(",
"set",
"(",
"self",
".",
"annotation_pattern",
")",
"|",
"set",
"(",
"self",
".",
"annotation_url",
")",
"|",
"set",
"(",
"self",
".",
"annotation_l... | Get the set of all keywords defined as annotations in this graph. | [
"Get",
"the",
"set",
"of",
"all",
"keywords",
"defined",
"as",
"annotations",
"in",
"this",
"graph",
"."
] | [
"\"\"\"Get the set of all keywords defined as annotations in this 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 | add_transitivity | None | def add_transitivity(self, k1: str, k2: str) -> None:
"""Add a pair of edge hashes over which there is transitivity.
:param k1: The hash of the subject edge
:param k2: The hash of the object edge
"""
self.transitivities.add((k1, k2)) | Add a pair of edge hashes over which there is transitivity.
:param k1: The hash of the subject edge
:param k2: The hash of the object edge
| Add a pair of edge hashes over which there is transitivity. | [
"Add",
"a",
"pair",
"of",
"edge",
"hashes",
"over",
"which",
"there",
"is",
"transitivity",
"."
] | def add_transitivity(self, k1: str, k2: str) -> None:
self.transitivities.add((k1, k2)) | [
"def",
"add_transitivity",
"(",
"self",
",",
"k1",
":",
"str",
",",
"k2",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"transitivities",
".",
"add",
"(",
"(",
"k1",
",",
"k2",
")",
")"
] | Add a pair of edge hashes over which there is transitivity. | [
"Add",
"a",
"pair",
"of",
"edge",
"hashes",
"over",
"which",
"there",
"is",
"transitivity",
"."
] | [
"\"\"\"Add a pair of edge hashes over which there is transitivity.\n\n :param k1: The hash of the subject edge\n :param k2: The hash of the object edge\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "k1",
"type": "str"
},
{
"param": "k2",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "k1",
"type": "str",
"docstring": "The hash of the subject edge",
... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_warning | None | def add_warning(
self,
exception: BELParserWarning,
context: Optional[Mapping[str, Any]] = None,
) -> None:
"""Add a warning to the internal warning log in the graph, with optional context information.
:param exception: The exception that occurred
:param context: The... | Add a warning to the internal warning log in the graph, with optional context information.
:param exception: The exception that occurred
:param context: The context from the parser when the exception occurred
| Add a warning to the internal warning log in the graph, with optional context information. | [
"Add",
"a",
"warning",
"to",
"the",
"internal",
"warning",
"log",
"in",
"the",
"graph",
"with",
"optional",
"context",
"information",
"."
] | def add_warning(
self,
exception: BELParserWarning,
context: Optional[Mapping[str, Any]] = None,
) -> None:
self.warnings.append((
self.path,
exception,
{} if context is None else context,
)) | [
"def",
"add_warning",
"(",
"self",
",",
"exception",
":",
"BELParserWarning",
",",
"context",
":",
"Optional",
"[",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
")",
"->",
"None",
":",
"self",
".",
"warnings",
".",
"append",
"(",
"(... | Add a warning to the internal warning log in the graph, with optional context information. | [
"Add",
"a",
"warning",
"to",
"the",
"internal",
"warning",
"log",
"in",
"the",
"graph",
"with",
"optional",
"context",
"information",
"."
] | [
"\"\"\"Add a warning to the internal warning log in the graph, with optional context information.\n\n :param exception: The exception that occurred\n :param context: The context from the parser when the exception occurred\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "exception",
"type": "BELParserWarning"
},
{
"param": "context",
"type": "Optional[Mapping[str, Any]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "exception",
"type": "BELParserWarning",
"docstring": "The exception... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | _help_add_edge | str | def _help_add_edge(self, source: BaseEntity, target: BaseEntity, attr: Mapping) -> str:
"""Help add a pre-built edge."""
self.add_node_from_data(source)
self.add_node_from_data(target)
return self._help_add_edge_helper(source=source, target=target, attr=attr) | Help add a pre-built edge. | Help add a pre-built edge. | [
"Help",
"add",
"a",
"pre",
"-",
"built",
"edge",
"."
] | def _help_add_edge(self, source: BaseEntity, target: BaseEntity, attr: Mapping) -> str:
self.add_node_from_data(source)
self.add_node_from_data(target)
return self._help_add_edge_helper(source=source, target=target, attr=attr) | [
"def",
"_help_add_edge",
"(",
"self",
",",
"source",
":",
"BaseEntity",
",",
"target",
":",
"BaseEntity",
",",
"attr",
":",
"Mapping",
")",
"->",
"str",
":",
"self",
".",
"add_node_from_data",
"(",
"source",
")",
"self",
".",
"add_node_from_data",
"(",
"ta... | Help add a pre-built edge. | [
"Help",
"add",
"a",
"pre",
"-",
"built",
"edge",
"."
] | [
"\"\"\"Help add a pre-built edge.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": "BaseEntity"
},
{
"param": "target",
"type": "BaseEntity"
},
{
"param": "attr",
"type": "Mapping"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": "BaseEntity",
"docstring": null,
"docstring_... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_unqualified_edge | str | def add_unqualified_edge(self, source: BaseEntity, target: BaseEntity, relation: str) -> str:
"""Add a unique edge that has no annotations.
:param source: The source node
:param target: The target node
:param relation: A relationship label from :mod:`pybel.constants`
:return: Th... | Add a unique edge that has no annotations.
:param source: The source node
:param target: The target node
:param relation: A relationship label from :mod:`pybel.constants`
:return: The key for this edge (a unique hash)
| Add a unique edge that has no annotations. | [
"Add",
"a",
"unique",
"edge",
"that",
"has",
"no",
"annotations",
"."
] | def add_unqualified_edge(self, source: BaseEntity, target: BaseEntity, relation: str) -> str:
attr = {RELATION: relation}
return self._help_add_edge(source=source, target=target, attr=attr) | [
"def",
"add_unqualified_edge",
"(",
"self",
",",
"source",
":",
"BaseEntity",
",",
"target",
":",
"BaseEntity",
",",
"relation",
":",
"str",
")",
"->",
"str",
":",
"attr",
"=",
"{",
"RELATION",
":",
"relation",
"}",
"return",
"self",
".",
"_help_add_edge",... | Add a unique edge that has no annotations. | [
"Add",
"a",
"unique",
"edge",
"that",
"has",
"no",
"annotations",
"."
] | [
"\"\"\"Add a unique edge that has no annotations.\n\n :param source: The source node\n :param target: The target node\n :param relation: A relationship label from :mod:`pybel.constants`\n :return: The key for this edge (a unique hash)\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": "BaseEntity"
},
{
"param": "target",
"type": "BaseEntity"
},
{
"param": "relation",
"type": "str"
}
] | {
"returns": [
{
"docstring": "The key for this edge (a unique hash)",
"docstring_tokens": [
"The",
"key",
"for",
"this",
"edge",
"(",
"a",
"unique",
"hash",
")"
],
"type": null
}
],
"raises": [],
"pa... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_transcription | str | def add_transcription(self, gene: Gene, rna: Union[Rna, MicroRna]) -> str:
"""Add a transcription relation from a gene to an RNA or miRNA node.
:param gene: A gene node
:param rna: An RNA or microRNA node
"""
return self.add_unqualified_edge(gene, rna, TRANSCRIBED_TO) | Add a transcription relation from a gene to an RNA or miRNA node.
:param gene: A gene node
:param rna: An RNA or microRNA node
| Add a transcription relation from a gene to an RNA or miRNA node. | [
"Add",
"a",
"transcription",
"relation",
"from",
"a",
"gene",
"to",
"an",
"RNA",
"or",
"miRNA",
"node",
"."
] | def add_transcription(self, gene: Gene, rna: Union[Rna, MicroRna]) -> str:
return self.add_unqualified_edge(gene, rna, TRANSCRIBED_TO) | [
"def",
"add_transcription",
"(",
"self",
",",
"gene",
":",
"Gene",
",",
"rna",
":",
"Union",
"[",
"Rna",
",",
"MicroRna",
"]",
")",
"->",
"str",
":",
"return",
"self",
".",
"add_unqualified_edge",
"(",
"gene",
",",
"rna",
",",
"TRANSCRIBED_TO",
")"
] | Add a transcription relation from a gene to an RNA or miRNA node. | [
"Add",
"a",
"transcription",
"relation",
"from",
"a",
"gene",
"to",
"an",
"RNA",
"or",
"miRNA",
"node",
"."
] | [
"\"\"\"Add a transcription relation from a gene to an RNA or miRNA node.\n\n :param gene: A gene node\n :param rna: An RNA or microRNA node\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "gene",
"type": "Gene"
},
{
"param": "rna",
"type": "Union[Rna, MicroRna]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gene",
"type": "Gene",
"docstring": "A gene node",
"docstring... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_translation | str | def add_translation(self, rna: Rna, protein: Protein) -> str:
"""Add a translation relation from a RNA to a protein.
:param rna: An RNA node
:param protein: A protein node
"""
return self.add_unqualified_edge(rna, protein, TRANSLATED_TO) | Add a translation relation from a RNA to a protein.
:param rna: An RNA node
:param protein: A protein node
| Add a translation relation from a RNA to a protein. | [
"Add",
"a",
"translation",
"relation",
"from",
"a",
"RNA",
"to",
"a",
"protein",
"."
] | def add_translation(self, rna: Rna, protein: Protein) -> str:
return self.add_unqualified_edge(rna, protein, TRANSLATED_TO) | [
"def",
"add_translation",
"(",
"self",
",",
"rna",
":",
"Rna",
",",
"protein",
":",
"Protein",
")",
"->",
"str",
":",
"return",
"self",
".",
"add_unqualified_edge",
"(",
"rna",
",",
"protein",
",",
"TRANSLATED_TO",
")"
] | Add a translation relation from a RNA to a protein. | [
"Add",
"a",
"translation",
"relation",
"from",
"a",
"RNA",
"to",
"a",
"protein",
"."
] | [
"\"\"\"Add a translation relation from a RNA to a protein.\n\n :param rna: An RNA node\n :param protein: A protein node\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "rna",
"type": "Rna"
},
{
"param": "protein",
"type": "Protein"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rna",
"type": "Rna",
"docstring": "An RNA node",
"docstring_t... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_qualified_edge | str | def add_qualified_edge(
self,
source: BaseEntity,
target: BaseEntity,
*,
relation: str,
evidence: str,
citation: Union[str, Tuple[str, str], CitationDict],
annotations: Optional[AnnotationsHint] = None,
source_modifier: Optional[Mapping[str, Any]] ... | Add a qualified edge.
Qualified edges have a relation, evidence, citation, and optional annotations, subject modifications,
and object modifications.
:param source: The source node
:param target: The target node
:param relation: The type of relation this edge represents
... | Add a qualified edge.
Qualified edges have a relation, evidence, citation, and optional annotations, subject modifications,
and object modifications. | [
"Add",
"a",
"qualified",
"edge",
".",
"Qualified",
"edges",
"have",
"a",
"relation",
"evidence",
"citation",
"and",
"optional",
"annotations",
"subject",
"modifications",
"and",
"object",
"modifications",
"."
] | def add_qualified_edge(
self,
source: BaseEntity,
target: BaseEntity,
*,
relation: str,
evidence: str,
citation: Union[str, Tuple[str, str], CitationDict],
annotations: Optional[AnnotationsHint] = None,
source_modifier: Optional[Mapping[str, Any]] ... | [
"def",
"add_qualified_edge",
"(",
"self",
",",
"source",
":",
"BaseEntity",
",",
"target",
":",
"BaseEntity",
",",
"*",
",",
"relation",
":",
"str",
",",
"evidence",
":",
"str",
",",
"citation",
":",
"Union",
"[",
"str",
",",
"Tuple",
"[",
"str",
",",
... | Add a qualified edge. | [
"Add",
"a",
"qualified",
"edge",
"."
] | [
"\"\"\"Add a qualified edge.\n\n Qualified edges have a relation, evidence, citation, and optional annotations, subject modifications,\n and object modifications.\n\n :param source: The source node\n :param target: The target node\n :param relation: The type of relation this edge ... | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": "BaseEntity"
},
{
"param": "target",
"type": "BaseEntity"
},
{
"param": "relation",
"type": "str"
},
{
"param": "evidence",
"type": "str"
},
{
"param": "citation",
"type": "Union[str, ... | {
"returns": [
{
"docstring": "The hash of the edge",
"docstring_tokens": [
"The",
"hash",
"of",
"the",
"edge"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_node_from_data | None | def add_node_from_data(self, node: BaseEntity) -> None:
"""Add an entity to the graph."""
assert isinstance(node, BaseEntity)
if node in self:
return
self.add_node(node)
if isinstance(node, CentralDogma) and node.variants:
self.add_has_variant(node.get_... | Add an entity to the graph. | Add an entity to the graph. | [
"Add",
"an",
"entity",
"to",
"the",
"graph",
"."
] | def add_node_from_data(self, node: BaseEntity) -> None:
assert isinstance(node, BaseEntity)
if node in self:
return
self.add_node(node)
if isinstance(node, CentralDogma) and node.variants:
self.add_has_variant(node.get_parent(), node)
elif isinstance(node,... | [
"def",
"add_node_from_data",
"(",
"self",
",",
"node",
":",
"BaseEntity",
")",
"->",
"None",
":",
"assert",
"isinstance",
"(",
"node",
",",
"BaseEntity",
")",
"if",
"node",
"in",
"self",
":",
"return",
"self",
".",
"add_node",
"(",
"node",
")",
"if",
"... | Add an entity to the graph. | [
"Add",
"an",
"entity",
"to",
"the",
"graph",
"."
] | [
"\"\"\"Add an entity to the graph.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "BaseEntity"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_to... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | add_reaction | None | def add_reaction(
self,
reactants: Union[BaseAbundance, Iterable[BaseAbundance]],
products: Union[BaseAbundance, Iterable[BaseAbundance]],
) -> None:
"""Add a reaction directly to the graph."""
return self.add_node_from_data(Reaction(reactants=reactants, products=products)) | Add a reaction directly to the graph. | Add a reaction directly to the graph. | [
"Add",
"a",
"reaction",
"directly",
"to",
"the",
"graph",
"."
] | def add_reaction(
self,
reactants: Union[BaseAbundance, Iterable[BaseAbundance]],
products: Union[BaseAbundance, Iterable[BaseAbundance]],
) -> None:
return self.add_node_from_data(Reaction(reactants=reactants, products=products)) | [
"def",
"add_reaction",
"(",
"self",
",",
"reactants",
":",
"Union",
"[",
"BaseAbundance",
",",
"Iterable",
"[",
"BaseAbundance",
"]",
"]",
",",
"products",
":",
"Union",
"[",
"BaseAbundance",
",",
"Iterable",
"[",
"BaseAbundance",
"]",
"]",
",",
")",
"->",... | Add a reaction directly to the graph. | [
"Add",
"a",
"reaction",
"directly",
"to",
"the",
"graph",
"."
] | [
"\"\"\"Add a reaction directly to the graph.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "reactants",
"type": "Union[BaseAbundance, Iterable[BaseAbundance]]"
},
{
"param": "products",
"type": "Union[BaseAbundance, Iterable[BaseAbundance]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reactants",
"type": "Union[BaseAbundance, Iterable[BaseAbundance]]",
... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | edge_to_bel | str | def edge_to_bel(
u: BaseEntity,
v: BaseEntity,
edge_data: EdgeData,
sep: Optional[str] = None,
use_identifiers: bool = True,
) -> str:
"""Serialize a pair of nodes and related edge data as a BEL relation."""
return edge_to_bel(u, v, data=edge_data, sep=sep, us... | Serialize a pair of nodes and related edge data as a BEL relation. | Serialize a pair of nodes and related edge data as a BEL relation. | [
"Serialize",
"a",
"pair",
"of",
"nodes",
"and",
"related",
"edge",
"data",
"as",
"a",
"BEL",
"relation",
"."
] | def edge_to_bel(
u: BaseEntity,
v: BaseEntity,
edge_data: EdgeData,
sep: Optional[str] = None,
use_identifiers: bool = True,
) -> str:
return edge_to_bel(u, v, data=edge_data, sep=sep, use_identifiers=use_identifiers) | [
"def",
"edge_to_bel",
"(",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"edge_data",
":",
"EdgeData",
",",
"sep",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
")",
"->",
"str",
":"... | Serialize a pair of nodes and related edge data as a BEL relation. | [
"Serialize",
"a",
"pair",
"of",
"nodes",
"and",
"related",
"edge",
"data",
"as",
"a",
"BEL",
"relation",
"."
] | [
"\"\"\"Serialize a pair of nodes and related edge data as a BEL relation.\"\"\""
] | [
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "edge_data",
"type": "EdgeData"
},
{
"param": "sep",
"type": "Optional[str]"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BaseEntity",
"docstring": null,
"docstring_... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | _equivalent_node_iterator_helper | BaseEntity | def _equivalent_node_iterator_helper(self, node: BaseEntity, visited: Set[BaseEntity]) -> BaseEntity:
"""Iterate over nodes and their data that are equal to the given node, starting with the original."""
for v in self[node]:
if v in visited:
continue
if self._has... | Iterate over nodes and their data that are equal to the given node, starting with the original. | Iterate over nodes and their data that are equal to the given node, starting with the original. | [
"Iterate",
"over",
"nodes",
"and",
"their",
"data",
"that",
"are",
"equal",
"to",
"the",
"given",
"node",
"starting",
"with",
"the",
"original",
"."
] | def _equivalent_node_iterator_helper(self, node: BaseEntity, visited: Set[BaseEntity]) -> BaseEntity:
for v in self[node]:
if v in visited:
continue
if self._has_no_equivalent_edge(node, v):
continue
visited.add(v)
yield v
... | [
"def",
"_equivalent_node_iterator_helper",
"(",
"self",
",",
"node",
":",
"BaseEntity",
",",
"visited",
":",
"Set",
"[",
"BaseEntity",
"]",
")",
"->",
"BaseEntity",
":",
"for",
"v",
"in",
"self",
"[",
"node",
"]",
":",
"if",
"v",
"in",
"visited",
":",
... | Iterate over nodes and their data that are equal to the given node, starting with the original. | [
"Iterate",
"over",
"nodes",
"and",
"their",
"data",
"that",
"are",
"equal",
"to",
"the",
"given",
"node",
"starting",
"with",
"the",
"original",
"."
] | [
"\"\"\"Iterate over nodes and their data that are equal to the given node, starting with the original.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "visited",
"type": "Set[BaseEntity]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_to... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | _node_has_namespace_helper | bool | def _node_has_namespace_helper(node: BaseEntity, namespace: str) -> bool:
"""Check that the node has namespace information.
Might have cross references in future.
"""
return isinstance(node, BaseConcept) and node.namespace.lower() == namespace.lower() | Check that the node has namespace information.
Might have cross references in future.
| Check that the node has namespace information.
Might have cross references in future. | [
"Check",
"that",
"the",
"node",
"has",
"namespace",
"information",
".",
"Might",
"have",
"cross",
"references",
"in",
"future",
"."
] | def _node_has_namespace_helper(node: BaseEntity, namespace: str) -> bool:
return isinstance(node, BaseConcept) and node.namespace.lower() == namespace.lower() | [
"def",
"_node_has_namespace_helper",
"(",
"node",
":",
"BaseEntity",
",",
"namespace",
":",
"str",
")",
"->",
"bool",
":",
"return",
"isinstance",
"(",
"node",
",",
"BaseConcept",
")",
"and",
"node",
".",
"namespace",
".",
"lower",
"(",
")",
"==",
"namespa... | Check that the node has namespace information. | [
"Check",
"that",
"the",
"node",
"has",
"namespace",
"information",
"."
] | [
"\"\"\"Check that the node has namespace information.\n\n Might have cross references in future.\n \"\"\""
] | [
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "namespace",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "namespace",
"type": "str",
"docstring": null,
"docstr... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | node_has_namespace | bool | def node_has_namespace(self, node: BaseEntity, namespace: str) -> bool:
"""Check if the node have the given namespace.
This also should look in the equivalent nodes.
"""
return any(
self._node_has_namespace_helper(n, namespace)
for n in self.iter_equivalent_nodes... | Check if the node have the given namespace.
This also should look in the equivalent nodes.
| Check if the node have the given namespace.
This also should look in the equivalent nodes. | [
"Check",
"if",
"the",
"node",
"have",
"the",
"given",
"namespace",
".",
"This",
"also",
"should",
"look",
"in",
"the",
"equivalent",
"nodes",
"."
] | def node_has_namespace(self, node: BaseEntity, namespace: str) -> bool:
return any(
self._node_has_namespace_helper(n, namespace)
for n in self.iter_equivalent_nodes(node)
) | [
"def",
"node_has_namespace",
"(",
"self",
",",
"node",
":",
"BaseEntity",
",",
"namespace",
":",
"str",
")",
"->",
"bool",
":",
"return",
"any",
"(",
"self",
".",
"_node_has_namespace_helper",
"(",
"n",
",",
"namespace",
")",
"for",
"n",
"in",
"self",
".... | Check if the node have the given namespace. | [
"Check",
"if",
"the",
"node",
"have",
"the",
"given",
"namespace",
"."
] | [
"\"\"\"Check if the node have the given namespace.\n\n This also should look in the equivalent nodes.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "BaseEntity"
},
{
"param": "namespace",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_to... |
32c2c70ef7a234764f50581ae38ee326337e01f8 | rpatil524/pybel | src/pybel/struct/graph.py | [
"MIT"
] | Python | functions | Counter | def functions(self) -> Counter:
"""Count the functions in a graph.
>>> from pybel.examples import sialic_acid_graph
>>> sialic_acid_graph.count.functions()
Counter({'Protein': 7, 'Complex': 1, 'Abundance': 1})
"""
from .summary import count_functions
return count... | Count the functions in a graph.
>>> from pybel.examples import sialic_acid_graph
>>> sialic_acid_graph.count.functions()
Counter({'Protein': 7, 'Complex': 1, 'Abundance': 1})
| Count the functions in a graph. | [
"Count",
"the",
"functions",
"in",
"a",
"graph",
"."
] | def functions(self) -> Counter:
from .summary import count_functions
return count_functions(self.graph) | [
"def",
"functions",
"(",
"self",
")",
"->",
"Counter",
":",
"from",
".",
"summary",
"import",
"count_functions",
"return",
"count_functions",
"(",
"self",
".",
"graph",
")"
] | Count the functions in a graph. | [
"Count",
"the",
"functions",
"in",
"a",
"graph",
"."
] | [
"\"\"\"Count the functions in a graph.\n\n >>> from pybel.examples import sialic_acid_graph\n >>> sialic_acid_graph.count.functions()\n Counter({'Protein': 7, 'Complex': 1, 'Abundance': 1})\n \"\"\""
] | [
{
"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 | list | List[Tuple[str, Any]] | def list(self) -> List[Tuple[str, Any]]:
"""Return a list of tuples that summarize the graph."""
return [
*self._metadata_list(),
*self._statistics_list(),
] | Return a list of tuples that summarize the graph. | Return a list of tuples that summarize the graph. | [
"Return",
"a",
"list",
"of",
"tuples",
"that",
"summarize",
"the",
"graph",
"."
] | def list(self) -> List[Tuple[str, Any]]:
return [
*self._metadata_list(),
*self._statistics_list(),
] | [
"def",
"list",
"(",
"self",
")",
"->",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"return",
"[",
"*",
"self",
".",
"_metadata_list",
"(",
")",
",",
"*",
"self",
".",
"_statistics_list",
"(",
")",
",",
"]"
] | Return a list of tuples that summarize the graph. | [
"Return",
"a",
"list",
"of",
"tuples",
"that",
"summarize",
"the",
"graph",
"."
] | [
"\"\"\"Return a list of tuples that summarize the 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 | parent | BELGraph | def parent(self) -> BELGraph:
"""Get the parent BEL graph."""
if not self.graph.parent:
raise RuntimeError('Can not use expand dispatch on graph without a parent')
return self.graph.parent | Get the parent BEL graph. | Get the parent BEL graph. | [
"Get",
"the",
"parent",
"BEL",
"graph",
"."
] | def parent(self) -> BELGraph:
if not self.graph.parent:
raise RuntimeError('Can not use expand dispatch on graph without a parent')
return self.graph.parent | [
"def",
"parent",
"(",
"self",
")",
"->",
"BELGraph",
":",
"if",
"not",
"self",
".",
"graph",
".",
"parent",
":",
"raise",
"RuntimeError",
"(",
"'Can not use expand dispatch on graph without a parent'",
")",
"return",
"self",
".",
"graph",
".",
"parent"
] | Get the parent BEL graph. | [
"Get",
"the",
"parent",
"BEL",
"graph",
"."
] | [
"\"\"\"Get the parent BEL 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 | neighborhood | BELGraph | def neighborhood(self, node: BaseEntity) -> BELGraph:
"""Expand around the neighborhood of a given node.
>>> from pybel.examples import braf_graph
>>> from pybel.dsl import Protein
>>> thpo = Protein(namespace='HGNC', name='THPO', identifier='11795')
>>> braf = Protein(namespace... | Expand around the neighborhood of a given node.
>>> from pybel.examples import braf_graph
>>> from pybel.dsl import Protein
>>> thpo = Protein(namespace='HGNC', name='THPO', identifier='11795')
>>> braf = Protein(namespace='HGNC', name='BRAF', identifier='1097')
>>> raf1 = Prote... | Expand around the neighborhood of a given node. | [
"Expand",
"around",
"the",
"neighborhood",
"of",
"a",
"given",
"node",
"."
] | def neighborhood(self, node: BaseEntity) -> BELGraph:
from .mutation import expand_node_neighborhood
cp = self.graph.copy()
expand_node_neighborhood(universe=self.parent, graph=cp, node=node)
return cp | [
"def",
"neighborhood",
"(",
"self",
",",
"node",
":",
"BaseEntity",
")",
"->",
"BELGraph",
":",
"from",
".",
"mutation",
"import",
"expand_node_neighborhood",
"cp",
"=",
"self",
".",
"graph",
".",
"copy",
"(",
")",
"expand_node_neighborhood",
"(",
"universe",
... | Expand around the neighborhood of a given node. | [
"Expand",
"around",
"the",
"neighborhood",
"of",
"a",
"given",
"node",
"."
] | [
"\"\"\"Expand around the neighborhood of a given node.\n\n >>> from pybel.examples import braf_graph\n >>> from pybel.dsl import Protein\n >>> thpo = Protein(namespace='HGNC', name='THPO', identifier='11795')\n >>> braf = Protein(namespace='HGNC', name='BRAF', identifier='1097')\n ... | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": "BaseEntity"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": "BaseEntity",
"docstring": null,
"docstring_to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.