repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.drop_edges
def drop_edges(self) -> None: """Drop all edges in the database.""" t = time.time() self.session.query(Edge).delete() self.session.commit() log.info('dropped all edges in %.2f seconds', time.time() - t)
python
def drop_edges(self) -> None: """Drop all edges in the database.""" t = time.time() self.session.query(Edge).delete() self.session.commit() log.info('dropped all edges in %.2f seconds', time.time() - t)
[ "def", "drop_edges", "(", "self", ")", "->", "None", ":", "t", "=", "time", ".", "time", "(", ")", "self", ".", "session", ".", "query", "(", "Edge", ")", ".", "delete", "(", ")", "self", ".", "session", ".", "commit", "(", ")", "log", ".", "in...
Drop all edges in the database.
[ "Drop", "all", "edges", "in", "the", "database", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L892-L899
train
29,600
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.get_or_create_edge
def get_or_create_edge(self, source: Node, target: Node, relation: str, bel: str, sha512: str, data: EdgeData, evidence: Optional[E...
python
def get_or_create_edge(self, source: Node, target: Node, relation: str, bel: str, sha512: str, data: EdgeData, evidence: Optional[E...
[ "def", "get_or_create_edge", "(", "self", ",", "source", ":", "Node", ",", "target", ":", "Node", ",", "relation", ":", "str", ",", "bel", ":", "str", ",", "sha512", ":", "str", ",", "data", ":", "EdgeData", ",", "evidence", ":", "Optional", "[", "Ev...
Create an edge if it does not exist, or return it if it does. :param source: Source node of the relation :param target: Target node of the relation :param relation: Type of the relation between source and target node :param bel: BEL statement that describes the relation :param s...
[ "Create", "an", "edge", "if", "it", "does", "not", "exist", "or", "return", "it", "if", "it", "does", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L901-L953
train
29,601
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.get_or_create_citation
def get_or_create_citation(self, reference: str, type: Optional[str] = None, name: Optional[str] = None, title: Optional[str] = None, volume: Optional[str] = None, ...
python
def get_or_create_citation(self, reference: str, type: Optional[str] = None, name: Optional[str] = None, title: Optional[str] = None, volume: Optional[str] = None, ...
[ "def", "get_or_create_citation", "(", "self", ",", "reference", ":", "str", ",", "type", ":", "Optional", "[", "str", "]", "=", "None", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ",", "title", ":", "Optional", "[", "str", "]", "=", ...
Create a citation if it does not exist, or return it if it does. :param type: Citation type (e.g. PubMed) :param reference: Identifier of the given citation (e.g. PubMed id) :param name: Name of the publication :param title: Title of article :param volume: Volume of publication ...
[ "Create", "a", "citation", "if", "it", "does", "not", "exist", "or", "return", "it", "if", "it", "does", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L955-L1025
train
29,602
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.get_or_create_author
def get_or_create_author(self, name: str) -> Author: """Get an author by name, or creates one if it does not exist.""" author = self.object_cache_author.get(name) if author is not None: self.session.add(author) return author author = self.get_author_by_name(name...
python
def get_or_create_author(self, name: str) -> Author: """Get an author by name, or creates one if it does not exist.""" author = self.object_cache_author.get(name) if author is not None: self.session.add(author) return author author = self.get_author_by_name(name...
[ "def", "get_or_create_author", "(", "self", ",", "name", ":", "str", ")", "->", "Author", ":", "author", "=", "self", ".", "object_cache_author", ".", "get", "(", "name", ")", "if", "author", "is", "not", "None", ":", "self", ".", "session", ".", "add"...
Get an author by name, or creates one if it does not exist.
[ "Get", "an", "author", "by", "name", "or", "creates", "one", "if", "it", "does", "not", "exist", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L1027-L1043
train
29,603
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.get_modification_by_hash
def get_modification_by_hash(self, sha512: str) -> Optional[Modification]: """Get a modification by a SHA512 hash.""" return self.session.query(Modification).filter(Modification.sha512 == sha512).one_or_none()
python
def get_modification_by_hash(self, sha512: str) -> Optional[Modification]: """Get a modification by a SHA512 hash.""" return self.session.query(Modification).filter(Modification.sha512 == sha512).one_or_none()
[ "def", "get_modification_by_hash", "(", "self", ",", "sha512", ":", "str", ")", "->", "Optional", "[", "Modification", "]", ":", "return", "self", ".", "session", ".", "query", "(", "Modification", ")", ".", "filter", "(", "Modification", ".", "sha512", "=...
Get a modification by a SHA512 hash.
[ "Get", "a", "modification", "by", "a", "SHA512", "hash", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L1045-L1047
train
29,604
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager.get_property_by_hash
def get_property_by_hash(self, property_hash: str) -> Optional[Property]: """Get a property by its hash if it exists.""" return self.session.query(Property).filter(Property.sha512 == property_hash).one_or_none()
python
def get_property_by_hash(self, property_hash: str) -> Optional[Property]: """Get a property by its hash if it exists.""" return self.session.query(Property).filter(Property.sha512 == property_hash).one_or_none()
[ "def", "get_property_by_hash", "(", "self", ",", "property_hash", ":", "str", ")", "->", "Optional", "[", "Property", "]", ":", "return", "self", ".", "session", ".", "query", "(", "Property", ")", ".", "filter", "(", "Property", ".", "sha512", "==", "pr...
Get a property by its hash if it exists.
[ "Get", "a", "property", "by", "its", "hash", "if", "it", "exists", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L1171-L1173
train
29,605
pybel/pybel
src/pybel/manager/cache_manager.py
InsertManager._make_property_from_dict
def _make_property_from_dict(self, property_def: Dict) -> Property: """Build an edge property from a dictionary.""" property_hash = hash_dump(property_def) edge_property_model = self.object_cache_property.get(property_hash) if edge_property_model is None: edge_property_model...
python
def _make_property_from_dict(self, property_def: Dict) -> Property: """Build an edge property from a dictionary.""" property_hash = hash_dump(property_def) edge_property_model = self.object_cache_property.get(property_hash) if edge_property_model is None: edge_property_model...
[ "def", "_make_property_from_dict", "(", "self", ",", "property_def", ":", "Dict", ")", "->", "Property", ":", "property_hash", "=", "hash_dump", "(", "property_def", ")", "edge_property_model", "=", "self", ".", "object_cache_property", ".", "get", "(", "property_...
Build an edge property from a dictionary.
[ "Build", "an", "edge", "property", "from", "a", "dictionary", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/cache_manager.py#L1175-L1189
train
29,606
pybel/pybel
src/pybel/struct/graph.py
_clean_annotations
def _clean_annotations(annotations_dict: AnnotationsHint) -> AnnotationsDict: """Fix the formatting of annotation dict.""" return { key: ( values if isinstance(values, dict) else {v: True for v in values} if isinstance(values, set) else {values: True} ) ...
python
def _clean_annotations(annotations_dict: AnnotationsHint) -> AnnotationsDict: """Fix the formatting of annotation dict.""" return { key: ( values if isinstance(values, dict) else {v: True for v in values} if isinstance(values, set) else {values: True} ) ...
[ "def", "_clean_annotations", "(", "annotations_dict", ":", "AnnotationsHint", ")", "->", "AnnotationsDict", ":", "return", "{", "key", ":", "(", "values", "if", "isinstance", "(", "values", ",", "dict", ")", "else", "{", "v", ":", "True", "for", "v", "in",...
Fix the formatting of annotation dict.
[ "Fix", "the", "formatting", "of", "annotation", "dict", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L817-L826
train
29,607
pybel/pybel
src/pybel/struct/graph.py
BELGraph.defined_namespace_keywords
def defined_namespace_keywords(self) -> Set[str]: # noqa: D401 """The set of all keywords defined as namespaces in this graph.""" return set(self.namespace_pattern) | set(self.namespace_url)
python
def defined_namespace_keywords(self) -> Set[str]: # noqa: D401 """The set of all keywords defined as namespaces in this graph.""" return set(self.namespace_pattern) | set(self.namespace_url)
[ "def", "defined_namespace_keywords", "(", "self", ")", "->", "Set", "[", "str", "]", ":", "# noqa: D401", "return", "set", "(", "self", ".", "namespace_pattern", ")", "|", "set", "(", "self", ".", "namespace_url", ")" ]
The set of all keywords defined as namespaces in this graph.
[ "The", "set", "of", "all", "keywords", "defined", "as", "namespaces", "in", "this", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L251-L253
train
29,608
pybel/pybel
src/pybel/struct/graph.py
BELGraph.defined_annotation_keywords
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) )
python
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) )
[ "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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L300-L306
train
29,609
pybel/pybel
src/pybel/struct/graph.py
BELGraph.skip_storing_namespace
def skip_storing_namespace(self, namespace: Optional[str]) -> bool: """Check if the namespace should be skipped. :param namespace: The keyword of the namespace to check. """ return ( namespace is not None and namespace in self.namespace_url and self.n...
python
def skip_storing_namespace(self, namespace: Optional[str]) -> bool: """Check if the namespace should be skipped. :param namespace: The keyword of the namespace to check. """ return ( namespace is not None and namespace in self.namespace_url and self.n...
[ "def", "skip_storing_namespace", "(", "self", ",", "namespace", ":", "Optional", "[", "str", "]", ")", "->", "bool", ":", "return", "(", "namespace", "is", "not", "None", "and", "namespace", "in", "self", ".", "namespace_url", "and", "self", ".", "namespac...
Check if the namespace should be skipped. :param namespace: The keyword of the namespace to check.
[ "Check", "if", "the", "namespace", "should", "be", "skipped", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L345-L354
train
29,610
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_warning
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 occur...
python
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 occur...
[ "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. :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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L356-L369
train
29,611
pybel/pybel
src/pybel/struct/graph.py
BELGraph._help_add_edge
def _help_add_edge(self, u: BaseEntity, v: BaseEntity, attr: Mapping) -> str: """Help add a pre-built edge.""" self.add_node_from_data(u) self.add_node_from_data(v) return self._help_add_edge_helper(u, v, attr)
python
def _help_add_edge(self, u: BaseEntity, v: BaseEntity, attr: Mapping) -> str: """Help add a pre-built edge.""" self.add_node_from_data(u) self.add_node_from_data(v) return self._help_add_edge_helper(u, v, attr)
[ "def", "_help_add_edge", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "attr", ":", "Mapping", ")", "->", "str", ":", "self", ".", "add_node_from_data", "(", "u", ")", "self", ".", "add_node_from_data", "(", "v", ")", "ret...
Help add a pre-built edge.
[ "Help", "add", "a", "pre", "-", "built", "edge", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L371-L376
train
29,612
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_unqualified_edge
def add_unqualified_edge(self, u: BaseEntity, v: BaseEntity, relation: str) -> str: """Add a unique edge that has no annotations. :param u: The source node :param v: The target node :param relation: A relationship label from :mod:`pybel.constants` :return: The key for this edge ...
python
def add_unqualified_edge(self, u: BaseEntity, v: BaseEntity, relation: str) -> str: """Add a unique edge that has no annotations. :param u: The source node :param v: The target node :param relation: A relationship label from :mod:`pybel.constants` :return: The key for this edge ...
[ "def", "add_unqualified_edge", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "relation", ":", "str", ")", "->", "str", ":", "attr", "=", "{", "RELATION", ":", "relation", "}", "return", "self", ".", "_help_add_edge", "(", ...
Add a unique edge that has no annotations. :param u: The source node :param v: 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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L386-L395
train
29,613
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_transcription
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)
python
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)
[ "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. :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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L397-L403
train
29,614
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_translation
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)
python
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)
[ "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. :param rna: An RNA node :param protein: A protein node
[ "Add", "a", "translation", "relation", "from", "a", "RNA", "to", "a", "protein", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L405-L411
train
29,615
pybel/pybel
src/pybel/struct/graph.py
BELGraph._add_two_way_unqualified_edge
def _add_two_way_unqualified_edge(self, u: BaseEntity, v: BaseEntity, relation: str) -> str: """Add an unqualified edge both ways.""" self.add_unqualified_edge(v, u, relation) return self.add_unqualified_edge(u, v, relation)
python
def _add_two_way_unqualified_edge(self, u: BaseEntity, v: BaseEntity, relation: str) -> str: """Add an unqualified edge both ways.""" self.add_unqualified_edge(v, u, relation) return self.add_unqualified_edge(u, v, relation)
[ "def", "_add_two_way_unqualified_edge", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "relation", ":", "str", ")", "->", "str", ":", "self", ".", "add_unqualified_edge", "(", "v", ",", "u", ",", "relation", ")", "return", "s...
Add an unqualified edge both ways.
[ "Add", "an", "unqualified", "edge", "both", "ways", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L413-L416
train
29,616
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_qualified_edge
def add_qualified_edge( self, u, v, *, relation: str, evidence: str, citation: Union[str, Mapping[str, str]], annotations: Optional[AnnotationsHint] = None, subject_modifier: Optional[Mapping] = None, ...
python
def add_qualified_edge( self, u, v, *, relation: str, evidence: str, citation: Union[str, Mapping[str, str]], annotations: Optional[AnnotationsHint] = None, subject_modifier: Optional[Mapping] = None, ...
[ "def", "add_qualified_edge", "(", "self", ",", "u", ",", "v", ",", "*", ",", "relation", ":", "str", ",", "evidence", ":", "str", ",", "citation", ":", "Union", "[", "str", ",", "Mapping", "[", "str", ",", "str", "]", "]", ",", "annotations", ":", ...
Add a qualified edge. Qualified edges have a relation, evidence, citation, and optional annotations, subject modifications, and object modifications. :param u: The source node :param v: The target node :param relation: The type of relation this edge represents :param ev...
[ "Add", "a", "qualified", "edge", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L445-L499
train
29,617
pybel/pybel
src/pybel/struct/graph.py
BELGraph.add_node_from_data
def add_node_from_data(self, node: BaseEntity) -> BaseEntity: """Add an entity to the graph.""" assert isinstance(node, BaseEntity) if node in self: return node self.add_node(node) if VARIANTS in node: self.add_has_variant(node.get_parent(), node) ...
python
def add_node_from_data(self, node: BaseEntity) -> BaseEntity: """Add an entity to the graph.""" assert isinstance(node, BaseEntity) if node in self: return node self.add_node(node) if VARIANTS in node: self.add_has_variant(node.get_parent(), node) ...
[ "def", "add_node_from_data", "(", "self", ",", "node", ":", "BaseEntity", ")", "->", "BaseEntity", ":", "assert", "isinstance", "(", "node", ",", "BaseEntity", ")", "if", "node", "in", "self", ":", "return", "node", "self", ".", "add_node", "(", "node", ...
Add an entity to the graph.
[ "Add", "an", "entity", "to", "the", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L525-L547
train
29,618
pybel/pybel
src/pybel/struct/graph.py
BELGraph.has_edge_citation
def has_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> bool: """Check if the given edge has a citation.""" return self._has_edge_attr(u, v, key, CITATION)
python
def has_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> bool: """Check if the given edge has a citation.""" return self._has_edge_attr(u, v, key, CITATION)
[ "def", "has_edge_citation", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "bool", ":", "return", "self", ".", "_has_edge_attr", "(", "u", ",", "v", ",", "key", ",", "CITATION", ")" ]
Check if the given edge has a citation.
[ "Check", "if", "the", "given", "edge", "has", "a", "citation", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L554-L556
train
29,619
pybel/pybel
src/pybel/struct/graph.py
BELGraph.has_edge_evidence
def has_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> bool: """Check if the given edge has an evidence.""" return self._has_edge_attr(u, v, key, EVIDENCE)
python
def has_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> bool: """Check if the given edge has an evidence.""" return self._has_edge_attr(u, v, key, EVIDENCE)
[ "def", "has_edge_evidence", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "bool", ":", "return", "self", ".", "_has_edge_attr", "(", "u", ",", "v", ",", "key", ",", "EVIDENCE", ")" ]
Check if the given edge has an evidence.
[ "Check", "if", "the", "given", "edge", "has", "an", "evidence", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L558-L560
train
29,620
pybel/pybel
src/pybel/struct/graph.py
BELGraph.get_edge_citation
def get_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[CitationDict]: """Get the citation for a given edge.""" return self._get_edge_attr(u, v, key, CITATION)
python
def get_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[CitationDict]: """Get the citation for a given edge.""" return self._get_edge_attr(u, v, key, CITATION)
[ "def", "get_edge_citation", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "Optional", "[", "CitationDict", "]", ":", "return", "self", ".", "_get_edge_attr", "(", "u", ",", "v", ",", "key", ...
Get the citation for a given edge.
[ "Get", "the", "citation", "for", "a", "given", "edge", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L565-L567
train
29,621
pybel/pybel
src/pybel/struct/graph.py
BELGraph.get_edge_evidence
def get_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[str]: """Get the evidence for a given edge.""" return self._get_edge_attr(u, v, key, EVIDENCE)
python
def get_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[str]: """Get the evidence for a given edge.""" return self._get_edge_attr(u, v, key, EVIDENCE)
[ "def", "get_edge_evidence", "(", "self", ",", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "key", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_get_edge_attr", "(", "u", ",", "v", ",", "key", ",", "E...
Get the evidence for a given edge.
[ "Get", "the", "evidence", "for", "a", "given", "edge", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L569-L571
train
29,622
pybel/pybel
src/pybel/struct/graph.py
BELGraph.get_edge_annotations
def get_edge_annotations(self, u, v, key: str) -> Optional[AnnotationsDict]: """Get the annotations for a given edge.""" return self._get_edge_attr(u, v, key, ANNOTATIONS)
python
def get_edge_annotations(self, u, v, key: str) -> Optional[AnnotationsDict]: """Get the annotations for a given edge.""" return self._get_edge_attr(u, v, key, ANNOTATIONS)
[ "def", "get_edge_annotations", "(", "self", ",", "u", ",", "v", ",", "key", ":", "str", ")", "->", "Optional", "[", "AnnotationsDict", "]", ":", "return", "self", ".", "_get_edge_attr", "(", "u", ",", "v", ",", "key", ",", "ANNOTATIONS", ")" ]
Get the annotations for a given edge.
[ "Get", "the", "annotations", "for", "a", "given", "edge", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L573-L575
train
29,623
pybel/pybel
src/pybel/struct/graph.py
BELGraph.get_node_description
def get_node_description(self, node: BaseEntity) -> Optional[str]: """Get the description for a given node.""" return self._get_node_attr(node, DESCRIPTION)
python
def get_node_description(self, node: BaseEntity) -> Optional[str]: """Get the description for a given node.""" return self._get_node_attr(node, DESCRIPTION)
[ "def", "get_node_description", "(", "self", ",", "node", ":", "BaseEntity", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_get_node_attr", "(", "node", ",", "DESCRIPTION", ")" ]
Get the description for a given node.
[ "Get", "the", "description", "for", "a", "given", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L589-L591
train
29,624
pybel/pybel
src/pybel/struct/graph.py
BELGraph.set_node_description
def set_node_description(self, node: BaseEntity, description: str) -> None: """Set the description for a given node.""" self._set_node_attr(node, DESCRIPTION, description)
python
def set_node_description(self, node: BaseEntity, description: str) -> None: """Set the description for a given node.""" self._set_node_attr(node, DESCRIPTION, description)
[ "def", "set_node_description", "(", "self", ",", "node", ":", "BaseEntity", ",", "description", ":", "str", ")", "->", "None", ":", "self", ".", "_set_node_attr", "(", "node", ",", "DESCRIPTION", ",", "description", ")" ]
Set the description for a given node.
[ "Set", "the", "description", "for", "a", "given", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L597-L599
train
29,625
pybel/pybel
src/pybel/struct/graph.py
BELGraph.edge_to_bel
def edge_to_bel(u: BaseEntity, v: BaseEntity, edge_data: EdgeData, sep: Optional[str] = None) -> 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)
python
def edge_to_bel(u: BaseEntity, v: BaseEntity, edge_data: EdgeData, sep: Optional[str] = None) -> 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)
[ "def", "edge_to_bel", "(", "u", ":", "BaseEntity", ",", "v", ":", "BaseEntity", ",", "edge_data", ":", "EdgeData", ",", "sep", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "return", "edge_to_bel", "(", "u", ",", "v", ",", "...
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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L705-L707
train
29,626
pybel/pybel
src/pybel/struct/graph.py
BELGraph._equivalent_node_iterator_helper
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...
python
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...
[ "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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L715-L726
train
29,627
pybel/pybel
src/pybel/struct/graph.py
BELGraph.iter_equivalent_nodes
def iter_equivalent_nodes(self, node: BaseEntity) -> Iterable[BaseEntity]: """Iterate over nodes that are equivalent to the given node, including the original.""" yield node yield from self._equivalent_node_iterator_helper(node, {node})
python
def iter_equivalent_nodes(self, node: BaseEntity) -> Iterable[BaseEntity]: """Iterate over nodes that are equivalent to the given node, including the original.""" yield node yield from self._equivalent_node_iterator_helper(node, {node})
[ "def", "iter_equivalent_nodes", "(", "self", ",", "node", ":", "BaseEntity", ")", "->", "Iterable", "[", "BaseEntity", "]", ":", "yield", "node", "yield", "from", "self", ".", "_equivalent_node_iterator_helper", "(", "node", ",", "{", "node", "}", ")" ]
Iterate over nodes that are equivalent to the given node, including the original.
[ "Iterate", "over", "nodes", "that", "are", "equivalent", "to", "the", "given", "node", "including", "the", "original", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L728-L731
train
29,628
pybel/pybel
src/pybel/struct/graph.py
BELGraph.get_equivalent_nodes
def get_equivalent_nodes(self, node: BaseEntity) -> Set[BaseEntity]: """Get a set of equivalent nodes to this node, excluding the given node.""" if isinstance(node, BaseEntity): return set(self.iter_equivalent_nodes(node)) return set(self.iter_equivalent_nodes(node))
python
def get_equivalent_nodes(self, node: BaseEntity) -> Set[BaseEntity]: """Get a set of equivalent nodes to this node, excluding the given node.""" if isinstance(node, BaseEntity): return set(self.iter_equivalent_nodes(node)) return set(self.iter_equivalent_nodes(node))
[ "def", "get_equivalent_nodes", "(", "self", ",", "node", ":", "BaseEntity", ")", "->", "Set", "[", "BaseEntity", "]", ":", "if", "isinstance", "(", "node", ",", "BaseEntity", ")", ":", "return", "set", "(", "self", ".", "iter_equivalent_nodes", "(", "node"...
Get a set of equivalent nodes to this node, excluding the given node.
[ "Get", "a", "set", "of", "equivalent", "nodes", "to", "this", "node", "excluding", "the", "given", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L733-L738
train
29,629
pybel/pybel
src/pybel/struct/graph.py
BELGraph._node_has_namespace_helper
def _node_has_namespace_helper(node: BaseEntity, namespace: str) -> bool: """Check that the node has namespace information. Might have cross references in future. """ return namespace == node.get(NAMESPACE)
python
def _node_has_namespace_helper(node: BaseEntity, namespace: str) -> bool: """Check that the node has namespace information. Might have cross references in future. """ return namespace == node.get(NAMESPACE)
[ "def", "_node_has_namespace_helper", "(", "node", ":", "BaseEntity", ",", "namespace", ":", "str", ")", "->", "bool", ":", "return", "namespace", "==", "node", ".", "get", "(", "NAMESPACE", ")" ]
Check that the node has namespace information. Might have cross references in future.
[ "Check", "that", "the", "node", "has", "namespace", "information", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L741-L746
train
29,630
pybel/pybel
src/pybel/struct/graph.py
BELGraph.node_has_namespace
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...
python
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...
[ "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. This also should look in the equivalent nodes.
[ "Check", "if", "the", "node", "have", "the", "given", "namespace", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L748-L756
train
29,631
pybel/pybel
src/pybel/struct/graph.py
BELGraph._describe_list
def _describe_list(self) -> List[Tuple[str, float]]: """Return useful information about the graph as a list of tuples.""" number_nodes = self.number_of_nodes() return [ ('Number of Nodes', number_nodes), ('Number of Edges', self.number_of_edges()), ('Number of...
python
def _describe_list(self) -> List[Tuple[str, float]]: """Return useful information about the graph as a list of tuples.""" number_nodes = self.number_of_nodes() return [ ('Number of Nodes', number_nodes), ('Number of Edges', self.number_of_edges()), ('Number of...
[ "def", "_describe_list", "(", "self", ")", "->", "List", "[", "Tuple", "[", "str", ",", "float", "]", "]", ":", "number_nodes", "=", "self", ".", "number_of_nodes", "(", ")", "return", "[", "(", "'Number of Nodes'", ",", "number_nodes", ")", ",", "(", ...
Return useful information about the graph as a list of tuples.
[ "Return", "useful", "information", "about", "the", "graph", "as", "a", "list", "of", "tuples", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L758-L769
train
29,632
pybel/pybel
src/pybel/struct/graph.py
BELGraph.summary_str
def summary_str(self) -> str: """Return a string that summarizes the graph.""" return '{}\n'.format(self) + '\n'.join( '{}: {}'.format(label, value) for label, value in self._describe_list() )
python
def summary_str(self) -> str: """Return a string that summarizes the graph.""" return '{}\n'.format(self) + '\n'.join( '{}: {}'.format(label, value) for label, value in self._describe_list() )
[ "def", "summary_str", "(", "self", ")", "->", "str", ":", "return", "'{}\\n'", ".", "format", "(", "self", ")", "+", "'\\n'", ".", "join", "(", "'{}: {}'", ".", "format", "(", "label", ",", "value", ")", "for", "label", ",", "value", "in", "self", ...
Return a string that summarizes the graph.
[ "Return", "a", "string", "that", "summarizes", "the", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L775-L780
train
29,633
pybel/pybel
src/pybel/struct/graph.py
BELGraph.summarize
def summarize(self, file: Optional[TextIO] = None) -> None: """Print a summary of the graph.""" print(self.summary_str(), file=file)
python
def summarize(self, file: Optional[TextIO] = None) -> None: """Print a summary of the graph.""" print(self.summary_str(), file=file)
[ "def", "summarize", "(", "self", ",", "file", ":", "Optional", "[", "TextIO", "]", "=", "None", ")", "->", "None", ":", "print", "(", "self", ".", "summary_str", "(", ")", ",", "file", "=", "file", ")" ]
Print a summary of the graph.
[ "Print", "a", "summary", "of", "the", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L782-L784
train
29,634
pybel/pybel
src/pybel/struct/graph.py
BELGraph.serialize
def serialize(self, *, fmt: str = 'nodelink', file: Union[None, str, TextIO] = None, **kwargs): """Serialize the graph to an object or file if given. For additional I/O, see the :mod:`pybel.io` module. """ if file is None: return self._serialize_object(fmt=fmt, **kwargs) ...
python
def serialize(self, *, fmt: str = 'nodelink', file: Union[None, str, TextIO] = None, **kwargs): """Serialize the graph to an object or file if given. For additional I/O, see the :mod:`pybel.io` module. """ if file is None: return self._serialize_object(fmt=fmt, **kwargs) ...
[ "def", "serialize", "(", "self", ",", "*", ",", "fmt", ":", "str", "=", "'nodelink'", ",", "file", ":", "Union", "[", "None", ",", "str", ",", "TextIO", "]", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "file", "is", "None", ":", "retu...
Serialize the graph to an object or file if given. For additional I/O, see the :mod:`pybel.io` module.
[ "Serialize", "the", "graph", "to", "an", "object", "or", "file", "if", "given", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/graph.py#L786-L797
train
29,635
pybel/pybel
src/pybel/struct/mutation/utils.py
remove_isolated_nodes
def remove_isolated_nodes(graph): """Remove isolated nodes from the network, in place. :param pybel.BELGraph graph: A BEL graph """ nodes = list(nx.isolates(graph)) graph.remove_nodes_from(nodes)
python
def remove_isolated_nodes(graph): """Remove isolated nodes from the network, in place. :param pybel.BELGraph graph: A BEL graph """ nodes = list(nx.isolates(graph)) graph.remove_nodes_from(nodes)
[ "def", "remove_isolated_nodes", "(", "graph", ")", ":", "nodes", "=", "list", "(", "nx", ".", "isolates", "(", "graph", ")", ")", "graph", ".", "remove_nodes_from", "(", "nodes", ")" ]
Remove isolated nodes from the network, in place. :param pybel.BELGraph graph: A BEL graph
[ "Remove", "isolated", "nodes", "from", "the", "network", "in", "place", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/utils.py#L20-L26
train
29,636
pybel/pybel
src/pybel/struct/mutation/utils.py
remove_isolated_nodes_op
def remove_isolated_nodes_op(graph): """Build a new graph excluding the isolated nodes. :param pybel.BELGraph graph: A BEL graph :rtype: pybel.BELGraph """ rv = graph.copy() nodes = list(nx.isolates(rv)) rv.remove_nodes_from(nodes) return rv
python
def remove_isolated_nodes_op(graph): """Build a new graph excluding the isolated nodes. :param pybel.BELGraph graph: A BEL graph :rtype: pybel.BELGraph """ rv = graph.copy() nodes = list(nx.isolates(rv)) rv.remove_nodes_from(nodes) return rv
[ "def", "remove_isolated_nodes_op", "(", "graph", ")", ":", "rv", "=", "graph", ".", "copy", "(", ")", "nodes", "=", "list", "(", "nx", ".", "isolates", "(", "rv", ")", ")", "rv", ".", "remove_nodes_from", "(", "nodes", ")", "return", "rv" ]
Build a new graph excluding the isolated nodes. :param pybel.BELGraph graph: A BEL graph :rtype: pybel.BELGraph
[ "Build", "a", "new", "graph", "excluding", "the", "isolated", "nodes", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/utils.py#L30-L39
train
29,637
pybel/pybel
src/pybel/struct/mutation/utils.py
expand_by_edge_filter
def expand_by_edge_filter(source, target, edge_predicates: EdgePredicates): """Expand a target graph by edges in the source matching the given predicates. :param pybel.BELGraph source: A BEL graph :param pybel.BELGraph target: A BEL graph :param edge_predicates: An edge predicate or list of edge predic...
python
def expand_by_edge_filter(source, target, edge_predicates: EdgePredicates): """Expand a target graph by edges in the source matching the given predicates. :param pybel.BELGraph source: A BEL graph :param pybel.BELGraph target: A BEL graph :param edge_predicates: An edge predicate or list of edge predic...
[ "def", "expand_by_edge_filter", "(", "source", ",", "target", ",", "edge_predicates", ":", "EdgePredicates", ")", ":", "target", ".", "add_edges_from", "(", "(", "u", ",", "v", ",", "k", ",", "source", "[", "u", "]", "[", "v", "]", "[", "k", "]", ")"...
Expand a target graph by edges in the source matching the given predicates. :param pybel.BELGraph source: A BEL graph :param pybel.BELGraph target: A BEL graph :param edge_predicates: An edge predicate or list of edge predicates :return: A BEL sub-graph induced over the edges passing the given filters ...
[ "Expand", "a", "target", "graph", "by", "edges", "in", "the", "source", "matching", "the", "given", "predicates", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/utils.py#L43-L58
train
29,638
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.handle_document
def handle_document(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``SET DOCUMENT X = "Y"``. :raises: InvalidMetadataException :raises: VersionFormatWarning """ key = tokens['key'] value = tokens['value'] if key ...
python
def handle_document(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``SET DOCUMENT X = "Y"``. :raises: InvalidMetadataException :raises: VersionFormatWarning """ key = tokens['key'] value = tokens['value'] if key ...
[ "def", "handle_document", "(", "self", ",", "line", ":", "str", ",", "position", ":", "int", ",", "tokens", ":", "ParseResults", ")", "->", "ParseResults", ":", "key", "=", "tokens", "[", "'key'", "]", "value", "=", "tokens", "[", "'value'", "]", "if",...
Handle statements like ``SET DOCUMENT X = "Y"``. :raises: InvalidMetadataException :raises: VersionFormatWarning
[ "Handle", "statements", "like", "SET", "DOCUMENT", "X", "=", "Y", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L132-L155
train
29,639
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.raise_for_redefined_namespace
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...
python
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...
[ "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. :raises: RedefinedNamespaceError
[ "Raise", "an", "exception", "if", "a", "namespace", "is", "already", "defined", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L157-L163
train
29,640
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.handle_namespace_url
def handle_namespace_url(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE NAMESPACE X AS URL "Y"``. :raises: RedefinedNamespaceError :raises: pybel.resources.exc.ResourceError """ namespace = tokens['name'] self.ra...
python
def handle_namespace_url(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE NAMESPACE X AS URL "Y"``. :raises: RedefinedNamespaceError :raises: pybel.resources.exc.ResourceError """ namespace = tokens['name'] self.ra...
[ "def", "handle_namespace_url", "(", "self", ",", "line", ":", "str", ",", "position", ":", "int", ",", "tokens", ":", "ParseResults", ")", "->", "ParseResults", ":", "namespace", "=", "tokens", "[", "'name'", "]", "self", ".", "raise_for_redefined_namespace", ...
Handle statements like ``DEFINE NAMESPACE X AS URL "Y"``. :raises: RedefinedNamespaceError :raises: pybel.resources.exc.ResourceError
[ "Handle", "statements", "like", "DEFINE", "NAMESPACE", "X", "AS", "URL", "Y", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L165-L188
train
29,641
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.handle_namespace_pattern
def handle_namespace_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE NAMESPACE X AS PATTERN "Y"``. :raises: RedefinedNamespaceError """ namespace = tokens['name'] self.raise_for_redefined_namespace(line, position,...
python
def handle_namespace_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE NAMESPACE X AS PATTERN "Y"``. :raises: RedefinedNamespaceError """ namespace = tokens['name'] self.raise_for_redefined_namespace(line, position,...
[ "def", "handle_namespace_pattern", "(", "self", ",", "line", ":", "str", ",", "position", ":", "int", ",", "tokens", ":", "ParseResults", ")", "->", "ParseResults", ":", "namespace", "=", "tokens", "[", "'name'", "]", "self", ".", "raise_for_redefined_namespac...
Handle statements like ``DEFINE NAMESPACE X AS PATTERN "Y"``. :raises: RedefinedNamespaceError
[ "Handle", "statements", "like", "DEFINE", "NAMESPACE", "X", "AS", "PATTERN", "Y", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L190-L198
train
29,642
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.raise_for_redefined_annotation
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...
python
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...
[ "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. :raises: RedefinedAnnotationError
[ "Raise", "an", "exception", "if", "the", "given", "annotation", "is", "already", "defined", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L200-L206
train
29,643
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.handle_annotations_url
def handle_annotations_url(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE ANNOTATION X AS URL "Y"``. :raises: RedefinedAnnotationError """ keyword = tokens['name'] self.raise_for_redefined_annotation(line, position, keyw...
python
def handle_annotations_url(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE ANNOTATION X AS URL "Y"``. :raises: RedefinedAnnotationError """ keyword = tokens['name'] self.raise_for_redefined_annotation(line, position, keyw...
[ "def", "handle_annotations_url", "(", "self", ",", "line", ":", "str", ",", "position", ":", "int", ",", "tokens", ":", "ParseResults", ")", "->", "ParseResults", ":", "keyword", "=", "tokens", "[", "'name'", "]", "self", ".", "raise_for_redefined_annotation",...
Handle statements like ``DEFINE ANNOTATION X AS URL "Y"``. :raises: RedefinedAnnotationError
[ "Handle", "statements", "like", "DEFINE", "ANNOTATION", "X", "AS", "URL", "Y", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L208-L224
train
29,644
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.handle_annotation_pattern
def handle_annotation_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE ANNOTATION X AS PATTERN "Y"``. :raises: RedefinedAnnotationError """ annotation = tokens['name'] self.raise_for_redefined_annotation(line, posi...
python
def handle_annotation_pattern(self, line: str, position: int, tokens: ParseResults) -> ParseResults: """Handle statements like ``DEFINE ANNOTATION X AS PATTERN "Y"``. :raises: RedefinedAnnotationError """ annotation = tokens['name'] self.raise_for_redefined_annotation(line, posi...
[ "def", "handle_annotation_pattern", "(", "self", ",", "line", ":", "str", ",", "position", ":", "int", ",", "tokens", ":", "ParseResults", ")", "->", "ParseResults", ":", "annotation", "=", "tokens", "[", "'name'", "]", "self", ".", "raise_for_redefined_annota...
Handle statements like ``DEFINE ANNOTATION X AS PATTERN "Y"``. :raises: RedefinedAnnotationError
[ "Handle", "statements", "like", "DEFINE", "ANNOTATION", "X", "AS", "PATTERN", "Y", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L236-L244
train
29,645
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.has_annotation
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) )
python
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) )
[ "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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L258-L264
train
29,646
pybel/pybel
src/pybel/parser/parse_metadata.py
MetadataParser.raise_for_version
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 ...
python
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 ...
[ "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. 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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/parse_metadata.py#L278-L292
train
29,647
pybel/pybel
src/pybel/dsl/namespaces.py
chebi
def chebi(name=None, identifier=None) -> Abundance: """Build a ChEBI abundance node.""" return Abundance(namespace='CHEBI', name=name, identifier=identifier)
python
def chebi(name=None, identifier=None) -> Abundance: """Build a ChEBI abundance node.""" return Abundance(namespace='CHEBI', name=name, identifier=identifier)
[ "def", "chebi", "(", "name", "=", "None", ",", "identifier", "=", "None", ")", "->", "Abundance", ":", "return", "Abundance", "(", "namespace", "=", "'CHEBI'", ",", "name", "=", "name", ",", "identifier", "=", "identifier", ")" ]
Build a ChEBI abundance node.
[ "Build", "a", "ChEBI", "abundance", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/dsl/namespaces.py#L13-L15
train
29,648
pybel/pybel
src/pybel/dsl/namespaces.py
hgnc
def hgnc(name=None, identifier=None) -> Protein: """Build an HGNC protein node.""" return Protein(namespace='HGNC', name=name, identifier=identifier)
python
def hgnc(name=None, identifier=None) -> Protein: """Build an HGNC protein node.""" return Protein(namespace='HGNC', name=name, identifier=identifier)
[ "def", "hgnc", "(", "name", "=", "None", ",", "identifier", "=", "None", ")", "->", "Protein", ":", "return", "Protein", "(", "namespace", "=", "'HGNC'", ",", "name", "=", "name", ",", "identifier", "=", "identifier", ")" ]
Build an HGNC protein node.
[ "Build", "an", "HGNC", "protein", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/dsl/namespaces.py#L18-L20
train
29,649
pybel/pybel
src/pybel/manager/base_manager.py
build_engine_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) -> Tupl...
python
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) -> Tupl...
[ "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. :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", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/base_manager.py#L24-L78
train
29,650
pybel/pybel
src/pybel/manager/base_manager.py
BaseManager.create_all
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)
python
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)
[ "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. :param checkfirst: Check if the database exists before trying to re-make it
[ "Create", "the", "PyBEL", "cache", "s", "database", "and", "tables", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/base_manager.py#L92-L97
train
29,651
pybel/pybel
src/pybel/manager/base_manager.py
BaseManager.drop_all
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...
python
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...
[ "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. :param checkfirst: Check if the database exists before trying to drop it
[ "Drop", "all", "data", "tables", "and", "databases", "for", "the", "PyBEL", "cache", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/base_manager.py#L99-L105
train
29,652
pybel/pybel
src/pybel/manager/base_manager.py
BaseManager.bind
def bind(self) -> None: """Bind the metadata to the engine and session.""" self.base.metadata.bind = self.engine self.base.query = self.session.query_property()
python
def bind(self) -> None: """Bind the metadata to the engine and session.""" self.base.metadata.bind = self.engine self.base.query = self.session.query_property()
[ "def", "bind", "(", "self", ")", "->", "None", ":", "self", ".", "base", ".", "metadata", ".", "bind", "=", "self", ".", "engine", "self", ".", "base", ".", "query", "=", "self", ".", "session", ".", "query_property", "(", ")" ]
Bind the metadata to the engine and session.
[ "Bind", "the", "metadata", "to", "the", "engine", "and", "session", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/base_manager.py#L107-L110
train
29,653
pybel/pybel
src/pybel/manager/base_manager.py
BaseManager._list_model
def _list_model(self, model_cls: Type[X]) -> List[X]: """List the models in this class.""" return self.session.query(model_cls).all()
python
def _list_model(self, model_cls: Type[X]) -> List[X]: """List the models in this class.""" return self.session.query(model_cls).all()
[ "def", "_list_model", "(", "self", ",", "model_cls", ":", "Type", "[", "X", "]", ")", "->", "List", "[", "X", "]", ":", "return", "self", ".", "session", ".", "query", "(", "model_cls", ")", ".", "all", "(", ")" ]
List the models in this class.
[ "List", "the", "models", "in", "this", "class", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/base_manager.py#L112-L114
train
29,654
pybel/pybel
src/pybel/manager/citation_utils.py
sanitize_date
def sanitize_date(publication_date: str) -> str: """Sanitize lots of different date strings into ISO-8601.""" if re1.search(publication_date): return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d') if re2.search(publication_date): return datetime.strptime(publication_da...
python
def sanitize_date(publication_date: str) -> str: """Sanitize lots of different date strings into ISO-8601.""" if re1.search(publication_date): return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d') if re2.search(publication_date): return datetime.strptime(publication_da...
[ "def", "sanitize_date", "(", "publication_date", ":", "str", ")", "->", "str", ":", "if", "re1", ".", "search", "(", "publication_date", ")", ":", "return", "datetime", ".", "strptime", "(", "publication_date", ",", "'%Y %b %d'", ")", ".", "strftime", "(", ...
Sanitize lots of different date strings into ISO-8601.
[ "Sanitize", "lots", "of", "different", "date", "strings", "into", "ISO", "-", "8601", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L39-L67
train
29,655
pybel/pybel
src/pybel/manager/citation_utils.py
clean_pubmed_identifiers
def clean_pubmed_identifiers(pmids: Iterable[str]) -> List[str]: """Clean a list of PubMed identifiers with string strips, deduplicates, and sorting.""" return sorted({str(pmid).strip() for pmid in pmids})
python
def clean_pubmed_identifiers(pmids: Iterable[str]) -> List[str]: """Clean a list of PubMed identifiers with string strips, deduplicates, and sorting.""" return sorted({str(pmid).strip() for pmid in pmids})
[ "def", "clean_pubmed_identifiers", "(", "pmids", ":", "Iterable", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "return", "sorted", "(", "{", "str", "(", "pmid", ")", ".", "strip", "(", ")", "for", "pmid", "in", "pmids", "}", ")" ]
Clean a list of PubMed identifiers with string strips, deduplicates, and sorting.
[ "Clean", "a", "list", "of", "PubMed", "identifiers", "with", "string", "strips", "deduplicates", "and", "sorting", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L79-L81
train
29,656
pybel/pybel
src/pybel/manager/citation_utils.py
get_pubmed_citation_response
def get_pubmed_citation_response(pubmed_identifiers: Iterable[str]): """Get the response from PubMed E-Utils for a given list of PubMed identifiers. :param pubmed_identifiers: :rtype: dict """ pubmed_identifiers = list(pubmed_identifiers) url = EUTILS_URL_FMT.format(','.join( pubmed_ide...
python
def get_pubmed_citation_response(pubmed_identifiers: Iterable[str]): """Get the response from PubMed E-Utils for a given list of PubMed identifiers. :param pubmed_identifiers: :rtype: dict """ pubmed_identifiers = list(pubmed_identifiers) url = EUTILS_URL_FMT.format(','.join( pubmed_ide...
[ "def", "get_pubmed_citation_response", "(", "pubmed_identifiers", ":", "Iterable", "[", "str", "]", ")", ":", "pubmed_identifiers", "=", "list", "(", "pubmed_identifiers", ")", "url", "=", "EUTILS_URL_FMT", ".", "format", "(", "','", ".", "join", "(", "pubmed_id...
Get the response from PubMed E-Utils for a given list of PubMed identifiers. :param pubmed_identifiers: :rtype: dict
[ "Get", "the", "response", "from", "PubMed", "E", "-", "Utils", "for", "a", "given", "list", "of", "PubMed", "identifiers", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L84-L97
train
29,657
pybel/pybel
src/pybel/manager/citation_utils.py
enrich_citation_model
def enrich_citation_model(manager, citation, p) -> bool: """Enrich a citation model with the information from PubMed. :param pybel.manager.Manager manager: :param Citation citation: A citation model :param dict p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid] """ if 'err...
python
def enrich_citation_model(manager, citation, p) -> bool: """Enrich a citation model with the information from PubMed. :param pybel.manager.Manager manager: :param Citation citation: A citation model :param dict p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid] """ if 'err...
[ "def", "enrich_citation_model", "(", "manager", ",", "citation", ",", "p", ")", "->", "bool", ":", "if", "'error'", "in", "p", ":", "log", ".", "warning", "(", "'Error downloading PubMed'", ")", "return", "False", "citation", ".", "name", "=", "p", "[", ...
Enrich a citation model with the information from PubMed. :param pybel.manager.Manager manager: :param Citation citation: A citation model :param dict p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
[ "Enrich", "a", "citation", "model", "with", "the", "information", "from", "PubMed", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L100-L133
train
29,658
pybel/pybel
src/pybel/manager/citation_utils.py
get_citations_by_pmids
def get_citations_by_pmids(manager, pmids: Iterable[Union[str, int]], group_size: Optional[int] = None, sleep_time: Optional[int] = None, ) -> Tuple[Dict[str, Dict], Set[str]]: """Get citation information for...
python
def get_citations_by_pmids(manager, pmids: Iterable[Union[str, int]], group_size: Optional[int] = None, sleep_time: Optional[int] = None, ) -> Tuple[Dict[str, Dict], Set[str]]: """Get citation information for...
[ "def", "get_citations_by_pmids", "(", "manager", ",", "pmids", ":", "Iterable", "[", "Union", "[", "str", ",", "int", "]", "]", ",", "group_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "sleep_time", ":", "Optional", "[", "int", "]", "=", ...
Get citation information for the given list of PubMed identifiers using the NCBI's eUtils service. :type manager: pybel.Manager :param pmids: an iterable of PubMed identifiers :param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers. :param sleep_time: Number ...
[ "Get", "citation", "information", "for", "the", "given", "list", "of", "PubMed", "identifiers", "using", "the", "NCBI", "s", "eUtils", "service", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L136-L209
train
29,659
pybel/pybel
src/pybel/manager/citation_utils.py
enrich_pubmed_citations
def enrich_pubmed_citations(manager, graph, group_size: Optional[int] = None, sleep_time: Optional[int] = None, ) -> Set[str]: """Overwrite all PubMed citations with values from NCBI's eUtils lookup servi...
python
def enrich_pubmed_citations(manager, graph, group_size: Optional[int] = None, sleep_time: Optional[int] = None, ) -> Set[str]: """Overwrite all PubMed citations with values from NCBI's eUtils lookup servi...
[ "def", "enrich_pubmed_citations", "(", "manager", ",", "graph", ",", "group_size", ":", "Optional", "[", "int", "]", "=", "None", ",", "sleep_time", ":", "Optional", "[", "int", "]", "=", "None", ",", ")", "->", "Set", "[", "str", "]", ":", "pmids", ...
Overwrite all PubMed citations with values from NCBI's eUtils lookup service. Sets authors as list, so probably a good idea to run :func:`pybel_tools.mutation.serialize_authors` before exporting. :type manager: pybel.manager.Manager :type graph: pybel.BELGraph :param group_size: The number of PubM...
[ "Overwrite", "all", "PubMed", "citations", "with", "values", "from", "NCBI", "s", "eUtils", "lookup", "service", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/manager/citation_utils.py#L212-L241
train
29,660
pybel/pybel
src/pybel/struct/mutation/collapse/protein_rna_origins.py
_build_collapse_to_gene_dict
def _build_collapse_to_gene_dict(graph) -> Dict[BaseEntity, Set[BaseEntity]]: """Build a collapse dictionary. :param pybel.BELGraph graph: A BEL graph :return: A dictionary of {node: set of PyBEL node tuples} """ collapse_dict = defaultdict(set) r2g = {} for gene_node, rna_node, d in graph...
python
def _build_collapse_to_gene_dict(graph) -> Dict[BaseEntity, Set[BaseEntity]]: """Build a collapse dictionary. :param pybel.BELGraph graph: A BEL graph :return: A dictionary of {node: set of PyBEL node tuples} """ collapse_dict = defaultdict(set) r2g = {} for gene_node, rna_node, d in graph...
[ "def", "_build_collapse_to_gene_dict", "(", "graph", ")", "->", "Dict", "[", "BaseEntity", ",", "Set", "[", "BaseEntity", "]", "]", ":", "collapse_dict", "=", "defaultdict", "(", "set", ")", "r2g", "=", "{", "}", "for", "gene_node", ",", "rna_node", ",", ...
Build a collapse dictionary. :param pybel.BELGraph graph: A BEL graph :return: A dictionary of {node: set of PyBEL node tuples}
[ "Build", "a", "collapse", "dictionary", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/collapse/protein_rna_origins.py#L19-L44
train
29,661
pybel/pybel
src/pybel/struct/mutation/collapse/protein_rna_origins.py
collapse_to_genes
def collapse_to_genes(graph): """Collapse all protein, RNA, and miRNA nodes to their corresponding gene nodes. :param pybel.BELGraph graph: A BEL graph """ enrich_protein_and_rna_origins(graph) collapse_dict = _build_collapse_to_gene_dict(graph) collapse_nodes(graph, collapse_dict)
python
def collapse_to_genes(graph): """Collapse all protein, RNA, and miRNA nodes to their corresponding gene nodes. :param pybel.BELGraph graph: A BEL graph """ enrich_protein_and_rna_origins(graph) collapse_dict = _build_collapse_to_gene_dict(graph) collapse_nodes(graph, collapse_dict)
[ "def", "collapse_to_genes", "(", "graph", ")", ":", "enrich_protein_and_rna_origins", "(", "graph", ")", "collapse_dict", "=", "_build_collapse_to_gene_dict", "(", "graph", ")", "collapse_nodes", "(", "graph", ",", "collapse_dict", ")" ]
Collapse all protein, RNA, and miRNA nodes to their corresponding gene nodes. :param pybel.BELGraph graph: A BEL graph
[ "Collapse", "all", "protein", "RNA", "and", "miRNA", "nodes", "to", "their", "corresponding", "gene", "nodes", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/collapse/protein_rna_origins.py#L49-L56
train
29,662
pybel/pybel
src/pybel/cli.py
main
def main(ctx, connection): """Command line interface for PyBEL.""" ctx.obj = Manager(connection=connection) ctx.obj.bind()
python
def main(ctx, connection): """Command line interface for PyBEL.""" ctx.obj = Manager(connection=connection) ctx.obj.bind()
[ "def", "main", "(", "ctx", ",", "connection", ")", ":", "ctx", ".", "obj", "=", "Manager", "(", "connection", "=", "connection", ")", "ctx", ".", "obj", ".", "bind", "(", ")" ]
Command line interface for PyBEL.
[ "Command", "line", "interface", "for", "PyBEL", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L87-L90
train
29,663
pybel/pybel
src/pybel/cli.py
compile
def compile(manager, path, allow_naked_names, allow_nested, disallow_unqualified_translocations, no_identifier_validation, no_citation_clearing, required_annotations, skip_tqdm, verbose): """Compile a BEL script to a graph.""" if verbose: logging.basicConfig(level=logging.DEBUG) log....
python
def compile(manager, path, allow_naked_names, allow_nested, disallow_unqualified_translocations, no_identifier_validation, no_citation_clearing, required_annotations, skip_tqdm, verbose): """Compile a BEL script to a graph.""" if verbose: logging.basicConfig(level=logging.DEBUG) log....
[ "def", "compile", "(", "manager", ",", "path", ",", "allow_naked_names", ",", "allow_nested", ",", "disallow_unqualified_translocations", ",", "no_identifier_validation", ",", "no_citation_clearing", ",", "required_annotations", ",", "skip_tqdm", ",", "verbose", ")", ":...
Compile a BEL script to a graph.
[ "Compile", "a", "BEL", "script", "to", "a", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L104-L134
train
29,664
pybel/pybel
src/pybel/cli.py
insert
def insert(manager, graph: BELGraph): """Insert a graph to the database.""" to_database(graph, manager=manager, use_tqdm=True)
python
def insert(manager, graph: BELGraph): """Insert a graph to the database.""" to_database(graph, manager=manager, use_tqdm=True)
[ "def", "insert", "(", "manager", ",", "graph", ":", "BELGraph", ")", ":", "to_database", "(", "graph", ",", "manager", "=", "manager", ",", "use_tqdm", "=", "True", ")" ]
Insert a graph to the database.
[ "Insert", "a", "graph", "to", "the", "database", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L200-L202
train
29,665
pybel/pybel
src/pybel/cli.py
post
def post(graph: BELGraph, host: str): """Upload a graph to BEL Commons.""" resp = to_web(graph, host=host) resp.raise_for_status()
python
def post(graph: BELGraph, host: str): """Upload a graph to BEL Commons.""" resp = to_web(graph, host=host) resp.raise_for_status()
[ "def", "post", "(", "graph", ":", "BELGraph", ",", "host", ":", "str", ")", ":", "resp", "=", "to_web", "(", "graph", ",", "host", "=", "host", ")", "resp", ".", "raise_for_status", "(", ")" ]
Upload a graph to BEL Commons.
[ "Upload", "a", "graph", "to", "BEL", "Commons", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L208-L211
train
29,666
pybel/pybel
src/pybel/cli.py
serialize
def serialize(graph: BELGraph, csv, sif, gsea, graphml, json, bel): """Serialize a graph to various formats.""" if csv: log.info('Outputting CSV to %s', csv) to_csv(graph, csv) if sif: log.info('Outputting SIF to %s', sif) to_sif(graph, sif) if graphml: log.info...
python
def serialize(graph: BELGraph, csv, sif, gsea, graphml, json, bel): """Serialize a graph to various formats.""" if csv: log.info('Outputting CSV to %s', csv) to_csv(graph, csv) if sif: log.info('Outputting SIF to %s', sif) to_sif(graph, sif) if graphml: log.info...
[ "def", "serialize", "(", "graph", ":", "BELGraph", ",", "csv", ",", "sif", ",", "gsea", ",", "graphml", ",", "json", ",", "bel", ")", ":", "if", "csv", ":", "log", ".", "info", "(", "'Outputting CSV to %s'", ",", "csv", ")", "to_csv", "(", "graph", ...
Serialize a graph to various formats.
[ "Serialize", "a", "graph", "to", "various", "formats", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L222-L246
train
29,667
pybel/pybel
src/pybel/cli.py
neo
def neo(graph: BELGraph, connection: str, password: str): """Upload to neo4j.""" import py2neo neo_graph = py2neo.Graph(connection, password=password) to_neo4j(graph, neo_graph)
python
def neo(graph: BELGraph, connection: str, password: str): """Upload to neo4j.""" import py2neo neo_graph = py2neo.Graph(connection, password=password) to_neo4j(graph, neo_graph)
[ "def", "neo", "(", "graph", ":", "BELGraph", ",", "connection", ":", "str", ",", "password", ":", "str", ")", ":", "import", "py2neo", "neo_graph", "=", "py2neo", ".", "Graph", "(", "connection", ",", "password", "=", "password", ")", "to_neo4j", "(", ...
Upload to neo4j.
[ "Upload", "to", "neo4j", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L253-L257
train
29,668
pybel/pybel
src/pybel/cli.py
machine
def machine(manager: Manager, agents: List[str], local: bool, host: str): """Get content from the INDRA machine and upload to BEL Commons.""" from indra.sources import indra_db_rest from pybel import from_indra_statements statements = indra_db_rest.get_statements(agents=agents) click.echo('got {} s...
python
def machine(manager: Manager, agents: List[str], local: bool, host: str): """Get content from the INDRA machine and upload to BEL Commons.""" from indra.sources import indra_db_rest from pybel import from_indra_statements statements = indra_db_rest.get_statements(agents=agents) click.echo('got {} s...
[ "def", "machine", "(", "manager", ":", "Manager", ",", "agents", ":", "List", "[", "str", "]", ",", "local", ":", "bool", ",", "host", ":", "str", ")", ":", "from", "indra", ".", "sources", "import", "indra_db_rest", "from", "pybel", "import", "from_in...
Get content from the INDRA machine and upload to BEL Commons.
[ "Get", "content", "from", "the", "INDRA", "machine", "and", "upload", "to", "BEL", "Commons", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L265-L288
train
29,669
pybel/pybel
src/pybel/cli.py
examples
def examples(manager: Manager): """Load examples to the database.""" for graph in (sialic_acid_graph, statin_graph, homology_graph, braf_graph, egf_graph): if manager.has_name_version(graph.name, graph.version): click.echo('already inserted {}'.format(graph)) continue cli...
python
def examples(manager: Manager): """Load examples to the database.""" for graph in (sialic_acid_graph, statin_graph, homology_graph, braf_graph, egf_graph): if manager.has_name_version(graph.name, graph.version): click.echo('already inserted {}'.format(graph)) continue cli...
[ "def", "examples", "(", "manager", ":", "Manager", ")", ":", "for", "graph", "in", "(", "sialic_acid_graph", ",", "statin_graph", ",", "homology_graph", ",", "braf_graph", ",", "egf_graph", ")", ":", "if", "manager", ".", "has_name_version", "(", "graph", "....
Load examples to the database.
[ "Load", "examples", "to", "the", "database", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L306-L313
train
29,670
pybel/pybel
src/pybel/cli.py
ls
def ls(manager: Manager, url: Optional[str], namespace_id: Optional[int]): """List cached namespaces.""" if url: n = manager.get_or_create_namespace(url) if isinstance(n, Namespace): _page(n.entries) else: click.echo('uncachable namespace') elif namespace_id i...
python
def ls(manager: Manager, url: Optional[str], namespace_id: Optional[int]): """List cached namespaces.""" if url: n = manager.get_or_create_namespace(url) if isinstance(n, Namespace): _page(n.entries) else: click.echo('uncachable namespace') elif namespace_id i...
[ "def", "ls", "(", "manager", ":", "Manager", ",", "url", ":", "Optional", "[", "str", "]", ",", "namespace_id", ":", "Optional", "[", "int", "]", ")", ":", "if", "url", ":", "n", "=", "manager", ".", "get_or_create_namespace", "(", "url", ")", "if", ...
List cached namespaces.
[ "List", "cached", "namespaces", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L343-L354
train
29,671
pybel/pybel
src/pybel/cli.py
ls
def ls(manager: Manager): """List network names, versions, and optionally, descriptions.""" for n in manager.list_networks(): click.echo('{}\t{}\t{}'.format(n.id, n.name, n.version))
python
def ls(manager: Manager): """List network names, versions, and optionally, descriptions.""" for n in manager.list_networks(): click.echo('{}\t{}\t{}'.format(n.id, n.name, n.version))
[ "def", "ls", "(", "manager", ":", "Manager", ")", ":", "for", "n", "in", "manager", ".", "list_networks", "(", ")", ":", "click", ".", "echo", "(", "'{}\\t{}\\t{}'", ".", "format", "(", "n", ".", "id", ",", "n", ".", "name", ",", "n", ".", "versi...
List network names, versions, and optionally, descriptions.
[ "List", "network", "names", "versions", "and", "optionally", "descriptions", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L372-L375
train
29,672
pybel/pybel
src/pybel/cli.py
drop
def drop(manager: Manager, network_id: Optional[int], yes): """Drop a network by its identifier or drop all networks.""" if network_id: manager.drop_network_by_id(network_id) elif yes or click.confirm('Drop all networks?'): manager.drop_networks()
python
def drop(manager: Manager, network_id: Optional[int], yes): """Drop a network by its identifier or drop all networks.""" if network_id: manager.drop_network_by_id(network_id) elif yes or click.confirm('Drop all networks?'): manager.drop_networks()
[ "def", "drop", "(", "manager", ":", "Manager", ",", "network_id", ":", "Optional", "[", "int", "]", ",", "yes", ")", ":", "if", "network_id", ":", "manager", ".", "drop_network_by_id", "(", "network_id", ")", "elif", "yes", "or", "click", ".", "confirm",...
Drop a network by its identifier or drop all networks.
[ "Drop", "a", "network", "by", "its", "identifier", "or", "drop", "all", "networks", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L382-L388
train
29,673
pybel/pybel
src/pybel/cli.py
ls
def ls(manager: Manager, offset: Optional[int], limit: Optional[int]): """List edges.""" q = manager.session.query(Edge) if offset: q = q.offset(offset) if limit > 0: q = q.limit(limit) for e in q: click.echo(e.bel)
python
def ls(manager: Manager, offset: Optional[int], limit: Optional[int]): """List edges.""" q = manager.session.query(Edge) if offset: q = q.offset(offset) if limit > 0: q = q.limit(limit) for e in q: click.echo(e.bel)
[ "def", "ls", "(", "manager", ":", "Manager", ",", "offset", ":", "Optional", "[", "int", "]", ",", "limit", ":", "Optional", "[", "int", "]", ")", ":", "q", "=", "manager", ".", "session", ".", "query", "(", "Edge", ")", "if", "offset", ":", "q",...
List edges.
[ "List", "edges", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L400-L411
train
29,674
pybel/pybel
src/pybel/cli.py
prune
def prune(manager: Manager): """Prune nodes not belonging to any edges.""" nodes_to_delete = [ node for node in tqdm(manager.session.query(Node), total=manager.count_nodes()) if not node.networks ] manager.session.delete(nodes_to_delete) manager.session.commit()
python
def prune(manager: Manager): """Prune nodes not belonging to any edges.""" nodes_to_delete = [ node for node in tqdm(manager.session.query(Node), total=manager.count_nodes()) if not node.networks ] manager.session.delete(nodes_to_delete) manager.session.commit()
[ "def", "prune", "(", "manager", ":", "Manager", ")", ":", "nodes_to_delete", "=", "[", "node", "for", "node", "in", "tqdm", "(", "manager", ".", "session", ".", "query", "(", "Node", ")", ",", "total", "=", "manager", ".", "count_nodes", "(", ")", ")...
Prune nodes not belonging to any edges.
[ "Prune", "nodes", "not", "belonging", "to", "any", "edges", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L421-L429
train
29,675
pybel/pybel
src/pybel/cli.py
summarize
def summarize(manager: Manager): """Summarize the contents of the database.""" click.echo('Networks: {}'.format(manager.count_networks())) click.echo('Edges: {}'.format(manager.count_edges())) click.echo('Nodes: {}'.format(manager.count_nodes())) click.echo('Namespaces: {}'.format(manager.count_name...
python
def summarize(manager: Manager): """Summarize the contents of the database.""" click.echo('Networks: {}'.format(manager.count_networks())) click.echo('Edges: {}'.format(manager.count_edges())) click.echo('Nodes: {}'.format(manager.count_nodes())) click.echo('Namespaces: {}'.format(manager.count_name...
[ "def", "summarize", "(", "manager", ":", "Manager", ")", ":", "click", ".", "echo", "(", "'Networks: {}'", ".", "format", "(", "manager", ".", "count_networks", "(", ")", ")", ")", "click", ".", "echo", "(", "'Edges: {}'", ".", "format", "(", "manager", ...
Summarize the contents of the database.
[ "Summarize", "the", "contents", "of", "the", "database", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L434-L442
train
29,676
pybel/pybel
src/pybel/cli.py
echo_warnings_via_pager
def echo_warnings_via_pager(warnings: List[WarningTuple], sep: str = '\t') -> None: """Output the warnings from a BEL graph with Click and the system's pager.""" # Exit if no warnings if not warnings: click.echo('Congratulations! No warnings.') sys.exit(0) max_line_width = max( ...
python
def echo_warnings_via_pager(warnings: List[WarningTuple], sep: str = '\t') -> None: """Output the warnings from a BEL graph with Click and the system's pager.""" # Exit if no warnings if not warnings: click.echo('Congratulations! No warnings.') sys.exit(0) max_line_width = max( ...
[ "def", "echo_warnings_via_pager", "(", "warnings", ":", "List", "[", "WarningTuple", "]", ",", "sep", ":", "str", "=", "'\\t'", ")", "->", "None", ":", "# Exit if no warnings", "if", "not", "warnings", ":", "click", ".", "echo", "(", "'Congratulations! No warn...
Output the warnings from a BEL graph with Click and the system's pager.
[ "Output", "the", "warnings", "from", "a", "BEL", "graph", "with", "Click", "and", "the", "system", "s", "pager", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/cli.py#L445-L477
train
29,677
pybel/pybel
src/pybel/tokens.py
parse_result_to_dsl
def parse_result_to_dsl(tokens): """Convert a ParseResult to a PyBEL DSL object. :type tokens: dict or pyparsing.ParseResults :rtype: BaseEntity """ if MODIFIER in tokens: return parse_result_to_dsl(tokens[TARGET]) elif REACTION == tokens[FUNCTION]: return _reaction_po_to_dict(...
python
def parse_result_to_dsl(tokens): """Convert a ParseResult to a PyBEL DSL object. :type tokens: dict or pyparsing.ParseResults :rtype: BaseEntity """ if MODIFIER in tokens: return parse_result_to_dsl(tokens[TARGET]) elif REACTION == tokens[FUNCTION]: return _reaction_po_to_dict(...
[ "def", "parse_result_to_dsl", "(", "tokens", ")", ":", "if", "MODIFIER", "in", "tokens", ":", "return", "parse_result_to_dsl", "(", "tokens", "[", "TARGET", "]", ")", "elif", "REACTION", "==", "tokens", "[", "FUNCTION", "]", ":", "return", "_reaction_po_to_dic...
Convert a ParseResult to a PyBEL DSL object. :type tokens: dict or pyparsing.ParseResults :rtype: BaseEntity
[ "Convert", "a", "ParseResult", "to", "a", "PyBEL", "DSL", "object", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L24-L45
train
29,678
pybel/pybel
src/pybel/tokens.py
_fusion_to_dsl
def _fusion_to_dsl(tokens) -> FusionBase: """Convert a PyParsing data dictionary to a PyBEL fusion data dictionary. :param tokens: A PyParsing data dictionary representing a fusion :type tokens: ParseResult """ func = tokens[FUNCTION] fusion_dsl = FUNC_TO_FUSION_DSL[func] member_dsl = FUNC_...
python
def _fusion_to_dsl(tokens) -> FusionBase: """Convert a PyParsing data dictionary to a PyBEL fusion data dictionary. :param tokens: A PyParsing data dictionary representing a fusion :type tokens: ParseResult """ func = tokens[FUNCTION] fusion_dsl = FUNC_TO_FUSION_DSL[func] member_dsl = FUNC_...
[ "def", "_fusion_to_dsl", "(", "tokens", ")", "->", "FusionBase", ":", "func", "=", "tokens", "[", "FUNCTION", "]", "fusion_dsl", "=", "FUNC_TO_FUSION_DSL", "[", "func", "]", "member_dsl", "=", "FUNC_TO_DSL", "[", "func", "]", "partner_5p", "=", "member_dsl", ...
Convert a PyParsing data dictionary to a PyBEL fusion data dictionary. :param tokens: A PyParsing data dictionary representing a fusion :type tokens: ParseResult
[ "Convert", "a", "PyParsing", "data", "dictionary", "to", "a", "PyBEL", "fusion", "data", "dictionary", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L48-L76
train
29,679
pybel/pybel
src/pybel/tokens.py
_fusion_range_to_dsl
def _fusion_range_to_dsl(tokens) -> FusionRangeBase: """Convert a PyParsing data dictionary into a PyBEL. :type tokens: ParseResult """ if FUSION_MISSING in tokens: return missing_fusion_range() return fusion_range( reference=tokens[FUSION_REFERENCE], start=tokens[FUSION_ST...
python
def _fusion_range_to_dsl(tokens) -> FusionRangeBase: """Convert a PyParsing data dictionary into a PyBEL. :type tokens: ParseResult """ if FUSION_MISSING in tokens: return missing_fusion_range() return fusion_range( reference=tokens[FUSION_REFERENCE], start=tokens[FUSION_ST...
[ "def", "_fusion_range_to_dsl", "(", "tokens", ")", "->", "FusionRangeBase", ":", "if", "FUSION_MISSING", "in", "tokens", ":", "return", "missing_fusion_range", "(", ")", "return", "fusion_range", "(", "reference", "=", "tokens", "[", "FUSION_REFERENCE", "]", ",", ...
Convert a PyParsing data dictionary into a PyBEL. :type tokens: ParseResult
[ "Convert", "a", "PyParsing", "data", "dictionary", "into", "a", "PyBEL", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L79-L91
train
29,680
pybel/pybel
src/pybel/tokens.py
_simple_po_to_dict
def _simple_po_to_dict(tokens) -> BaseAbundance: """Convert a simple named entity to a DSL object. :type tokens: ParseResult """ dsl = FUNC_TO_DSL.get(tokens[FUNCTION]) if dsl is None: raise ValueError('invalid tokens: {}'.format(tokens)) return dsl( namespace=tokens[NAMESPACE]...
python
def _simple_po_to_dict(tokens) -> BaseAbundance: """Convert a simple named entity to a DSL object. :type tokens: ParseResult """ dsl = FUNC_TO_DSL.get(tokens[FUNCTION]) if dsl is None: raise ValueError('invalid tokens: {}'.format(tokens)) return dsl( namespace=tokens[NAMESPACE]...
[ "def", "_simple_po_to_dict", "(", "tokens", ")", "->", "BaseAbundance", ":", "dsl", "=", "FUNC_TO_DSL", ".", "get", "(", "tokens", "[", "FUNCTION", "]", ")", "if", "dsl", "is", "None", ":", "raise", "ValueError", "(", "'invalid tokens: {}'", ".", "format", ...
Convert a simple named entity to a DSL object. :type tokens: ParseResult
[ "Convert", "a", "simple", "named", "entity", "to", "a", "DSL", "object", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L94-L107
train
29,681
pybel/pybel
src/pybel/tokens.py
_variant_to_dsl_helper
def _variant_to_dsl_helper(tokens) -> Variant: """Convert variant tokens to DSL objects. :type tokens: ParseResult """ kind = tokens[KIND] if kind == HGVS: return hgvs(tokens[IDENTIFIER]) if kind == GMOD: return gmod( name=tokens[IDENTIFIER][NAME], name...
python
def _variant_to_dsl_helper(tokens) -> Variant: """Convert variant tokens to DSL objects. :type tokens: ParseResult """ kind = tokens[KIND] if kind == HGVS: return hgvs(tokens[IDENTIFIER]) if kind == GMOD: return gmod( name=tokens[IDENTIFIER][NAME], name...
[ "def", "_variant_to_dsl_helper", "(", "tokens", ")", "->", "Variant", ":", "kind", "=", "tokens", "[", "KIND", "]", "if", "kind", "==", "HGVS", ":", "return", "hgvs", "(", "tokens", "[", "IDENTIFIER", "]", ")", "if", "kind", "==", "GMOD", ":", "return"...
Convert variant tokens to DSL objects. :type tokens: ParseResult
[ "Convert", "variant", "tokens", "to", "DSL", "objects", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L129-L161
train
29,682
pybel/pybel
src/pybel/tokens.py
_reaction_po_to_dict
def _reaction_po_to_dict(tokens) -> Reaction: """Convert a reaction parse object to a DSL. :type tokens: ParseResult """ return Reaction( reactants=_reaction_part_po_to_dict(tokens[REACTANTS]), products=_reaction_part_po_to_dict(tokens[PRODUCTS]), )
python
def _reaction_po_to_dict(tokens) -> Reaction: """Convert a reaction parse object to a DSL. :type tokens: ParseResult """ return Reaction( reactants=_reaction_part_po_to_dict(tokens[REACTANTS]), products=_reaction_part_po_to_dict(tokens[PRODUCTS]), )
[ "def", "_reaction_po_to_dict", "(", "tokens", ")", "->", "Reaction", ":", "return", "Reaction", "(", "reactants", "=", "_reaction_part_po_to_dict", "(", "tokens", "[", "REACTANTS", "]", ")", ",", "products", "=", "_reaction_part_po_to_dict", "(", "tokens", "[", ...
Convert a reaction parse object to a DSL. :type tokens: ParseResult
[ "Convert", "a", "reaction", "parse", "object", "to", "a", "DSL", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L164-L172
train
29,683
pybel/pybel
src/pybel/tokens.py
_list_po_to_dict
def _list_po_to_dict(tokens) -> ListAbundance: """Convert a list parse object to a node. :type tokens: ParseResult """ func = tokens[FUNCTION] dsl = FUNC_TO_LIST_DSL[func] members = [parse_result_to_dsl(token) for token in tokens[MEMBERS]] return dsl(members)
python
def _list_po_to_dict(tokens) -> ListAbundance: """Convert a list parse object to a node. :type tokens: ParseResult """ func = tokens[FUNCTION] dsl = FUNC_TO_LIST_DSL[func] members = [parse_result_to_dsl(token) for token in tokens[MEMBERS]] return dsl(members)
[ "def", "_list_po_to_dict", "(", "tokens", ")", "->", "ListAbundance", ":", "func", "=", "tokens", "[", "FUNCTION", "]", "dsl", "=", "FUNC_TO_LIST_DSL", "[", "func", "]", "members", "=", "[", "parse_result_to_dsl", "(", "token", ")", "for", "token", "in", "...
Convert a list parse object to a node. :type tokens: ParseResult
[ "Convert", "a", "list", "parse", "object", "to", "a", "node", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/tokens.py#L183-L193
train
29,684
pybel/pybel
src/pybel/struct/mutation/induction/annotations.py
get_subgraph_by_annotations
def get_subgraph_by_annotations(graph, annotations, or_=None): """Induce a sub-graph given an annotations filter. :param graph: pybel.BELGraph graph: A BEL graph :param dict[str,iter[str]] annotations: Annotation filters (match all with :func:`pybel.utils.subdict_matches`) :param boolean or_: if True a...
python
def get_subgraph_by_annotations(graph, annotations, or_=None): """Induce a sub-graph given an annotations filter. :param graph: pybel.BELGraph graph: A BEL graph :param dict[str,iter[str]] annotations: Annotation filters (match all with :func:`pybel.utils.subdict_matches`) :param boolean or_: if True a...
[ "def", "get_subgraph_by_annotations", "(", "graph", ",", "annotations", ",", "or_", "=", "None", ")", ":", "edge_filter_builder", "=", "(", "build_annotation_dict_any_filter", "if", "(", "or_", "is", "None", "or", "or_", ")", "else", "build_annotation_dict_all_filte...
Induce a sub-graph given an annotations filter. :param graph: pybel.BELGraph graph: A BEL graph :param dict[str,iter[str]] annotations: Annotation filters (match all with :func:`pybel.utils.subdict_matches`) :param boolean or_: if True any annotation should be present, if False all annotations should be pr...
[ "Induce", "a", "sub", "-", "graph", "given", "an", "annotations", "filter", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/induction/annotations.py#L20-L36
train
29,685
pybel/pybel
src/pybel/struct/mutation/induction/annotations.py
get_subgraph_by_annotation_value
def get_subgraph_by_annotation_value(graph, annotation, values): """Induce a sub-graph over all edges whose annotations match the given key and value. :param pybel.BELGraph graph: A BEL graph :param str annotation: The annotation to group by :param values: The value(s) for the annotation :type valu...
python
def get_subgraph_by_annotation_value(graph, annotation, values): """Induce a sub-graph over all edges whose annotations match the given key and value. :param pybel.BELGraph graph: A BEL graph :param str annotation: The annotation to group by :param values: The value(s) for the annotation :type valu...
[ "def", "get_subgraph_by_annotation_value", "(", "graph", ",", "annotation", ",", "values", ")", ":", "if", "isinstance", "(", "values", ",", "str", ")", ":", "values", "=", "{", "values", "}", "return", "get_subgraph_by_annotations", "(", "graph", ",", "{", ...
Induce a sub-graph over all edges whose annotations match the given key and value. :param pybel.BELGraph graph: A BEL graph :param str annotation: The annotation to group by :param values: The value(s) for the annotation :type values: str or iter[str] :return: A subgraph of the original BEL graph ...
[ "Induce", "a", "sub", "-", "graph", "over", "all", "edges", "whose", "annotations", "match", "the", "given", "key", "and", "value", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/induction/annotations.py#L40-L53
train
29,686
pybel/pybel
src/pybel/struct/filters/edge_filters.py
invert_edge_predicate
def invert_edge_predicate(edge_predicate: EdgePredicate) -> EdgePredicate: # noqa: D202 """Build an edge predicate that is the inverse of the given edge predicate.""" def _inverse_filter(graph, u, v, k): return not edge_predicate(graph, u, v, k) return _inverse_filter
python
def invert_edge_predicate(edge_predicate: EdgePredicate) -> EdgePredicate: # noqa: D202 """Build an edge predicate that is the inverse of the given edge predicate.""" def _inverse_filter(graph, u, v, k): return not edge_predicate(graph, u, v, k) return _inverse_filter
[ "def", "invert_edge_predicate", "(", "edge_predicate", ":", "EdgePredicate", ")", "->", "EdgePredicate", ":", "# noqa: D202", "def", "_inverse_filter", "(", "graph", ",", "u", ",", "v", ",", "k", ")", ":", "return", "not", "edge_predicate", "(", "graph", ",", ...
Build an edge predicate that is the inverse of the given edge predicate.
[ "Build", "an", "edge", "predicate", "that", "is", "the", "inverse", "of", "the", "given", "edge", "predicate", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/edge_filters.py#L28-L34
train
29,687
pybel/pybel
src/pybel/struct/filters/edge_filters.py
and_edge_predicates
def and_edge_predicates(edge_predicates: EdgePredicates) -> EdgePredicate: """Concatenate multiple edge predicates to a new predicate that requires all predicates to be met.""" # If something that isn't a list or tuple is given, assume it's a function and return it if not isinstance(edge_predicates, Iterabl...
python
def and_edge_predicates(edge_predicates: EdgePredicates) -> EdgePredicate: """Concatenate multiple edge predicates to a new predicate that requires all predicates to be met.""" # If something that isn't a list or tuple is given, assume it's a function and return it if not isinstance(edge_predicates, Iterabl...
[ "def", "and_edge_predicates", "(", "edge_predicates", ":", "EdgePredicates", ")", "->", "EdgePredicate", ":", "# If something that isn't a list or tuple is given, assume it's a function and return it", "if", "not", "isinstance", "(", "edge_predicates", ",", "Iterable", ")", ":"...
Concatenate multiple edge predicates to a new predicate that requires all predicates to be met.
[ "Concatenate", "multiple", "edge", "predicates", "to", "a", "new", "predicate", "that", "requires", "all", "predicates", "to", "be", "met", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/edge_filters.py#L37-L59
train
29,688
pybel/pybel
src/pybel/struct/filters/edge_filters.py
filter_edges
def filter_edges(graph: BELGraph, edge_predicates: EdgePredicates) -> EdgeIterator: """Apply a set of filters to the edges iterator of a BEL graph. :return: An iterable of edges that pass all predicates """ compound_edge_predicate = and_edge_predicates(edge_predicates=edge_predicates) for u, v, k i...
python
def filter_edges(graph: BELGraph, edge_predicates: EdgePredicates) -> EdgeIterator: """Apply a set of filters to the edges iterator of a BEL graph. :return: An iterable of edges that pass all predicates """ compound_edge_predicate = and_edge_predicates(edge_predicates=edge_predicates) for u, v, k i...
[ "def", "filter_edges", "(", "graph", ":", "BELGraph", ",", "edge_predicates", ":", "EdgePredicates", ")", "->", "EdgeIterator", ":", "compound_edge_predicate", "=", "and_edge_predicates", "(", "edge_predicates", "=", "edge_predicates", ")", "for", "u", ",", "v", "...
Apply a set of filters to the edges iterator of a BEL graph. :return: An iterable of edges that pass all predicates
[ "Apply", "a", "set", "of", "filters", "to", "the", "edges", "iterator", "of", "a", "BEL", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/edge_filters.py#L62-L70
train
29,689
pybel/pybel
src/pybel/struct/filters/edge_filters.py
count_passed_edge_filter
def count_passed_edge_filter(graph: BELGraph, edge_predicates: EdgePredicates) -> int: """Return the number of edges passing a given set of predicates.""" return sum( 1 for _ in filter_edges(graph, edge_predicates=edge_predicates) )
python
def count_passed_edge_filter(graph: BELGraph, edge_predicates: EdgePredicates) -> int: """Return the number of edges passing a given set of predicates.""" return sum( 1 for _ in filter_edges(graph, edge_predicates=edge_predicates) )
[ "def", "count_passed_edge_filter", "(", "graph", ":", "BELGraph", ",", "edge_predicates", ":", "EdgePredicates", ")", "->", "int", ":", "return", "sum", "(", "1", "for", "_", "in", "filter_edges", "(", "graph", ",", "edge_predicates", "=", "edge_predicates", "...
Return the number of edges passing a given set of predicates.
[ "Return", "the", "number", "of", "edges", "passing", "a", "given", "set", "of", "predicates", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/filters/edge_filters.py#L73-L78
train
29,690
pybel/pybel
src/pybel/struct/operations.py
subgraph
def subgraph(graph, nodes: Iterable[BaseEntity]): """Induce a sub-graph over the given nodes. :rtype: BELGraph """ sg = graph.subgraph(nodes) # see implementation for .copy() result = graph.fresh_copy() result.graph.update(sg.graph) for node, data in sg.nodes(data=True): resul...
python
def subgraph(graph, nodes: Iterable[BaseEntity]): """Induce a sub-graph over the given nodes. :rtype: BELGraph """ sg = graph.subgraph(nodes) # see implementation for .copy() result = graph.fresh_copy() result.graph.update(sg.graph) for node, data in sg.nodes(data=True): resul...
[ "def", "subgraph", "(", "graph", ",", "nodes", ":", "Iterable", "[", "BaseEntity", "]", ")", ":", "sg", "=", "graph", ".", "subgraph", "(", "nodes", ")", "# see implementation for .copy()", "result", "=", "graph", ".", "fresh_copy", "(", ")", "result", "."...
Induce a sub-graph over the given nodes. :rtype: BELGraph
[ "Induce", "a", "sub", "-", "graph", "over", "the", "given", "nodes", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L23-L42
train
29,691
pybel/pybel
src/pybel/struct/operations.py
left_full_join
def left_full_join(g, h) -> None: """Add all nodes and edges from ``h`` to ``g``, in-place for ``g``. :param pybel.BELGraph g: A BEL graph :param pybel.BELGraph h: A BEL graph Example usage: >>> import pybel >>> g = pybel.from_path('...') >>> h = pybel.from_path('...') >>> left_full_j...
python
def left_full_join(g, h) -> None: """Add all nodes and edges from ``h`` to ``g``, in-place for ``g``. :param pybel.BELGraph g: A BEL graph :param pybel.BELGraph h: A BEL graph Example usage: >>> import pybel >>> g = pybel.from_path('...') >>> h = pybel.from_path('...') >>> left_full_j...
[ "def", "left_full_join", "(", "g", ",", "h", ")", "->", "None", ":", "g", ".", "add_nodes_from", "(", "(", "node", ",", "data", ")", "for", "node", ",", "data", "in", "h", ".", "nodes", "(", "data", "=", "True", ")", "if", "node", "not", "in", ...
Add all nodes and edges from ``h`` to ``g``, in-place for ``g``. :param pybel.BELGraph g: A BEL graph :param pybel.BELGraph h: A BEL graph Example usage: >>> import pybel >>> g = pybel.from_path('...') >>> h = pybel.from_path('...') >>> left_full_join(g, h)
[ "Add", "all", "nodes", "and", "edges", "from", "h", "to", "g", "in", "-", "place", "for", "g", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L45-L71
train
29,692
pybel/pybel
src/pybel/struct/operations.py
left_outer_join
def left_outer_join(g, h) -> None: """Only add components from the ``h`` that are touching ``g``. Algorithm: 1. Identify all weakly connected components in ``h`` 2. Add those that have an intersection with the ``g`` :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph Example us...
python
def left_outer_join(g, h) -> None: """Only add components from the ``h`` that are touching ``g``. Algorithm: 1. Identify all weakly connected components in ``h`` 2. Add those that have an intersection with the ``g`` :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph Example us...
[ "def", "left_outer_join", "(", "g", ",", "h", ")", "->", "None", ":", "g_nodes", "=", "set", "(", "g", ")", "for", "comp", "in", "nx", ".", "weakly_connected_components", "(", "h", ")", ":", "if", "g_nodes", ".", "intersection", "(", "comp", ")", ":"...
Only add components from the ``h`` that are touching ``g``. Algorithm: 1. Identify all weakly connected components in ``h`` 2. Add those that have an intersection with the ``g`` :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph Example usage: >>> import pybel >>> g = pyb...
[ "Only", "add", "components", "from", "the", "h", "that", "are", "touching", "g", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L74-L96
train
29,693
pybel/pybel
src/pybel/struct/operations.py
union
def union(graphs, use_tqdm: bool = False): """Take the union over a collection of graphs into a new graph. Assumes iterator is longer than 2, but not infinite. :param iter[BELGraph] graphs: An iterator over BEL graphs. Can't be infinite. :param use_tqdm: Should a progress bar be displayed? :return...
python
def union(graphs, use_tqdm: bool = False): """Take the union over a collection of graphs into a new graph. Assumes iterator is longer than 2, but not infinite. :param iter[BELGraph] graphs: An iterator over BEL graphs. Can't be infinite. :param use_tqdm: Should a progress bar be displayed? :return...
[ "def", "union", "(", "graphs", ",", "use_tqdm", ":", "bool", "=", "False", ")", ":", "it", "=", "iter", "(", "graphs", ")", "if", "use_tqdm", ":", "it", "=", "tqdm", "(", "it", ",", "desc", "=", "'taking union'", ")", "try", ":", "target", "=", "...
Take the union over a collection of graphs into a new graph. Assumes iterator is longer than 2, but not infinite. :param iter[BELGraph] graphs: An iterator over BEL graphs. Can't be infinite. :param use_tqdm: Should a progress bar be displayed? :return: A merged graph :rtype: BELGraph Example...
[ "Take", "the", "union", "over", "a", "collection", "of", "graphs", "into", "a", "new", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L113-L152
train
29,694
pybel/pybel
src/pybel/struct/operations.py
left_node_intersection_join
def left_node_intersection_join(g, h): """Take the intersection over two graphs. This intersection of two graphs is defined by the union of the sub-graphs induced over the intersection of their nodes :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph :rtype: BELGraph Example usage:...
python
def left_node_intersection_join(g, h): """Take the intersection over two graphs. This intersection of two graphs is defined by the union of the sub-graphs induced over the intersection of their nodes :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph :rtype: BELGraph Example usage:...
[ "def", "left_node_intersection_join", "(", "g", ",", "h", ")", ":", "intersecting", "=", "set", "(", "g", ")", ".", "intersection", "(", "set", "(", "h", ")", ")", "g_inter", "=", "subgraph", "(", "g", ",", "intersecting", ")", "h_inter", "=", "subgrap...
Take the intersection over two graphs. This intersection of two graphs is defined by the union of the sub-graphs induced over the intersection of their nodes :param BELGraph g: A BEL graph :param BELGraph h: A BEL graph :rtype: BELGraph Example usage: >>> import pybel >>> g = pybel.from_...
[ "Take", "the", "intersection", "over", "two", "graphs", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L155-L178
train
29,695
pybel/pybel
src/pybel/struct/operations.py
node_intersection
def node_intersection(graphs): """Take the node intersection over a collection of graphs into a new graph. This intersection is defined the same way as by :func:`left_node_intersection_join` :param iter[BELGraph] graphs: An iterable of graphs. Since it's iterated over twice, it gets converted to a tu...
python
def node_intersection(graphs): """Take the node intersection over a collection of graphs into a new graph. This intersection is defined the same way as by :func:`left_node_intersection_join` :param iter[BELGraph] graphs: An iterable of graphs. Since it's iterated over twice, it gets converted to a tu...
[ "def", "node_intersection", "(", "graphs", ")", ":", "graphs", "=", "tuple", "(", "graphs", ")", "n_graphs", "=", "len", "(", "graphs", ")", "if", "n_graphs", "==", "0", ":", "raise", "ValueError", "(", "'no graphs given'", ")", "if", "n_graphs", "==", "...
Take the node intersection over a collection of graphs into a new graph. This intersection is defined the same way as by :func:`left_node_intersection_join` :param iter[BELGraph] graphs: An iterable of graphs. Since it's iterated over twice, it gets converted to a tuple first, so this isn't a safe operat...
[ "Take", "the", "node", "intersection", "over", "a", "collection", "of", "graphs", "into", "a", "new", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/operations.py#L181-L216
train
29,696
pybel/pybel
src/pybel/struct/mutation/metadata.py
strip_annotations
def strip_annotations(graph): """Strip all the annotations from a BEL graph. :param pybel.BELGraph graph: A BEL graph """ for u, v, k in graph.edges(keys=True): if ANNOTATIONS in graph[u][v][k]: del graph[u][v][k][ANNOTATIONS]
python
def strip_annotations(graph): """Strip all the annotations from a BEL graph. :param pybel.BELGraph graph: A BEL graph """ for u, v, k in graph.edges(keys=True): if ANNOTATIONS in graph[u][v][k]: del graph[u][v][k][ANNOTATIONS]
[ "def", "strip_annotations", "(", "graph", ")", ":", "for", "u", ",", "v", ",", "k", "in", "graph", ".", "edges", "(", "keys", "=", "True", ")", ":", "if", "ANNOTATIONS", "in", "graph", "[", "u", "]", "[", "v", "]", "[", "k", "]", ":", "del", ...
Strip all the annotations from a BEL graph. :param pybel.BELGraph graph: A BEL graph
[ "Strip", "all", "the", "annotations", "from", "a", "BEL", "graph", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/metadata.py#L21-L28
train
29,697
pybel/pybel
src/pybel/struct/mutation/metadata.py
remove_citation_metadata
def remove_citation_metadata(graph): """Remove the metadata associated with a citation. Best practice is to add this information programmatically. """ for u, v, k in graph.edges(keys=True): if CITATION not in graph[u][v][k]: continue for key in list(graph[u][v][k][CITATION])...
python
def remove_citation_metadata(graph): """Remove the metadata associated with a citation. Best practice is to add this information programmatically. """ for u, v, k in graph.edges(keys=True): if CITATION not in graph[u][v][k]: continue for key in list(graph[u][v][k][CITATION])...
[ "def", "remove_citation_metadata", "(", "graph", ")", ":", "for", "u", ",", "v", ",", "k", "in", "graph", ".", "edges", "(", "keys", "=", "True", ")", ":", "if", "CITATION", "not", "in", "graph", "[", "u", "]", "[", "v", "]", "[", "k", "]", ":"...
Remove the metadata associated with a citation. Best practice is to add this information programmatically.
[ "Remove", "the", "metadata", "associated", "with", "a", "citation", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/metadata.py#L81-L91
train
29,698
pybel/pybel
src/pybel/io/nodelink.py
to_json
def to_json(graph: BELGraph) -> Mapping[str, Any]: """Convert this graph to a Node-Link JSON object.""" graph_json_dict = node_link_data(graph) # Convert annotation list definitions (which are sets) to canonicalized/sorted lists graph_json_dict['graph'][GRAPH_ANNOTATION_LIST] = { keyword: list(...
python
def to_json(graph: BELGraph) -> Mapping[str, Any]: """Convert this graph to a Node-Link JSON object.""" graph_json_dict = node_link_data(graph) # Convert annotation list definitions (which are sets) to canonicalized/sorted lists graph_json_dict['graph'][GRAPH_ANNOTATION_LIST] = { keyword: list(...
[ "def", "to_json", "(", "graph", ":", "BELGraph", ")", "->", "Mapping", "[", "str", ",", "Any", "]", ":", "graph_json_dict", "=", "node_link_data", "(", "graph", ")", "# Convert annotation list definitions (which are sets) to canonicalized/sorted lists", "graph_json_dict",...
Convert this graph to a Node-Link JSON object.
[ "Convert", "this", "graph", "to", "a", "Node", "-", "Link", "JSON", "object", "." ]
c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/io/nodelink.py#L29-L44
train
29,699