INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Does the given complex contain the member? | def complex_has_member(graph: BELGraph, complex_node: ComplexAbundance, member_node: BaseEntity) -> bool:
"""Does the given complex contain the member?"""
return any( # TODO can't you look in the members of the complex object (if it's enumerated)
v == member_node
for _, v, data in graph.out_edg... |
Return if the formation of a complex with u increases the activity of v. | def complex_increases_activity(graph: BELGraph, u: BaseEntity, v: BaseEntity, key: str) -> bool:
"""Return if the formation of a complex with u increases the activity of v."""
return (
isinstance(u, (ComplexAbundance, NamedComplexAbundance)) and
complex_has_member(graph, u, v) and
part_h... |
Find edges that are A - A meaning that some conditions in the edge best describe the interaction. | def find_activations(graph: BELGraph):
"""Find edges that are A - A, meaning that some conditions in the edge best describe the interaction."""
for u, v, key, data in graph.edges(keys=True, data=True):
if u != v:
continue
bel = graph.edge_to_bel(u, v, data)
line = data.get(... |
s - > ( s0 s1 ) ( s1 s2 ) ( s2 s3 )... | def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = itt.tee(iterable)
next(b, None)
return zip(a, b) |
Takes in a path ( a list of nodes in the graph ) and calculates a score | def rank_path(graph, path, edge_ranking=None):
"""Takes in a path (a list of nodes in the graph) and calculates a score
:param pybel.BELGraph graph: A BEL graph
:param list[tuple] path: A list of nodes in the path (includes terminal nodes)
:param dict edge_ranking: A dictionary of {relationship: score}... |
Find the root of the path - > The node with the lowest out degree if multiple: root is the one with the highest out degree among those with lowest out degree: param pybel. BELGraph graph: A BEL Graph: param list [ tuple ] path_nodes: A list of nodes in their order in a path: return: A pair of the graph: graph of the pa... | def find_root_in_path(graph, path_nodes):
"""Find the 'root' of the path -> The node with the lowest out degree, if multiple:
root is the one with the highest out degree among those with lowest out degree
:param pybel.BELGraph graph: A BEL Graph
:param list[tuple] path_nodes: A list of nodes i... |
Print a summary of the number of edges passing a given set of filters. | def summarize_edge_filter(graph: BELGraph, edge_predicates: EdgePredicates) -> None:
"""Print a summary of the number of edges passing a given set of filters."""
passed = count_passed_edge_filter(graph, edge_predicates)
print('{}/{} edges passed {}'.format(
passed, graph.number_of_edges(),
(... |
Build a filter that keeps edges whose data dictionaries are super - dictionaries to the given dictionary. | def build_edge_data_filter(annotations: Mapping, partial_match: bool = True) -> EdgePredicate: # noqa: D202
"""Build a filter that keeps edges whose data dictionaries are super-dictionaries to the given dictionary.
:param annotations: The annotation query dict to match
:param partial_match: Should the quer... |
Fail for edges with citations whose references are one of the given PubMed identifiers. | def build_pmid_exclusion_filter(pmids: Strings) -> EdgePredicate:
"""Fail for edges with citations whose references are one of the given PubMed identifiers.
:param pmids: A PubMed identifier or list of PubMed identifiers to filter against
"""
if isinstance(pmids, str):
@edge_predicate
d... |
Pass for nodes that have the given namespace. | def node_has_namespace(node: BaseEntity, namespace: str) -> bool:
"""Pass for nodes that have the given namespace."""
ns = node.get(NAMESPACE)
return ns is not None and ns == namespace |
Pass for nodes that have one of the given namespaces. | def node_has_namespaces(node: BaseEntity, namespaces: Set[str]) -> bool:
"""Pass for nodes that have one of the given namespaces."""
ns = node.get(NAMESPACE)
return ns is not None and ns in namespaces |
Pass for edges whose source nodes have the given namespace or one of the given namespaces. | def build_source_namespace_filter(namespaces: Strings) -> EdgePredicate:
"""Pass for edges whose source nodes have the given namespace or one of the given namespaces.
:param namespaces: The namespace or namespaces to filter by
"""
if isinstance(namespaces, str):
def source_namespace_filter(_, u... |
Only passes for edges whose target nodes have the given namespace or one of the given namespaces | def build_target_namespace_filter(namespaces: Strings) -> EdgePredicate:
"""Only passes for edges whose target nodes have the given namespace or one of the given namespaces
:param namespaces: The namespace or namespaces to filter by
"""
if isinstance(namespaces, str):
def target_namespace_filte... |
Search for nodes with the given namespace ( s ) and whose names containing a given string ( s ). | def search_node_namespace_names(graph, query, namespace):
"""Search for nodes with the given namespace(s) and whose names containing a given string(s).
:param pybel.BELGraph graph: A BEL graph
:param query: The search query
:type query: str or iter[str]
:param namespace: The namespace(s) to filter
... |
Assign if a value is greater than or less than a cutoff. | def get_cutoff(value: float, cutoff: Optional[float] = None) -> int:
"""Assign if a value is greater than or less than a cutoff."""
cutoff = cutoff if cutoff is not None else 0
if value > cutoff:
return 1
if value < (-1 * cutoff):
return - 1
return 0 |
Help calculate network - wide concordance | def calculate_concordance_helper(graph: BELGraph,
key: str,
cutoff: Optional[float] = None,
) -> Tuple[int, int, int, int]:
"""Help calculate network-wide concordance
Assumes data already annotated with given key... |
Calculates network - wide concordance. | def calculate_concordance(graph: BELGraph, key: str, cutoff: Optional[float] = None,
use_ambiguous: bool = False) -> float:
"""Calculates network-wide concordance.
Assumes data already annotated with given key
:param graph: A BEL graph
:param key: The node data dictionary key... |
Calculate the one - sided probability of getting a value more extreme than the distribution. | def one_sided(value: float, distribution: List[float]) -> float:
"""Calculate the one-sided probability of getting a value more extreme than the distribution."""
assert distribution
return sum(value < element for element in distribution) / len(distribution) |
Calculates a graph s concordance as well as its statistical probability. | def calculate_concordance_probability(graph: BELGraph,
key: str,
cutoff: Optional[float] = None,
permutations: Optional[int] = None,
percentage: Optional[float] = None,... |
Returns the concordance scores for each stratified graph based on the given annotation | def calculate_concordance_by_annotation(graph, annotation, key, cutoff=None):
"""Returns the concordance scores for each stratified graph based on the given annotation
:param pybel.BELGraph graph: A BEL graph
:param str annotation: The annotation to group by.
:param str key: The node data dictionary ke... |
Returns the results of concordance analysis on each subgraph stratified by the given annotation. | def calculate_concordance_probability_by_annotation(graph, annotation, key, cutoff=None, permutations=None,
percentage=None,
use_ambiguous=False):
"""Returns the results of concordance analysis on each subgraph, ... |
Get a mapping from drugs to their list of gene. | def _get_drug_target_interactions(manager: Optional['bio2bel_drugbank.manager'] = None) -> Mapping[str, List[str]]:
"""Get a mapping from drugs to their list of gene."""
if manager is None:
import bio2bel_drugbank
manager = bio2bel_drugbank.Manager()
if not manager.is_populated():
m... |
Run EpiCom analysis on many graphs. | def multi_run_epicom(graphs: Iterable[BELGraph], path: Union[None, str, TextIO]) -> None:
"""Run EpiCom analysis on many graphs."""
if isinstance(path, str):
with open(path, 'w') as file:
_multi_run_helper_file_wrapper(graphs, file)
else:
_multi_run_helper_file_wrapper(graphs, p... |
Convert the Alzheimer s and Parkinson s disease NeuroMMSig excel sheets to BEL. | def main():
"""Convert the Alzheimer's and Parkinson's disease NeuroMMSig excel sheets to BEL."""
logging.basicConfig(level=logging.INFO)
log.setLevel(logging.INFO)
bms_base = get_bms_base()
neurommsig_base = get_neurommsig_base()
neurommsig_excel_dir = os.path.join(neurommsig_base, 'resources'... |
Remove all edges between node pairs with inconsistent edges. | def remove_inconsistent_edges(graph: BELGraph) -> None:
"""Remove all edges between node pairs with inconsistent edges.
This is the all-or-nothing approach. It would be better to do more careful investigation of the evidences during
curation.
"""
for u, v in get_inconsistent_edges(graph):
e... |
Gets all walks under a given length starting at a given node | def get_walks_exhaustive(graph, node, length):
"""Gets all walks under a given length starting at a given node
:param networkx.Graph graph: A graph
:param node: Starting node
:param int length: The length of walks to get
:return: A list of paths
:rtype: list[tuple]
"""
if 0 == length:
... |
Matches a simple metapath starting at the given node | def match_simple_metapath(graph, node, simple_metapath):
"""Matches a simple metapath starting at the given node
:param pybel.BELGraph graph: A BEL graph
:param tuple node: A BEL node
:param list[str] simple_metapath: A list of BEL Functions
:return: An iterable over paths from the node matching th... |
Build a database of scores for NeuroMMSig annotated graphs. | def build_database(manager: pybel.Manager, annotation_url: Optional[str] = None) -> None:
"""Build a database of scores for NeuroMMSig annotated graphs.
1. Get all networks that use the Subgraph annotation
2. run on each
"""
annotation_url = annotation_url or NEUROMMSIG_DEFAULT_URL
annotation ... |
Calculate the scores over all biological processes in the sub - graph. | def calculate_average_scores_on_graph(
graph: BELGraph,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
use_tqdm: bool = False,
):
"""Calculate the scores over all biological processes in the sub... |
Calculate the scores over precomputed candidate mechanisms. | def calculate_average_scores_on_subgraphs(
subgraphs: Mapping[H, BELGraph],
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
use_tqdm: bool = False,
tqdm_kwargs: Optional[Mapping[str, Any]] = ... |
Generate candidate mechanisms and run the heat diffusion workflow. | def workflow(
graph: BELGraph,
node: BaseEntity,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
minimum_nodes: int = 1,
) -> List['Runner']:
"""Generate candidate mechanisms and run the ... |
Run the heat diffusion workflow multiple times each time yielding a: class: Runner object upon completion. | def multirun(graph: BELGraph,
node: BaseEntity,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
use_tqdm: bool = False,
) -> Iterable['Runner']:
"""Run ... |
Get the average score over multiple runs. | def workflow_aggregate(graph: BELGraph,
node: BaseEntity,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
agg... |
Run the heat diffusion workflow and get runners for every possible candidate mechanism | def workflow_all(graph: BELGraph,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
) -> Mapping[BaseEntity, List[Runner]]:
"""Run the heat diffusion workflow a... |
Run the heat diffusion workflow to get average score for every possible candidate mechanism. | def workflow_all_aggregate(graph: BELGraph,
key: Optional[str] = None,
tag: Optional[str] = None,
default_score: Optional[float] = None,
runs: Optional[int] = None,
aggregator: Optional... |
For each sub - graph induced over the edges matching the annotation calculate the average score for all of the contained biological processes | def calculate_average_score_by_annotation(
graph: BELGraph,
annotation: str,
key: Optional[str] = None,
runs: Optional[int] = None,
use_tqdm: bool = False,
) -> Mapping[str, float]:
"""For each sub-graph induced over the edges matching the annotation, calculate the average sc... |
Return an iterable over all nodes that are leaves. | def iter_leaves(self) -> Iterable[BaseEntity]:
"""Return an iterable over all nodes that are leaves.
A node is a leaf if either:
- it doesn't have any predecessors, OR
- all of its predecessors have a score in their data dictionaries
"""
for node in self.graph:
... |
Calculate the ratio of in - degree/ out - degree of a node. | def in_out_ratio(self, node: BaseEntity) -> float:
"""Calculate the ratio of in-degree / out-degree of a node."""
return self.graph.in_degree(node) / float(self.graph.out_degree(node)) |
Iterate over all nodes without a score. | def unscored_nodes_iter(self) -> BaseEntity:
"""Iterate over all nodes without a score."""
for node, data in self.graph.nodes(data=True):
if self.tag not in data:
yield node |
This function should be run when there are no leaves but there are still unscored nodes. It will introduce a probabilistic element to the algorithm where some edges are disregarded randomly to eventually get a score for the network. This means that the score can be averaged over many runs for a given graph and a better... | def get_random_edge(self):
"""This function should be run when there are no leaves, but there are still unscored nodes. It will introduce
a probabilistic element to the algorithm, where some edges are disregarded randomly to eventually get a score
for the network. This means that the score can b... |
Remove a random in - edge from the node with the lowest in/ out degree ratio. | def remove_random_edge(self):
"""Remove a random in-edge from the node with the lowest in/out degree ratio."""
u, v, k = self.get_random_edge()
log.log(5, 'removing %s, %s (%s)', u, v, k)
self.graph.remove_edge(u, v, k) |
Remove random edges until there is at least one leaf node. | def remove_random_edge_until_has_leaves(self) -> None:
"""Remove random edges until there is at least one leaf node."""
while True:
leaves = set(self.iter_leaves())
if leaves:
return
self.remove_random_edge() |
Calculate the score for all leaves. | def score_leaves(self) -> Set[BaseEntity]:
"""Calculate the score for all leaves.
:return: The set of leaf nodes that were scored
"""
leaves = set(self.iter_leaves())
if not leaves:
log.warning('no leaves.')
return set()
for leaf in leaves:
... |
Calculate scores for all leaves until there are none removes edges until there are and repeats until all nodes have been scored. Also yields the current graph at every step so you can make a cool animation of how the graph changes throughout the course of the algorithm | def run_with_graph_transformation(self) -> Iterable[BELGraph]:
"""Calculate scores for all leaves until there are none, removes edges until there are, and repeats until
all nodes have been scored. Also, yields the current graph at every step so you can make a cool animation
of how the graph chan... |
Determines if the algorithm is complete by checking if the target node of this analysis has been scored yet. Because the algorithm removes edges when it gets stuck until it is un - stuck it is always guaranteed to finish. | def done_chomping(self) -> bool:
"""Determines if the algorithm is complete by checking if the target node of this analysis has been scored
yet. Because the algorithm removes edges when it gets stuck until it is un-stuck, it is always guaranteed to
finish.
:return: Is the algorithm done... |
Return the final score for the target node. | def get_final_score(self) -> float:
"""Return the final score for the target node.
:return: The final score for the target node
"""
if not self.done_chomping():
raise ValueError('algorithm has not yet completed')
return self.graph.nodes[self.target_node][self.tag] |
Calculate the new score of the given node. | def calculate_score(self, node: BaseEntity) -> float:
"""Calculate the new score of the given node."""
score = (
self.graph.nodes[node][self.tag]
if self.tag in self.graph.nodes[node] else
self.default_score
)
for predecessor, _, d in self.graph.in_ed... |
Return the numpy structured array data type for sample states | def microcanonical_statistics_dtype(spanning_cluster=True):
"""
Return the numpy structured array data type for sample states
Helper function
Parameters
----------
spanning_cluster : bool, optional
Whether to detect a spanning cluster or not.
Defaults to ``True``.
Returns
... |
Generate successive sample states of the bond percolation model | def bond_sample_states(
perc_graph, num_nodes, num_edges, seed, spanning_cluster=True,
auxiliary_node_attributes=None, auxiliary_edge_attributes=None,
spanning_sides=None,
**kwargs
):
'''
Generate successive sample states of the bond percolation model
This is a :ref:`generator function <pyt... |
Evolve a single run over all microstates ( bond occupation numbers ) | def bond_microcanonical_statistics(
perc_graph, num_nodes, num_edges, seed,
spanning_cluster=True,
auxiliary_node_attributes=None, auxiliary_edge_attributes=None,
spanning_sides=None,
**kwargs
):
"""
Evolve a single run over all microstates (bond occupation numbers)
Return the cluster s... |
The NumPy Structured Array type for canonical statistics | def canonical_statistics_dtype(spanning_cluster=True):
"""
The NumPy Structured Array type for canonical statistics
Helper function
Parameters
----------
spanning_cluster : bool, optional
Whether to detect a spanning cluster or not.
Defaults to ``True``.
Returns
------... |
canonical cluster statistics for a single run and a single probability | def bond_canonical_statistics(
microcanonical_statistics,
convolution_factors,
**kwargs
):
"""
canonical cluster statistics for a single run and a single probability
Parameters
----------
microcanonical_statistics : ndarray
Return value of `bond_microcanonical_statistics`
... |
The NumPy Structured Array type for canonical averages over several runs | def canonical_averages_dtype(spanning_cluster=True):
"""
The NumPy Structured Array type for canonical averages over several
runs
Helper function
Parameters
----------
spanning_cluster : bool, optional
Whether to detect a spanning cluster or not.
Defaults to ``True``.
... |
Initialize the canonical averages from a single - run cluster statistics | def bond_initialize_canonical_averages(
canonical_statistics, **kwargs
):
"""
Initialize the canonical averages from a single-run cluster statistics
Parameters
----------
canonical_statistics : 1-D structured ndarray
Typically contains the canonical statistics for a range of values
... |
Reduce the canonical averages over several runs | def bond_reduce(row_a, row_b):
"""
Reduce the canonical averages over several runs
This is a "true" reducer.
It is associative and commutative.
This is a wrapper around `simoa.stats.online_variance`.
Parameters
----------
row_a, row_b : structured ndarrays
Output of this funct... |
The NumPy Structured Array type for finalized canonical averages over several runs | def finalized_canonical_averages_dtype(spanning_cluster=True):
"""
The NumPy Structured Array type for finalized canonical averages over
several runs
Helper function
Parameters
----------
spanning_cluster : bool, optional
Whether to detect a spanning cluster or not.
Default... |
Finalize canonical averages | def finalize_canonical_averages(
number_of_nodes, ps, canonical_averages, alpha,
):
"""
Finalize canonical averages
"""
spanning_cluster = (
(
'percolation_probability_mean' in
canonical_averages.dtype.names
) and
'percolation_probability_m2' in canon... |
Compare generated mechanisms to actual ones. | def compare(graph: BELGraph, annotation: str = 'Subgraph') -> Mapping[str, Mapping[str, float]]:
"""Compare generated mechanisms to actual ones.
1. Generates candidate mechanisms for each biological process
2. Gets sub-graphs for all NeuroMMSig signatures
3. Make tanimoto similarity comparison for all ... |
Print a summary of the number of nodes passing a given set of filters. | def summarize_node_filter(graph: BELGraph, node_filters: NodePredicates) -> None:
"""Print a summary of the number of nodes passing a given set of filters.
:param graph: A BEL graph
:param node_filters: A node filter or list/tuple of node filters
"""
passed = count_passed_node_filter(graph, node_fi... |
Build a filter that only passes on nodes in the given list. | def node_inclusion_filter_builder(nodes: Iterable[BaseEntity]) -> NodePredicate:
"""Build a filter that only passes on nodes in the given list.
:param nodes: An iterable of BEL nodes
"""
node_set = set(nodes)
def inclusion_filter(_: BELGraph, node: BaseEntity) -> bool:
"""Pass only for a n... |
Build a filter that fails on nodes in the given list. | def node_exclusion_filter_builder(nodes: Iterable[BaseEntity]) -> NodePredicate:
"""Build a filter that fails on nodes in the given list."""
node_set = set(nodes)
def exclusion_filter(_: BELGraph, node: BaseEntity) -> bool:
"""Pass only for a node that isn't in the enclosed node list
:retu... |
Build a filter that fails on nodes of the given function ( s ). | def function_exclusion_filter_builder(func: Strings) -> NodePredicate:
"""Build a filter that fails on nodes of the given function(s).
:param func: A BEL Function or list/set/tuple of BEL functions
"""
if isinstance(func, str):
def function_exclusion_filter(_: BELGraph, node: BaseEntity) -> boo... |
Build a filter function for matching the given BEL function with the given namespace or namespaces. | def function_namespace_inclusion_builder(func: str, namespace: Strings) -> NodePredicate:
"""Build a filter function for matching the given BEL function with the given namespace or namespaces.
:param func: A BEL function
:param namespace: The namespace to search by
"""
if isinstance(namespace, str)... |
Build a filter that passes only on nodes that have the given key in their data dictionary. | def data_contains_key_builder(key: str) -> NodePredicate: # noqa: D202
"""Build a filter that passes only on nodes that have the given key in their data dictionary.
:param key: A key for the node's data dictionary
"""
def data_contains_key(_: BELGraph, node: BaseEntity) -> bool:
"""Pass only ... |
Returns all variants of the given node. | def variants_of(
graph: BELGraph,
node: Protein,
modifications: Optional[Set[str]] = None,
) -> Set[Protein]:
"""Returns all variants of the given node."""
if modifications:
return _get_filtered_variants_of(graph, node, modifications)
return {
v
for u, v, key... |
Get a mapping from variants of the given node to all of its upstream controllers. | def get_variants_to_controllers(
graph: BELGraph,
node: Protein,
modifications: Optional[Set[str]] = None,
) -> Mapping[Protein, Set[Protein]]:
"""Get a mapping from variants of the given node to all of its upstream controllers."""
rv = defaultdict(set)
variants = variants_of(graph, ... |
Make a dict that accumulates the values for each key in an iterator of doubles. | def group_dict_set(iterator: Iterable[Tuple[A, B]]) -> Mapping[A, Set[B]]:
"""Make a dict that accumulates the values for each key in an iterator of doubles."""
d = defaultdict(set)
for key, value in iterator:
d[key].add(value)
return dict(d) |
Build a dictionary of { node pair: set of edge types }. | def get_edge_relations(graph: BELGraph) -> Mapping[Tuple[BaseEntity, BaseEntity], Set[str]]:
"""Build a dictionary of {node pair: set of edge types}."""
return group_dict_set(
((u, v), d[RELATION])
for u, v, d in graph.edges(data=True)
) |
Return a histogram of the different types of relations present in a graph. | def count_unique_relations(graph: BELGraph) -> Counter:
"""Return a histogram of the different types of relations present in a graph.
Note: this operation only counts each type of edge once for each pair of nodes
"""
return Counter(itt.chain.from_iterable(get_edge_relations(graph).values())) |
Get annotation/ value pairs for values for whom the search string is a substring | def get_annotations_containing_keyword(graph: BELGraph, keyword: str) -> List[Mapping[str, str]]:
"""Get annotation/value pairs for values for whom the search string is a substring
:param graph: A BEL graph
:param keyword: Search for annotations whose values have this as a substring
"""
return [
... |
Count in how many edges each annotation appears in a graph | def count_annotation_values(graph: BELGraph, annotation: str) -> Counter:
"""Count in how many edges each annotation appears in a graph
:param graph: A BEL graph
:param annotation: The annotation to count
:return: A Counter from {annotation value: frequency}
"""
return Counter(iter_annotation_v... |
Count in how many edges each annotation appears in a graph but filter out source nodes and target nodes. | def count_annotation_values_filtered(graph: BELGraph,
annotation: str,
source_predicate: Optional[NodePredicate] = None,
target_predicate: Optional[NodePredicate] = None,
)... |
Return if the edges between the given nodes are consistent meaning they all have the same relation. | def pair_is_consistent(graph: BELGraph, u: BaseEntity, v: BaseEntity) -> Optional[str]:
"""Return if the edges between the given nodes are consistent, meaning they all have the same relation.
:return: If the edges aren't consistent, return false, otherwise return the relation type
"""
relations = {data... |
Iterates over contradictory node pairs in the graph based on their causal relationships: return: An iterator over ( source target ) node pairs that have contradictory causal edges | def get_contradictory_pairs(graph: BELGraph) -> Iterable[Tuple[BaseEntity, BaseEntity]]:
"""Iterates over contradictory node pairs in the graph based on their causal relationships
:return: An iterator over (source, target) node pairs that have contradictory causal edges
"""
for u, v in graph.edges(... |
Yield pairs of ( source node target node ) for which all of their edges have the same type of relation. | def get_consistent_edges(graph: BELGraph) -> Iterable[Tuple[BaseEntity, BaseEntity]]:
"""Yield pairs of (source node, target node) for which all of their edges have the same type of relation.
:return: An iterator over (source, target) node pairs corresponding to edges with many inconsistent relations
"""
... |
Add edges to the graph when a two way edge exists and the opposite direction doesn t exist. | def infer_missing_two_way_edges(graph):
"""Add edges to the graph when a two way edge exists, and the opposite direction doesn't exist.
Use: two way edges from BEL definition and/or axiomatic inverses of membership relations
:param pybel.BELGraph graph: A BEL graph
"""
for u, v, k, d in graph.edge... |
Add the same edge but in the opposite direction if not already present. | def infer_missing_backwards_edge(graph, u, v, k):
"""Add the same edge, but in the opposite direction if not already present.
:type graph: pybel.BELGraph
:type u: tuple
:type v: tuple
:type k: int
"""
if u in graph[v]:
for attr_dict in graph[v][u].values():
if attr_dict ... |
Add the missing unqualified edges between entities in the subgraph that are contained within the full graph. | def enrich_internal_unqualified_edges(graph, subgraph):
"""Add the missing unqualified edges between entities in the subgraph that are contained within the full graph.
:param pybel.BELGraph graph: The full BEL graph
:param pybel.BELGraph subgraph: The query BEL subgraph
"""
for u, v in itt.combinat... |
Build a template BEL document with the given PubMed identifiers. | def boilerplate(name, contact, description, pmids, version, copyright, authors, licenses, disclaimer, output):
"""Build a template BEL document with the given PubMed identifiers."""
from .document_utils import write_boilerplate
write_boilerplate(
name=name,
version=version,
descript... |
Parse a BEL document then serializes the given namespaces ( errors and all ) to the given directory. | def serialize_namespaces(namespaces, connection: str, path, directory):
"""Parse a BEL document then serializes the given namespaces (errors and all) to the given directory."""
from .definition_utils import export_namespaces
graph = from_lines(path, manager=connection)
export_namespaces(namespaces, gra... |
Output PubMed identifiers from a graph to a stream. | def get_pmids(graph: BELGraph, output: TextIO):
"""Output PubMed identifiers from a graph to a stream."""
for pmid in get_pubmed_identifiers(graph):
click.echo(pmid, file=output) |
Get count of rows in table object. | def getrowcount(self, window_name, object_name):
"""
Get count of rows in table object.
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to look for, either fu... |
Select row | def selectrow(self, window_name, object_name, row_text, partial_match=False):
"""
Select row
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either... |
Select multiple row | def multiselect(self, window_name, object_name, row_text_list, partial_match=False):
"""
Select multiple row
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to... |
Select row partial match | def selectrowpartialmatch(self, window_name, object_name, row_text):
"""
Select row partial match
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, e... |
Select row index | def selectrowindex(self, window_name, object_name, row_index):
"""
Select row index
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full nam... |
Select last row | def selectlastrow(self, window_name, object_name):
"""
Select last row
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LD... |
Get cell value | def getcellvalue(self, window_name, object_name, row_index, column=0):
"""
Get cell value
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either fu... |
Get table row index matching given text | def gettablerowindex(self, window_name, object_name, row_text):
"""
Get table row index matching given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to ... |
Double click row matching given text | def doubleclickrow(self, window_name, object_name, row_text):
"""
Double click row matching given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type ... |
Double click row matching given text | def doubleclickrowindex(self, window_name, object_name, row_index, col_index=0):
"""
Double click row matching given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: O... |
Verify table cell value with given text | def verifytablecell(self, window_name, object_name, row_index,
column_index, row_text):
"""
Verify table cell value with given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: st... |
Verify table cell value with given text | def doesrowexist(self, window_name, object_name, row_text,
partial_match=False):
"""
Verify table cell value with given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
... |
Verify partial table cell value | def verifypartialtablecell(self, window_name, object_name, row_index,
column_index, row_text):
"""
Verify partial table cell value
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_na... |
Get all accessibility application name that are currently running | def getapplist(self):
"""
Get all accessibility application name that are currently running
@return: list of appliction name of string type on success.
@rtype: list
"""
app_list = []
# Update apps list, before parsing the list
self._update_apps()
... |
Start memory and CPU monitoring with the time interval between each process scan | def startprocessmonitor(self, process_name, interval=2):
"""
Start memory and CPU monitoring, with the time interval between
each process scan
@param process_name: Process name, ex: firefox-bin.
@type process_name: string
@param interval: Time interval between each proce... |
Stop memory and CPU monitoring | def stopprocessmonitor(self, process_name):
"""
Stop memory and CPU monitoring
@param process_name: Process name, ex: firefox-bin.
@type process_name: string
@return: 1 on success
@rtype: integer
"""
if process_name in self._process_stats:
# ... |
get CPU stat for the give process name | def getcpustat(self, process_name):
"""
get CPU stat for the give process name
@param process_name: Process name, ex: firefox-bin.
@type process_name: string
@return: cpu stat list on success, else empty list
If same process name, running multiple instance,
... |
get memory stat | def getmemorystat(self, process_name):
"""
get memory stat
@param process_name: Process name, ex: firefox-bin.
@type process_name: string
@return: memory stat list on success, else empty list
If same process name, running multiple instance,
get t... |
Get list of items in given GUI. | def getobjectlist(self, window_name):
"""
Get list of items in given GUI.
@param window_name: Window name to look for, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@return: list of items in LDTP naming convention.
@rtype: l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.