The INDRA CoGEx Neo4j Client (indra_cogex.client.queries)

get_diseases_for_trial(trial, *, client)[source]

Return the diseases for the given trial.

Parameters:
Return type:

Iterable[Node]

Returns:

The diseases for the given trial.

get_drugs_for_side_effect(side_effect, *, client)[source]

Return the drugs for the given side effect.

Parameters:
Return type:

Iterable[Node]

Returns:

The drugs for the given side effect.

get_drugs_for_target(target, *, client)[source]

Return the drugs targeting the given protein.

Parameters:
Return type:

Iterable[Agent]

Returns:

The drugs targeting the given protein.

get_drugs_for_targets(targets, *, client)[source]

Return the drugs targeting each of the given targets.

Parameters:
Return type:

Mapping[str, Iterable[Agent]]

Returns:

A mapping of targets to the drugs targeting each of the given targets.

get_drugs_for_trial(trial, *, client)[source]

Return the drugs for the given trial.

Parameters:
Return type:

Iterable[Node]

Returns:

The drugs for the given trial.

get_edge_counter(*, client)[source]

Get a count of each edge type.

Return type:

Counter

get_evidences_for_mesh(mesh_term, include_child_terms=True, *, client)[source]

Return the evidence objects for the given MESH term.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • mesh_term (Tuple[str, str]) – The MESH ID to query.

  • include_child_terms (bool) – If True, also match against the child MESH terms of the given MESH ID

Return type:

Dict[int, List[Evidence]]

Returns:

The evidence objects for the given MESH ID grouped into a dict by statement hash.

get_evidences_for_stmt_hash(stmt_hash, *, client, limit=None, offset=0, remove_medscan=True)[source]

Return the matching evidence objects for the given statement hash.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • stmt_hash (int) – The statement hash to query, accepts both string and integer.

  • limit (Optional[int]) – The maximum number of results to return.

  • offset (int) – The number of results to skip before returning the first result.

  • remove_medscan (bool) – If True, remove the MedScan evidence from the results.

Return type:

Iterable[Evidence]

Returns:

The evidence objects for the given statement hash.

get_evidences_for_stmt_hashes(stmt_hashes, *, client, limit=None, remove_medscan=True)[source]

Return the matching evidence objects for the given statement hashes.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • stmt_hashes (Iterable[int]) – The statement hashes to query, accepts integers and strings.

  • limit (Optional[str]) – The optional maximum number of evidences returned for each statement hash

  • remove_medscan (bool) – If True, remove the MedScan evidence from the results.

Return type:

Dict[int, List[Evidence]]

Returns:

A mapping of stmt hash to a list of evidence objects for the given statement hashes.

get_genes_for_go_term(go_term, include_indirect=False, *, client)[source]

Return the genes associated with the given GO term.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • go_term (Tuple[str, str]) – The GO term to query. Example: ("GO", "GO:0006915")

  • include_indirect (bool) – Should ontological children of the given GO term be queried as well? Defaults to False.

Return type:

Iterable[Node]

Returns:

The genes associated with the given GO term.

get_genes_for_pathway(pathway, *, client)[source]

Return the genes for the given pathway.

Parameters:
Return type:

Iterable[Node]

Returns:

The genes for the given pathway.

get_genes_in_tissue(tissue, *, client)[source]

Return the genes in the given tissue.

Parameters:
Return type:

Iterable[Node]

Returns:

The genes expressed in the given tissue.

get_go_terms_for_gene(gene, include_indirect=False, *, client)[source]

Return the GO terms for the given gene.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • gene (Tuple[str, str]) – The gene to query.

  • include_indirect (bool) – If True, also return indirect GO terms.

Return type:

Iterable[Node]

Returns:

The GO terms for the given gene.

get_mesh_ids_for_pmid(pmid_term, *, client)[source]

Return the MESH terms for the given PubMed ID.

Parameters:
Return type:

Iterable[Node]

Returns:

The MESH terms for the given PubMed ID.

get_mutated_genes(cell_line, *, client)[source]

Return the list of genes that are mutated in a given cell line.

Parameters client:

The Neo4j client.

cell_line :

The cell line to query.

Return type:

List[Node]

Returns:

The list of genes that are mutated in the given cell line.

get_node_counter(*, client)[source]

Get a count of each entity type.

Parameters:

client (Neo4jClient) – The Neo4j client.

Return type:

Counter

Returns:

A Counter of the entity types.

Warning

This code assumes all nodes only have one label, as in label[0]

get_ontology_child_terms(term, *, client)[source]

Return the child terms of the given term.

Parameters:
Return type:

Iterable[Node]

Returns:

The child terms of the given term.

get_ontology_parent_terms(term, *, client)[source]

Return the parent terms of the given term.

Parameters:
Return type:

Iterable[Node]

Returns:

The parent terms of the given term.

get_pathways_for_gene(gene, *, client)[source]

Return the pathways for the given gene.

Parameters:
Return type:

Iterable[Node]

Returns:

The pathways for the given gene.

get_pmids_for_mesh(mesh_term, include_child_terms=True, *, client)[source]

Return the PubMed IDs for the given MESH term.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • mesh_term (Tuple[str, str]) – The MESH term to query.

  • include_child_terms (bool) – If True, also match against the child MESH terms of the given MESH term.

Return type:

Iterable[Node]

Returns:

The PubMed IDs for the given MESH term and, optionally, its child terms.

get_schema_graph(*, client)[source]

Get a NetworkX graph reflecting the schema of the Neo4j graph.

Generate a PDF diagram (works with PNG and SVG too) with the following:

>>> from networkx.drawing.nx_agraph import to_agraph
>>> client = ...
>>> graph = get_schema_graph(client=client)
>>> to_agraph(graph).draw("~/Desktop/cogex_schema.pdf", prog="dot")
Return type:

MultiDiGraph

get_shared_pathways_for_genes(genes, *, client)[source]

Return the shared pathways for the given list of genes.

Parameters:
Return type:

Iterable[Node]

Returns:

The pathways for the given gene.

get_side_effects_for_drug(drug, *, client)[source]

Return the side effects for the given drug.

Parameters:
Return type:

Iterable[Node]

Returns:

The side effects for the given drug.

get_stmts_for_mesh(mesh_term, include_child_terms=True, *, client, **kwargs)[source]

Return the statements with evidence for the given MESH ID.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • mesh_term (Tuple[str, str]) – The MESH ID to query.

  • include_child_terms (bool) – If True, also match against the children of the given MESH ID.

  • kwargs – Additional keyword arguments to forward to get_stmts_for_stmt_hashes()

Return type:

Iterable[Statement]

Returns:

The statements for the given MESH ID.

get_stmts_for_paper(paper_term, *, client, **kwargs)[source]

Return the statements with evidence from the given PubMed ID.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • paper_term (Tuple[str, str]) – The term to query. Can be a PubMed ID, PMC id, TRID, or DOI

Return type:

List[Statement]

Returns:

The statements for the given PubMed ID.

get_stmts_for_pubmeds(pubmeds, *, client, **kwargs)[source]

Return the statements with evidence from the given PubMed ID.

Parameters:
Return type:

List[Statement]

Returns:

The statements for the given PubMed identifiers.

Example

from indra_cogex.client.queries import get_stmts_for_pubmeds

pubmeds = [20861832, 19503834]
stmts = get_stmts_for_pubmeds(pubmeds)
get_stmts_for_stmt_hashes(stmt_hashes, *, evidence_map=None, client, evidence_limit=None, return_evidence_counts=False, subject_prefix=None, object_prefix=None)[source]

Return the statements for the given statement hashes.

Parameters:
  • client (Neo4jClient) – The Neo4j client.

  • stmt_hashes (Iterable[int]) – The statement hashes to query.

  • evidence_map (Optional[Dict[int, List[Evidence]]]) – Optionally provide a mapping of stmt hash to a list of evidence objects

  • evidence_limit (Optional[int]) – An optional maximum number of evidences to return

Return type:

Union[List[Statement], Tuple[List[Statement], Mapping[int, int]]]

Returns:

The statements for the given statement hashes.

get_stmts_meta_for_stmt_hashes(stmt_hashes, *, client)[source]

Return the metadata and statements for a given list of hashes

Parameters:
  • stmt_hashes (Iterable[int]) – The list of statement hashes to query.

  • client (Neo4jClient) – The Neo4j client.

Return type:

Iterable[Relation]

Returns:

A dict of statements with their metadata

get_targets_for_drug(drug, *, client)[source]

Return the proteins targeted by the given drug.

Parameters:
Return type:

Iterable[Agent]

Returns:

The proteins targeted by the given drug.

get_targets_for_drugs(drugs, *, client)[source]

Return the proteins targeted by each of the given drugs

Parameters:
Return type:

Mapping[str, Iterable[Agent]]

Returns:

A mapping from each drug to the proteins targeted by that drug.

get_tissues_for_gene(gene, *, client)[source]

Return the tissues the gene is expressed in.

Parameters:
Return type:

Iterable[Node]

Returns:

The tissues the gene is expressed in.

get_trials_for_disease(disease, *, client)[source]

Return the trials for the given disease.

Parameters:
Return type:

Iterable[Node]

Returns:

The trials for the given disease.

get_trials_for_drug(drug, *, client)[source]

Return the trials for the given drug.

Parameters:
Return type:

Iterable[Node]

Returns:

The trials for the given drug.

is_drug_target(drug, target, *, client)[source]

Return True if the drug targets the given protein.

Parameters:
Return type:

bool

Returns:

True if the drug targets the given protein.

is_gene_in_pathway(gene, pathway, *, client)[source]

Return True if the gene is in the given pathway.

Parameters:
Return type:

bool

Returns:

True if the gene is in the given pathway.

is_gene_in_tissue(gene, tissue, *, client)[source]

Return True if the gene is expressed in the given tissue.

Parameters:
Return type:

bool

Returns:

True if the gene is expressed in the given tissue.

is_gene_mutated(gene, cell_line, *, client)[source]

Return True if the gene is mutated in the given cell line.

Parameters:
Return type:

bool

Returns:

True if the gene is mutated in the given cell line.

is_go_term_for_gene(gene, go_term, *, client)[source]

Return True if the given GO term is associated with the given gene.

Parameters:
Return type:

bool

Returns:

True if the given GO term is associated with the given gene.

is_side_effect_for_drug(drug, side_effect, *, client)[source]

Return True if the given side effect is associated with the given drug.

Parameters:
Return type:

bool

Returns:

True if the given side effect is associated with the given drug.

isa_or_partof(term, parent, *, client)[source]

Return True if the given term is a child of the given parent.

Parameters:
Return type:

bool

Returns:

True if the given term is a child term of the given parent.