_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q246200
MetadataParser.raise_for_redefined_namespace
train
def raise_for_redefined_namespace(self, line: str, position: int, namespace: str) -> None: """Raise an exception if a namespace is already defined.
python
{ "resource": "" }
q246201
MetadataParser.handle_namespace_url
train
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
{ "resource": "" }
q246202
MetadataParser.handle_namespace_pattern
train
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']
python
{ "resource": "" }
q246203
MetadataParser.raise_for_redefined_annotation
train
def raise_for_redefined_annotation(self, line: str, position: int, annotation: str) -> None: """Raise an exception if the given annotation is already defined.
python
{ "resource": "" }
q246204
MetadataParser.handle_annotations_url
train
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
{ "resource": "" }
q246205
MetadataParser.handle_annotation_pattern
train
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']
python
{ "resource": "" }
q246206
MetadataParser.has_annotation
train
def has_annotation(self, annotation: str) -> bool: """Check if this annotation is defined.""" return ( self.has_enumerated_annotation(annotation) or
python
{ "resource": "" }
q246207
MetadataParser.raise_for_version
train
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
{ "resource": "" }
q246208
chebi
train
def chebi(name=None, identifier=None) -> Abundance: """Build a
python
{ "resource": "" }
q246209
hgnc
train
def hgnc(name=None, identifier=None) -> Protein: """Build an
python
{ "resource": "" }
q246210
build_engine_session
train
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
{ "resource": "" }
q246211
BaseManager.create_all
train
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
python
{ "resource": "" }
q246212
BaseManager.drop_all
train
def drop_all(self, checkfirst: bool = True) -> None: """Drop all data, tables, and databases for the PyBEL cache.
python
{ "resource": "" }
q246213
BaseManager.bind
train
def bind(self) -> None: """Bind the metadata to the engine and session.""" self.base.metadata.bind
python
{ "resource": "" }
q246214
BaseManager._list_model
train
def _list_model(self, model_cls: Type[X]) -> List[X]: """List the models in this class."""
python
{ "resource": "" }
q246215
sanitize_date
train
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
{ "resource": "" }
q246216
clean_pubmed_identifiers
train
def clean_pubmed_identifiers(pmids: Iterable[str]) -> List[str]: """Clean a list of
python
{ "resource": "" }
q246217
get_pubmed_citation_response
train
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
python
{ "resource": "" }
q246218
enrich_citation_model
train
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
{ "resource": "" }
q246219
get_citations_by_pmids
train
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
{ "resource": "" }
q246220
enrich_pubmed_citations
train
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
{ "resource": "" }
q246221
_build_collapse_to_gene_dict
train
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
{ "resource": "" }
q246222
collapse_to_genes
train
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)
python
{ "resource": "" }
q246223
main
train
def main(ctx, connection): """Command line interface
python
{ "resource": "" }
q246224
compile
train
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
{ "resource": "" }
q246225
insert
train
def insert(manager, graph: BELGraph): """Insert a
python
{ "resource": "" }
q246226
post
train
def post(graph: BELGraph, host: str): """Upload a graph to BEL Commons.""" resp =
python
{ "resource": "" }
q246227
serialize
train
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
{ "resource": "" }
q246228
neo
train
def neo(graph: BELGraph, connection: str, password: str): """Upload to neo4j.""" import py2neo
python
{ "resource": "" }
q246229
machine
train
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
{ "resource": "" }
q246230
examples
train
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):
python
{ "resource": "" }
q246231
ls
train
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:
python
{ "resource": "" }
q246232
ls
train
def ls(manager: Manager): """List network names, versions, and optionally, descriptions.""" for n in manager.list_networks():
python
{ "resource": "" }
q246233
drop
train
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)
python
{ "resource": "" }
q246234
ls
train
def ls(manager: Manager, offset: Optional[int], limit: Optional[int]): """List edges.""" q = manager.session.query(Edge) if offset: q = q.offset(offset)
python
{ "resource": "" }
q246235
prune
train
def prune(manager: Manager): """Prune nodes not belonging to any edges.""" nodes_to_delete = [ node
python
{ "resource": "" }
q246236
summarize
train
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
{ "resource": "" }
q246237
echo_warnings_via_pager
train
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
{ "resource": "" }
q246238
parse_result_to_dsl
train
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
{ "resource": "" }
q246239
_fusion_to_dsl
train
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
{ "resource": "" }
q246240
_fusion_range_to_dsl
train
def _fusion_range_to_dsl(tokens) -> FusionRangeBase: """Convert a PyParsing data dictionary into a PyBEL. :type tokens: ParseResult """
python
{ "resource": "" }
q246241
_simple_po_to_dict
train
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
python
{ "resource": "" }
q246242
_variant_to_dsl_helper
train
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
{ "resource": "" }
q246243
_reaction_po_to_dict
train
def _reaction_po_to_dict(tokens) -> Reaction: """Convert a reaction parse object to a DSL. :type tokens: ParseResult """ return Reaction(
python
{ "resource": "" }
q246244
_list_po_to_dict
train
def _list_po_to_dict(tokens) -> ListAbundance: """Convert a list parse object to a node. :type tokens: ParseResult """ func = tokens[FUNCTION] dsl =
python
{ "resource": "" }
q246245
get_subgraph_by_annotations
train
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
{ "resource": "" }
q246246
get_subgraph_by_annotation_value
train
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
{ "resource": "" }
q246247
invert_edge_predicate
train
def invert_edge_predicate(edge_predicate: EdgePredicate) -> EdgePredicate: # noqa: D202 """Build an edge predicate that
python
{ "resource": "" }
q246248
and_edge_predicates
train
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
{ "resource": "" }
q246249
filter_edges
train
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
python
{ "resource": "" }
q246250
count_passed_edge_filter
train
def count_passed_edge_filter(graph: BELGraph, edge_predicates: EdgePredicates) -> int: """Return the number of edges passing a given set of predicates.""" return sum(
python
{ "resource": "" }
q246251
subgraph
train
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 =
python
{ "resource": "" }
q246252
left_full_join
train
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
{ "resource": "" }
q246253
left_outer_join
train
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
{ "resource": "" }
q246254
union
train
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
{ "resource": "" }
q246255
left_node_intersection_join
train
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
{ "resource": "" }
q246256
node_intersection
train
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
{ "resource": "" }
q246257
strip_annotations
train
def strip_annotations(graph): """Strip all the annotations from a BEL graph. :param pybel.BELGraph graph: A BEL graph """ for u, v, k in
python
{ "resource": "" }
q246258
remove_citation_metadata
train
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
python
{ "resource": "" }
q246259
to_json
train
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] = {
python
{ "resource": "" }
q246260
to_json_path
train
def to_json_path(graph: BELGraph, path: str, **kwargs) -> None: """Write this graph to the given path as a Node-Link JSON."""
python
{ "resource": "" }
q246261
to_json_file
train
def to_json_file(graph: BELGraph, file: TextIO, **kwargs) -> None: """Write this graph as Node-Link JSON to a file."""
python
{ "resource": "" }
q246262
to_jsons
train
def to_jsons(graph: BELGraph, **kwargs) -> str: """Dump this graph as a Node-Link JSON object to a string.""" graph_json_str
python
{ "resource": "" }
q246263
from_json
train
def from_json(graph_json_dict: Mapping[str, Any], check_version=True) -> BELGraph: """Build a graph from Node-Link JSON Object."""
python
{ "resource": "" }
q246264
from_json_path
train
def from_json_path(path: str, check_version: bool = True) -> BELGraph: """Build a graph from a file containing Node-Link JSON."""
python
{ "resource": "" }
q246265
from_json_file
train
def from_json_file(file: TextIO, check_version=True) -> BELGraph: """Build a graph from the Node-Link JSON contained in the given file."""
python
{ "resource": "" }
q246266
from_jsons
train
def from_jsons(graph_json_str: str, check_version: bool = True) -> BELGraph: """Read a BEL graph from a Node-Link JSON string."""
python
{ "resource": "" }
q246267
node_link_data
train
def node_link_data(graph: BELGraph) -> Mapping[str, Any]: """Convert a BEL graph to a node-link format. Adapted from :func:`networkx.readwrite.json_graph.node_link_data` """ nodes = sorted(graph, key=methodcaller('as_bel')) mapping = dict(zip(nodes, count())) return { 'directed': True...
python
{ "resource": "" }
q246268
_augment_node
train
def _augment_node(node: BaseEntity) -> BaseEntity: """Add the SHA-512 identifier to a node's dictionary.""" rv = node.copy() rv['id'] = node.as_sha512() rv['bel'] = node.as_bel() for m
python
{ "resource": "" }
q246269
BaseParser.parse_lines
train
def parse_lines(self, lines: Iterable[str]) -> List[ParseResults]: """Parse multiple lines in succession.""" return [
python
{ "resource": "" }
q246270
BaseParser.parseString
train
def parseString(self, line: str, line_number: int = 0) -> ParseResults: # noqa: N802 """Parse a string with the language represented by this parser. :param line: A string representing an instance of this parser's language
python
{ "resource": "" }
q246271
BaseParser.streamline
train
def streamline(self): """Streamline the language represented by this parser to make queries run faster.""" t = time.time()
python
{ "resource": "" }
q246272
iter_children
train
def iter_children(graph, node: BaseEntity) -> Iterable[BaseEntity]: """Iterate over children of the node.""" return ( node
python
{ "resource": "" }
q246273
transfer_causal_edges
train
def transfer_causal_edges(graph, source: BaseEntity, target: BaseEntity) -> Iterable[str]: """Transfer causal edges that the source has to the target and yield the resulting hashes.""" for _, v, data in graph.out_edges(source, data=True): if data[RELATION] not in CAUSAL_RELATIONS: continue ...
python
{ "resource": "" }
q246274
_get_protocol_tuple
train
def _get_protocol_tuple(data: Dict[str, Any]) -> Tuple[str, List, Dict]: """Convert a dictionary to a tuple."""
python
{ "resource": "" }
q246275
Pipeline.from_functions
train
def from_functions(functions) -> 'Pipeline': """Build a pipeline from a list of functions. :param functions: A list of functions or names of functions :type functions: iter[((pybel.BELGraph) -> pybel.BELGraph) or ((pybel.BELGraph) -> None) or str] Example with function: >>> fr...
python
{ "resource": "" }
q246276
Pipeline._get_function
train
def _get_function(self, name: str): """Wrap a function with the universe and in-place. :param name: The name of the function :rtype: types.FunctionType :raises MissingPipelineFunctionError: If the functions is not registered """ f = mapped.get(name)
python
{ "resource": "" }
q246277
Pipeline.extend
train
def extend(self, protocol: Union[Iterable[Dict], 'Pipeline']) -> 'Pipeline': """Add another pipeline to the end of the current pipeline. :param protocol: An iterable of dictionaries (or another Pipeline) :return: This pipeline for fluid query building Example: >>> p1 = Pipelin...
python
{ "resource": "" }
q246278
Pipeline._run_helper
train
def _run_helper(self, graph, protocol: Iterable[Dict]): """Help run the protocol. :param pybel.BELGraph graph: A BEL graph :param protocol: The protocol to run, as JSON :rtype: pybel.BELGraph """ result = graph for entry in protocol: meta_entry = ent...
python
{ "resource": "" }
q246279
Pipeline.run
train
def run(self, graph, universe=None): """Run the contained protocol on a seed graph. :param pybel.BELGraph graph: The seed BEL graph :param pybel.BELGraph universe: Allows just-in-time setting of the universe in case it
python
{ "resource": "" }
q246280
Pipeline._wrap_universe
train
def _wrap_universe(self, func): # noqa: D202 """Take a function that needs a universe graph as the first argument and returns a wrapped one.""" @wraps(func) def wrapper(graph, *args, **kwargs): """Apply the enclosed function with the universe given as the first argument.""" ...
python
{ "resource": "" }
q246281
Pipeline._wrap_in_place
train
def _wrap_in_place(func): # noqa: D202 """Take a function that doesn't return the graph and returns the graph.""" @wraps(func) def wrapper(graph, *args, **kwargs):
python
{ "resource": "" }
q246282
Pipeline.dump
train
def dump(self, file: TextIO, **kwargs) -> None: """Dump this
python
{ "resource": "" }
q246283
Pipeline._build_meta
train
def _build_meta(meta: str, pipelines: Iterable['Pipeline']) -> 'Pipeline': """Build a pipeline with a given meta-argument. :param meta: either union or intersection :param pipelines: """ return Pipeline(protocol=[ { 'meta': meta,
python
{ "resource": "" }
q246284
get_names
train
def get_names(graph): """Get all names for each namespace. :type graph: pybel.BELGraph :rtype: dict[str,set[str]] """ rv = defaultdict(set) for namespace,
python
{ "resource": "" }
q246285
count_variants
train
def count_variants(graph): """Count how many of each type of variant a graph has. :param pybel.BELGraph graph: A BEL graph
python
{ "resource": "" }
q246286
get_top_hubs
train
def get_top_hubs(graph, *, n: Optional[int] = 15) -> List[Tuple[BaseEntity, int]]: """Get the top hubs in the graph by BEL. :param pybel.BELGraph graph: A BEL graph :param n: The
python
{ "resource": "" }
q246287
_pathology_iterator
train
def _pathology_iterator(graph): """Iterate over edges in which either the source or target is a pathology node. :param pybel.BELGraph graph: A BEL graph :rtype: iter """
python
{ "resource": "" }
q246288
get_top_pathologies
train
def get_top_pathologies(graph, n: Optional[int] = 15) -> List[Tuple[BaseEntity, int]]: """Get the top highest relationship-having edges in the graph by BEL. :param pybel.BELGraph graph: A BEL graph
python
{ "resource": "" }
q246289
enrich_proteins_with_rnas
train
def enrich_proteins_with_rnas(graph): """Add the corresponding RNA node for each protein node and connect them with a translation edge. :param pybel.BELGraph graph: A BEL graph """ for protein_node in list(graph): if not isinstance(protein_node, Protein):
python
{ "resource": "" }
q246290
get_upstream_causal_subgraph
train
def get_upstream_causal_subgraph(graph, nbunch: Union[BaseEntity, Iterable[BaseEntity]]): """Induce a sub-graph from all of the upstream causal entities of the nodes in the nbunch. :type graph: pybel.BELGraph
python
{ "resource": "" }
q246291
get_downstream_causal_subgraph
train
def get_downstream_causal_subgraph(graph, nbunch: Union[BaseEntity, Iterable[BaseEntity]]): """Induce a sub-graph from all of the downstream causal entities of the nodes in the nbunch. :type graph: pybel.BELGraph
python
{ "resource": "" }
q246292
cleanup
train
def cleanup(graph, subgraphs): """Clean up the metadata in the subgraphs. :type graph: pybel.BELGraph :type subgraphs: dict[Any,pybel.BELGraph] """
python
{ "resource": "" }
q246293
get_fragment_language
train
def get_fragment_language() -> ParserElement: """Build a protein fragment parser.""" _fragment_value_inner = fragment_range | missing_fragment(FRAGMENT_MISSING)
python
{ "resource": "" }
q246294
get_protein_modification_language
train
def get_protein_modification_language(identifier_qualified: ParserElement) -> ParserElement: """Build a protein modification parser.""" pmod_identifier = MatchFirst([ identifier_qualified, pmod_default_ns, pmod_legacy_ns ]) return pmod_tag + nest(
python
{ "resource": "" }
q246295
upload_cbn_dir
train
def upload_cbn_dir(dir_path, manager): """Uploads CBN data to edge store :param str dir_path: Directory full of CBN JGIF files :param pybel.Manager manager: """ t = time.time() for jfg_path in os.listdir(dir_path): if not jfg_path.endswith('.jgf'): continue path = ...
python
{ "resource": "" }
q246296
_activity_helper
train
def _activity_helper(modifier: str, location=None): """Make an activity dictionary. :param str modifier: :param Optional[dict] location: An entity from :func:`pybel.dsl.entity` :rtype: dict """
python
{ "resource": "" }
q246297
translocation
train
def translocation(from_loc, to_loc): """Make a translocation dictionary. :param dict from_loc: An entity dictionary from :func:`pybel.dsl.entity` :param dict to_loc: An entity dictionary from :func:`pybel.dsl.entity` :rtype: dict """ rv = _activity_helper(TRANSLOCATION) rv[EFFECT] = { ...
python
{ "resource": "" }
q246298
iterate_pubmed_identifiers
train
def iterate_pubmed_identifiers(graph) -> Iterable[str]: """Iterate over all PubMed identifiers in a graph. :param pybel.BELGraph graph: A BEL graph
python
{ "resource": "" }
q246299
remove_filtered_edges
train
def remove_filtered_edges(graph, edge_predicates=None): """Remove edges passing the given edge predicates. :param pybel.BELGraph graph: A BEL graph :param edge_predicates: A predicate or list of predicates :type edge_predicates: None or ((pybel.BELGraph, tuple, tuple, int) -> bool)
python
{ "resource": "" }