_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q246100
has_causal_out_edges
train
def has_causal_out_edges(graph: BELGraph, node: BaseEntity) -> bool: """Return true if the node contains any out_edges that are causal.""" return any(
python
{ "resource": "" }
q246101
node_exclusion_predicate_builder
train
def node_exclusion_predicate_builder(nodes: Iterable[BaseEntity]) -> NodePredicate: """Build a node predicate that returns false for the given nodes.""" nodes = set(nodes) @node_predicate def node_exclusion_predicate(node: BaseEntity) -> bool:
python
{ "resource": "" }
q246102
node_inclusion_predicate_builder
train
def node_inclusion_predicate_builder(nodes: Iterable[BaseEntity]) -> NodePredicate: """Build a function that returns true for the given nodes.""" nodes = set(nodes) @node_predicate def node_inclusion_predicate(node: BaseEntity) -> bool:
python
{ "resource": "" }
q246103
is_causal_source
train
def is_causal_source(graph: BELGraph, node: BaseEntity) -> bool: """Return true of the node is a causal source. - Doesn't have any causal in edge(s) - Does have causal out edge(s)
python
{ "resource": "" }
q246104
is_causal_sink
train
def is_causal_sink(graph: BELGraph, node: BaseEntity) -> bool: """Return true if the node is a causal sink. - Does have causal in edge(s) - Doesn't have any
python
{ "resource": "" }
q246105
is_causal_central
train
def is_causal_central(graph: BELGraph, node: BaseEntity) -> bool: """Return true if the node is neither a causal sink nor a causal source. - Does have causal in edges(s)
python
{ "resource": "" }
q246106
is_isolated_list_abundance
train
def is_isolated_list_abundance(graph: BELGraph, node: BaseEntity, cls: Type[ListAbundance] = ListAbundance) -> bool: """Return if the node is a list abundance but has no qualified edges.""" return ( isinstance(node, cls) and 0 == graph.in_degree(node) and
python
{ "resource": "" }
q246107
collapse_pair
train
def collapse_pair(graph, survivor: BaseEntity, victim: BaseEntity) -> None: """Rewire all edges from the synonymous node to the survivor node, then deletes the synonymous node. Does not keep edges between the two nodes. :param pybel.BELGraph graph: A BEL graph :param survivor: The BEL node to collapse...
python
{ "resource": "" }
q246108
collapse_nodes
train
def collapse_nodes(graph, survivor_mapping: Mapping[BaseEntity, Set[BaseEntity]]) -> None: """Collapse all nodes in values to the key nodes, in place. :param pybel.BELGraph graph: A BEL graph :param survivor_mapping: A dictionary with survivors as their keys, and iterables of the corresponding victims as ...
python
{ "resource": "" }
q246109
surviors_are_inconsistent
train
def surviors_are_inconsistent(survivor_mapping: Mapping[BaseEntity, Set[BaseEntity]]) -> Set[BaseEntity]: """Check that there's no transitive shit
python
{ "resource": "" }
q246110
collapse_all_variants
train
def collapse_all_variants(graph) -> None: """Collapse all genes', RNAs', miRNAs', and proteins' variants to their parents. :param pybel.BELGraph graph: A BEL Graph """ has_variant_predicate = build_relation_predicate(HAS_VARIANT)
python
{ "resource": "" }
q246111
update_metadata
train
def update_metadata(source, target) -> None: """Update the namespace and annotation metadata in the target graph. :param pybel.BELGraph source: :param pybel.BELGraph target: """ target.namespace_url.update(source.namespace_url) target.namespace_pattern.update(source.namespace_pattern) targ...
python
{ "resource": "" }
q246112
update_node_helper
train
def update_node_helper(source: nx.Graph, target: nx.Graph) -> None: """Update the nodes' data dictionaries in the target graph from the source graph. :param source: The universe of all knowledge :param
python
{ "resource": "" }
q246113
get_syntax_errors
train
def get_syntax_errors(graph: BELGraph) -> List[WarningTuple]: """List the syntax errors encountered during compilation of a BEL script.""" return [
python
{ "resource": "" }
q246114
count_error_types
train
def count_error_types(graph: BELGraph) -> Counter: """Count the occurrence of each type of error in a graph. :return: A Counter of {error type: frequency} """
python
{ "resource": "" }
q246115
_naked_names_iter
train
def _naked_names_iter(graph: BELGraph) -> Iterable[str]: """Iterate over naked name warnings from a graph.""" for _, exc, _ in graph.warnings:
python
{ "resource": "" }
q246116
calculate_incorrect_name_dict
train
def calculate_incorrect_name_dict(graph: BELGraph) -> Mapping[str, List[str]]: """Get missing names grouped by namespace."""
python
{ "resource": "" }
q246117
calculate_error_by_annotation
train
def calculate_error_by_annotation(graph: BELGraph, annotation: str) -> Mapping[str, List[str]]: """Group error names by a given annotation.""" results = defaultdict(list) for _, exc, ctx in graph.warnings: if not ctx or not edge_has_annotation(ctx, annotation): continue values ...
python
{ "resource": "" }
q246118
get_subgraph_by_edge_filter
train
def get_subgraph_by_edge_filter(graph, edge_predicates: Optional[EdgePredicates] = None): """Induce a sub-graph on all edges that pass the given filters. :param pybel.BELGraph graph: A BEL graph :param edge_predicates: An edge predicate or list of edge predicates
python
{ "resource": "" }
q246119
get_subgraph_by_induction
train
def get_subgraph_by_induction(graph, nodes: Iterable[BaseEntity]): """Induce a sub-graph over the given nodes or return None if none of the nodes are in the given graph. :param pybel.BELGraph graph: A BEL graph :param nodes: A list of BEL
python
{ "resource": "" }
q246120
get_multi_causal_upstream
train
def get_multi_causal_upstream(graph, nbunch: Union[BaseEntity, Iterable[BaseEntity]]): """Get the union of all the 2-level deep causal upstream subgraphs from the nbunch. :param pybel.BELGraph graph: A
python
{ "resource": "" }
q246121
get_multi_causal_downstream
train
def get_multi_causal_downstream(graph, nbunch: Union[BaseEntity, Iterable[BaseEntity]]): """Get the union of all of the 2-level deep causal downstream subgraphs from the nbunch. :param pybel.BELGraph graph:
python
{ "resource": "" }
q246122
get_subgraph_by_second_neighbors
train
def get_subgraph_by_second_neighbors(graph, nodes: Iterable[BaseEntity], filter_pathologies: bool = False): """Get a graph around the neighborhoods of the given nodes and expand to the neighborhood of those nodes. Returns none if none of the nodes are in the graph. :param pybel.BELGraph graph: A BEL graph...
python
{ "resource": "" }
q246123
_normalize_url
train
def _normalize_url(graph: BELGraph, keyword: str) -> Optional[str]: # FIXME move to utilities and unit test """Normalize a URL for the
python
{ "resource": "" }
q246124
NamespaceManager.drop_namespaces
train
def drop_namespaces(self): """Drop all namespaces.""" self.session.query(NamespaceEntry).delete()
python
{ "resource": "" }
q246125
NamespaceManager.drop_namespace_by_url
train
def drop_namespace_by_url(self, url: str) -> None: """Drop the namespace at the given URL. Won't work if the edge store is in use. :param url: The URL of
python
{ "resource": "" }
q246126
NamespaceManager.get_namespace_by_url
train
def get_namespace_by_url(self, url: str) -> Optional[Namespace]: """Look up a namespace by url."""
python
{ "resource": "" }
q246127
NamespaceManager.get_namespace_by_keyword_version
train
def get_namespace_by_keyword_version(self, keyword: str, version: str) -> Optional[Namespace]: """Get a namespace with a given keyword and version.""" filt = and_(Namespace.keyword == keyword,
python
{ "resource": "" }
q246128
NamespaceManager.ensure_default_namespace
train
def ensure_default_namespace(self) -> Namespace: """Get or create the BEL default namespace.""" namespace = self.get_namespace_by_keyword_version(BEL_DEFAULT_NAMESPACE, BEL_DEFAULT_NAMESPACE_VERSION) if namespace is None: namespace = Namespace( name='BEL Default Name...
python
{ "resource": "" }
q246129
NamespaceManager.get_namespace_by_keyword_pattern
train
def get_namespace_by_keyword_pattern(self, keyword: str, pattern: str) -> Optional[Namespace]: """Get a namespace with a given keyword and pattern.""" filt = and_(Namespace.keyword == keyword,
python
{ "resource": "" }
q246130
NamespaceManager.ensure_regex_namespace
train
def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace: """Get or create a regular expression namespace. :param keyword: The keyword of a regular expression namespace :param pattern: The pattern for a regular expression namespace """ if pattern is None: ...
python
{ "resource": "" }
q246131
NamespaceManager.get_namespace_entry
train
def get_namespace_entry(self, url: str, name: str) -> Optional[NamespaceEntry]: """Get a given NamespaceEntry object. :param url: The url of the namespace source :param name: The value of the namespace from the given url's document """ entry_filter = and_(Namespace.url == url, N...
python
{ "resource": "" }
q246132
NamespaceManager.get_or_create_regex_namespace_entry
train
def get_or_create_regex_namespace_entry(self, namespace: str, pattern: str, name: str) -> NamespaceEntry: """Get a namespace entry from a regular expression. Need to commit after! :param namespace: The name of the namespace :param pattern: The regular expression pattern for the namespa...
python
{ "resource": "" }
q246133
NamespaceManager.list_annotations
train
def list_annotations(self) -> List[Namespace]: """List all annotations."""
python
{ "resource": "" }
q246134
NamespaceManager.count_annotations
train
def count_annotations(self) -> int: """Count the number of annotations in the database."""
python
{ "resource": "" }
q246135
NamespaceManager.count_annotation_entries
train
def count_annotation_entries(self) -> int: """Count the number of annotation entries in the database."""
python
{ "resource": "" }
q246136
NamespaceManager.get_annotation_entry_names
train
def get_annotation_entry_names(self, url: str) -> Set[str]: """Return a dict of annotations and their labels for the given annotation file. :param url: the location of the annotation file """ annotation = self.get_or_create_annotation(url) return {
python
{ "resource": "" }
q246137
NamespaceManager.get_annotation_entries_by_names
train
def get_annotation_entries_by_names(self, url: str, names: Iterable[str]) -> List[NamespaceEntry]: """Get annotation entries by URL and names. :param url: The url of the annotation source :param names: The names of the annotation entries from the given url's document """
python
{ "resource": "" }
q246138
NetworkManager.drop_networks
train
def drop_networks(self) -> None: """Drop all networks.""" for
python
{ "resource": "" }
q246139
NetworkManager.drop_network_by_id
train
def drop_network_by_id(self, network_id: int) -> None: """Drop a network by its database identifier."""
python
{ "resource": "" }
q246140
NetworkManager.drop_network
train
def drop_network(self, network: Network) -> None: """Drop a network, while also cleaning up any edges that are no longer part of any network.""" # get the IDs of the edges that will be orphaned by deleting this network # FIXME: this list could be a problem if it becomes very large; possible opti...
python
{ "resource": "" }
q246141
NetworkManager.query_singleton_edges_from_network
train
def query_singleton_edges_from_network(self, network: Network) -> sqlalchemy.orm.query.Query: """Return a query selecting all edge ids that only belong to the given network.""" ne1 = aliased(network_edge, name='ne1') ne2 = aliased(network_edge, name='ne2') singleton_edge_ids_for_network ...
python
{ "resource": "" }
q246142
NetworkManager.get_network_versions
train
def get_network_versions(self, name: str) -> Set[str]: """Return all of the versions of a network with the given name.""" return { version
python
{ "resource": "" }
q246143
NetworkManager.get_network_by_name_version
train
def get_network_by_name_version(self, name: str, version: str) -> Optional[Network]: """Load the network with the given name and version if it exists.""" name_version_filter = and_(Network.name == name, Network.version ==
python
{ "resource": "" }
q246144
NetworkManager.get_graph_by_name_version
train
def get_graph_by_name_version(self, name: str, version: str) -> Optional[BELGraph]: """Load the BEL graph with the given name, or
python
{ "resource": "" }
q246145
NetworkManager.get_networks_by_name
train
def get_networks_by_name(self, name: str) -> List[Network]: """Get all networks with the given name.
python
{ "resource": "" }
q246146
NetworkManager.get_most_recent_network_by_name
train
def get_most_recent_network_by_name(self, name: str) -> Optional[Network]: """Get the most recently created
python
{ "resource": "" }
q246147
NetworkManager.get_network_by_id
train
def get_network_by_id(self, network_id: int) -> Network: """Get a network from the database by its identifier."""
python
{ "resource": "" }
q246148
NetworkManager.get_graph_by_id
train
def get_graph_by_id(self, network_id: int) -> BELGraph: """Get a network from the database by its identifier and converts it to a BEL graph.""" network = self.get_network_by_id(network_id)
python
{ "resource": "" }
q246149
NetworkManager.get_networks_by_ids
train
def get_networks_by_ids(self, network_ids: Iterable[int]) -> List[Network]: """Get a list of networks with the given identifiers.
python
{ "resource": "" }
q246150
NetworkManager.get_graphs_by_ids
train
def get_graphs_by_ids(self, network_ids: Iterable[int]) -> List[BELGraph]: """Get a list of networks with the given identifiers and converts to BEL graphs.""" rv = [ self.get_graph_by_id(network_id)
python
{ "resource": "" }
q246151
NetworkManager.get_graph_by_ids
train
def get_graph_by_ids(self, network_ids: List[int]) -> BELGraph: """Get a combine BEL Graph from a list of network identifiers.""" if len(network_ids) == 1: return self.get_graph_by_id(network_ids[0]) log.debug('getting graph by identifiers: %s', network_ids)
python
{ "resource": "" }
q246152
InsertManager.insert_graph
train
def insert_graph(self, graph: BELGraph, store_parts: bool = True, use_tqdm: bool = False) -> Network: """Insert a graph in the database and returns the corresponding Network model. :raises: pybel.resources.exc.ResourceError """ if not graph.name: raise ValueError('Can not up...
python
{ "resource": "" }
q246153
InsertManager._store_graph_parts
train
def _store_graph_parts(self, graph: BELGraph, use_tqdm: bool = False) -> Tuple[List[Node], List[Edge]]: """Store the given graph into the edge store. :raises: pybel.resources.exc.ResourceError :raises: EdgeAddError """ log.debug('inserting %s into edge store', graph) log...
python
{ "resource": "" }
q246154
InsertManager._get_annotation_entries_from_data
train
def _get_annotation_entries_from_data(self, graph: BELGraph, data: EdgeData) -> Optional[List[NamespaceEntry]]: """Get the annotation entries from an edge data dictionary.""" annotations_dict = data.get(ANNOTATIONS)
python
{ "resource": "" }
q246155
InsertManager._add_qualified_edge
train
def _add_qualified_edge(self, graph: BELGraph, source: Node, target: Node, key: str, bel: str, data: EdgeData): """Add a qualified edge to the network.""" citation_dict = data[CITATION] citation = self.get_or_create_citation( type=citation_dict.get(CITATION_TYPE), refere...
python
{ "resource": "" }
q246156
InsertManager._add_unqualified_edge
train
def _add_unqualified_edge(self, source: Node, target: Node, key: str, bel: str, data: EdgeData) -> Edge: """Add an unqualified edge to the network.""" return self.get_or_create_edge( source=source,
python
{ "resource": "" }
q246157
InsertManager.get_or_create_evidence
train
def get_or_create_evidence(self, citation: Citation, text: str) -> Evidence: """Create an entry and object for given evidence if it does not exist.""" sha512 = hash_evidence(text=text, type=str(citation.type), reference=str(citation.reference)) if sha512 in self.object_cache_evidence: ...
python
{ "resource": "" }
q246158
InsertManager.get_or_create_node
train
def get_or_create_node(self, graph: BELGraph, node: BaseEntity) -> Optional[Node]: """Create an entry and object for given node if it does not exist.""" sha512 = node.as_sha512() if sha512 in self.object_cache_node: return self.object_cache_node[sha512] node_model = self.get...
python
{ "resource": "" }
q246159
InsertManager.drop_nodes
train
def drop_nodes(self) -> None: """Drop all nodes in the database.""" t = time.time() self.session.query(Node).delete()
python
{ "resource": "" }
q246160
InsertManager.drop_edges
train
def drop_edges(self) -> None: """Drop all edges in the database.""" t = time.time() self.session.query(Edge).delete()
python
{ "resource": "" }
q246161
InsertManager.get_or_create_edge
train
def get_or_create_edge(self, source: Node, target: Node, relation: str, bel: str, sha512: str, data: EdgeData, evidence: Optional[E...
python
{ "resource": "" }
q246162
InsertManager.get_or_create_citation
train
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
{ "resource": "" }
q246163
InsertManager.get_or_create_author
train
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
{ "resource": "" }
q246164
InsertManager.get_modification_by_hash
train
def get_modification_by_hash(self, sha512: str) -> Optional[Modification]: """Get a modification by a SHA512 hash."""
python
{ "resource": "" }
q246165
InsertManager.get_property_by_hash
train
def get_property_by_hash(self, property_hash: str) -> Optional[Property]: """Get a property
python
{ "resource": "" }
q246166
InsertManager._make_property_from_dict
train
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
{ "resource": "" }
q246167
_clean_annotations
train
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}
python
{ "resource": "" }
q246168
BELGraph.defined_namespace_keywords
train
def defined_namespace_keywords(self) -> Set[str]: # noqa: D401 """The set of
python
{ "resource": "" }
q246169
BELGraph.defined_annotation_keywords
train
def defined_annotation_keywords(self) -> Set[str]: """Get the set of all keywords defined as annotations in this graph.""" return (
python
{ "resource": "" }
q246170
BELGraph.skip_storing_namespace
train
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 (
python
{ "resource": "" }
q246171
BELGraph.add_warning
train
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
{ "resource": "" }
q246172
BELGraph._help_add_edge
train
def _help_add_edge(self, u: BaseEntity, v: BaseEntity, attr: Mapping) -> str: """Help add a pre-built edge.""" self.add_node_from_data(u)
python
{ "resource": "" }
q246173
BELGraph.add_unqualified_edge
train
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`
python
{ "resource": "" }
q246174
BELGraph.add_transcription
train
def add_transcription(self, gene: Gene, rna: Union[Rna, MicroRna]) -> str: """Add a transcription relation from a gene to an
python
{ "resource": "" }
q246175
BELGraph.add_translation
train
def add_translation(self, rna: Rna, protein: Protein) -> str: """Add a translation relation from a RNA to a protein. :param rna: An RNA node
python
{ "resource": "" }
q246176
BELGraph._add_two_way_unqualified_edge
train
def _add_two_way_unqualified_edge(self, u: BaseEntity, v: BaseEntity, relation: str) -> str:
python
{ "resource": "" }
q246177
BELGraph.add_qualified_edge
train
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
{ "resource": "" }
q246178
BELGraph.add_node_from_data
train
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
{ "resource": "" }
q246179
BELGraph.has_edge_citation
train
def has_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> bool:
python
{ "resource": "" }
q246180
BELGraph.has_edge_evidence
train
def has_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> bool:
python
{ "resource": "" }
q246181
BELGraph.get_edge_citation
train
def get_edge_citation(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[CitationDict]: """Get
python
{ "resource": "" }
q246182
BELGraph.get_edge_evidence
train
def get_edge_evidence(self, u: BaseEntity, v: BaseEntity, key: str) -> Optional[str]: """Get
python
{ "resource": "" }
q246183
BELGraph.get_edge_annotations
train
def get_edge_annotations(self, u, v, key: str) -> Optional[AnnotationsDict]:
python
{ "resource": "" }
q246184
BELGraph.get_node_description
train
def get_node_description(self, node: BaseEntity) -> Optional[str]:
python
{ "resource": "" }
q246185
BELGraph.set_node_description
train
def set_node_description(self, node: BaseEntity, description: str) -> None: """Set the description for a given node."""
python
{ "resource": "" }
q246186
BELGraph.edge_to_bel
train
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
python
{ "resource": "" }
q246187
BELGraph._equivalent_node_iterator_helper
train
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:
python
{ "resource": "" }
q246188
BELGraph.iter_equivalent_nodes
train
def iter_equivalent_nodes(self, node: BaseEntity) -> Iterable[BaseEntity]: """Iterate over nodes that are equivalent to the given node, including the original."""
python
{ "resource": "" }
q246189
BELGraph.get_equivalent_nodes
train
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):
python
{ "resource": "" }
q246190
BELGraph._node_has_namespace_helper
train
def _node_has_namespace_helper(node: BaseEntity, namespace: str) -> bool: """Check that the
python
{ "resource": "" }
q246191
BELGraph.node_has_namespace
train
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(
python
{ "resource": "" }
q246192
BELGraph._describe_list
train
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
{ "resource": "" }
q246193
BELGraph.summary_str
train
def summary_str(self) -> str: """Return a string that summarizes the graph.""" return '{}\n'.format(self)
python
{ "resource": "" }
q246194
BELGraph.summarize
train
def summarize(self, file: Optional[TextIO] = None) -> None: """Print
python
{ "resource": "" }
q246195
BELGraph.serialize
train
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
{ "resource": "" }
q246196
remove_isolated_nodes
train
def remove_isolated_nodes(graph): """Remove isolated nodes from the network, in place. :param pybel.BELGraph graph: A BEL graph """
python
{ "resource": "" }
q246197
remove_isolated_nodes_op
train
def remove_isolated_nodes_op(graph): """Build a new graph excluding the isolated nodes. :param pybel.BELGraph graph: A BEL graph :rtype: pybel.BELGraph """
python
{ "resource": "" }
q246198
expand_by_edge_filter
train
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
{ "resource": "" }
q246199
MetadataParser.handle_document
train
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
{ "resource": "" }