tooluniverse.enrichr_tool moduleΒΆ

class tooluniverse.enrichr_tool.EnrichrTool(tool_config)[source]ΒΆ

Bases: BaseTool

Tool to perform gene enrichment analysis using Enrichr.

__init__(tool_config)[source]ΒΆ
build_graph(genes, enrichment_results)[source]ΒΆ

Initialize and build the graph with gene nodes and enriched terms.

Parameters:
  • genes (list) – List of gene names.

  • enrichment_results (dict) – Dictionary of enrichment results by library.

Returns:

The constructed graph.

Return type:

networkx.Graph

enrichr_api(genes, libs)[source]ΒΆ

Main API function to perform gene enrichment analysis.

Parameters:
  • genes (list) – List of gene names.

  • libs (list) – List of enrichment libraries to use.

Returns:

(connected_path, connections) dictionaries.

Return type:

tuple

get_enrichment_results(user_list_id, library)[source]ΒΆ

Fetch enrichment results for a specific library.

Parameters:
  • user_list_id (str) – The user list ID from Enrichr.

  • library (str) – The name of the enrichment library.

Returns:

The enrichment results.

Return type:

dict

get_official_gene_name(gene_name)[source]ΒΆ

Retrieve the official gene symbol for a given gene name or synonym using the MyGene.info API.

Parameters:

gene_name (str) – The gene name or synonym to query.

Returns:

The official gene symbol if found; otherwise, raises an Exception.

Return type:

str

rank_paths_by_weight(G, source, target)[source]ΒΆ

Find and rank paths between source and target based on total edge weight.

Parameters:
  • G (networkx.Graph) – The graph to search.

  • source (str) – The source node.

  • target (str) – The target node.

Returns:

List of tuples (path, weight) sorted by weight descending.

Return type:

list

rank_paths_to_term(G, gene, term)[source]ΒΆ

Find and rank paths from each gene to a specified term based on total edge weight.

Parameters:
  • G (networkx.Graph) – The graph to search.

  • gene (str) – The source gene.

  • term (str) – The target term.

Returns:

List of tuples (path, weight) sorted by weight descending, or None if no paths.

Return type:

list or None

run(arguments)[source]ΒΆ

Main entry point for the tool.

submit_gene_list(gene_list)[source]ΒΆ

Submit the gene list to Enrichr and return the user list ID.

Parameters:

gene_list (str) – Newline-separated string of gene names.

Returns:

The user list ID from Enrichr.

Return type:

str