Utils¶
Methods for various purposes.
-
class
pathme.utils.
CallCounted
(method)[source]¶ Decorator to determine number of calls for a method.
Init method.
-
pathme.utils.
parse_id_uri
(uri: str) → Tuple[str, str, str, str][source]¶ Get the components of a given uri (with identifier at the last position).
- Parameters
uri – URI
- Returns
prefix (ex: http://rdf.wikipathways.org/…)
- Returns
prefix_namespaces: if there are many namespaces, until the penultimate (ex: …/Pathway/WP22_r97775/…)
- Returns
namespace: if there are many namespaces, the last (ex: …/Interaction/)
- Returns
identifier (ex: …/c562c/)
-
pathme.utils.
parse_namespace_uri
(uri: str) → Tuple[str, str, str][source]¶ Get the prefix and namespace of a given URI (without identifier, only with a namspace at last position).
- Parameters
uri – URI
- Returns
prefix (ex: http://purl.org/dc/terms/…)
- Returns
namespace (ex: …/isPartOf)
-
pathme.utils.
parse_rdf
(path: str, format: Optional[str] = None) → rdflib.graph.Graph[source]¶ Import a queried pathway into a rdflib Graph object.
- Parameters
path – RDF file path
format – RDF file format, default is turtle
-
pathme.utils.
entry_result_to_dict
(entry, **kwargs)[source]¶ Export to a dictionary a SPARQL query result data structure.
- Returns
entries_dict: Dictionary with all the entries id as keys and the entries arguments as values.
- Return type
-
pathme.utils.
query_result_to_dict
(entries, **kwargs) → Dict[str, Dict[str, Dict[str, str]]][source]¶ Export to a dictionary a SPARQL query result data structure.
- Returns
entries_dict: Dictionary with all the entries id as keys and the entries arguments as values.
- Return type
-
pathme.utils.
get_entry_statitics
(types_list, primary_type=None, **kwargs)[source]¶ Get types statistics for a pathway entries type (nodes or interactions) set.
-
pathme.utils.
get_pathway_statitics
(nodes_types, edges_types, bel_graph, **kwargs)[source]¶ Calculate pathway statistics.
-
pathme.utils.
statistics_to_df
(all_pathways_statistics)[source]¶ Build a data frame with graph statistics.
- Parameters
all_pathways_statistics (dict) – pathway statistics
- Return type
pandas.DataFrame
-
pathme.utils.
get_bel_types
(path: str)[source]¶ Get BEL node and edge type statistics.
- Parameters
path – path to pickle
- Returns
count of all nodes and edges in a BEL graph
- Return type
-
pathme.utils.
get_bel_stats
(resource_folder: str)[source]¶ Get all BEL node and edge type statistics.
- Parameters
resource_folder – path to BEL pickles folder
- Returns
count of all nodes and edges in all BEL graphs from one resource
- Return type
-
pathme.utils.
get_genes_from_pickles
(resource_folder: str, files: List[str], manager) → Dict[str, set][source]¶ Get BEL graph gene set for all pathways in resource.
-
pathme.utils.
get_kegg_genes_from_pickles
(resource_folder, files: List[str], manager) → Dict[str, Set][source]¶ Get BEL graph gene set for all KEGG pathways.
-
pathme.utils.
get_genes_in_graph
(graph: pybel.struct.graph.BELGraph) → Set[str][source]¶ Get BEL graph gene set for a pathway.
- Parameters
graph – BEL Graph
- Returns
BEL graph gene set
-
pathme.utils.
jaccard_similarity
(database_gene_set, bel_genes_set)[source]¶ Get Jaccard similarity for gene sets in database and BEL graphs.
-
pathme.utils.
make_downloader
(url, path, export_path, decompress_file)[source]¶ Make a function that downloads the data for you, or uses a cached version at the given path.