Typed Python client and CLI for the mirDIP HTTP API.
- Project: Python client and CLI for
mirDIPathttp://ophid.utoronto.ca/mirDIP - Use cases: Query microRNA–gene target predictions programmatically
- Interfaces: Python API (
MirDIPClient) and CLI (mirdip)
pip install mirdip-clientTo develop/test locally:
pip install -e .[dev,test]from mirdip_client import MirDIPClient
client = MirDIPClient() # defaults to http://ophid.utoronto.ca/mirDIP
# Unidirectional: search by gene symbols
resp = client.search_genes("AKAP17A,AKR1C2,APP", "Very High")
print(resp.results_size)
print(resp.results) # Tab-delimited table- The server returns a custom text payload, parsed into a
MirDIPResponseobject with:raw_text: original server payload (string)fields: parsed key/value pairs (dict)- Convenience properties:
generated_at,gene_symbols,micro_rnas,minimum_score,db_occurrences,sources,results_size,results
to_dataframe(): convenience helper to parseresultsinto a pandas DataFrame.
resultsis a single string containing a tab-delimited table (header + rows). Convert to pandas easily:
import pandas as pd
from io import StringIO
df = pd.read_csv(StringIO(resp.results), sep="\t")
# or simply
df = resp.to_dataframe()mirDIP uses 4 score classes, mapped internally to API values:
- "Very High" → 0
- "High" → 1
- "Medium" → 2
- "Low" → 3
Always pass one of the four strings exactly as shown.
from mirdip_client import MirDIPClient
client = MirDIPClient(base_url="http://ophid.utoronto.ca/mirDIP", timeout=60.0)- base_url: change only if targeting a different mirDIP server.
- timeout: request timeout in seconds.
resp = client.search_genes(gene_symbols: str, minimum_score: str)- gene_symbols: comma-separated HUGO gene symbols (e.g.,
"AKAP17A,AKR1C2,APP"). - minimum_score: one of
"Very High" | "High" | "Medium" | "Low".
What it does
- Queries mirDIP for predicted microRNA targets associated with the provided genes.
- Internally calls the mirDIP
Http_Uendpoint withgenesymbolset andmicrornaleft empty.
Example
resp = client.search_genes("AKAP17A,AKR1C2,APP,ZZZ3,MARK4,C17orf51", "Very High")
print(resp.generated_at)
print(resp.results_size)
print(resp.results)resp = client.search_micro_rnas(micro_rnas: str, minimum_score: str)- micro_rnas: comma-separated microRNA identifiers (e.g.,
"hsa-miR-603,hsa-let-7a-3p"). - minimum_score: one of
"Very High" | "High" | "Medium" | "Low".
What it does
- Queries mirDIP for predicted gene targets associated with the provided microRNAs.
- Internally calls the mirDIP
Http_Uendpoint withmicrornaset andgenesymbolleft empty.
Example
resp = client.search_micro_rnas(
"hsa-miR-603, hsa-let-7a-3p, hsa-miR-625-5p, hsa-miR-7852-3p, hsa-miR-17-5p",
"Very High",
)
print(resp.micro_rnas)
print(resp.results_size)
print(resp.results)resp = client.search_bidirectional(
gene_symbols: str,
micro_rnas: str,
minimum_score: str,
sources: str,
occurrences: str = "1",
)- gene_symbols: comma-separated HUGO gene symbols.
- micro_rnas: comma-separated microRNA identifiers.
- minimum_score: one of
"Very High" | "High" | "Medium" | "Low". - sources: comma-separated list of source datasets to filter by. Examples include:
bitargeting_May_2021, BCmicrO, CoMeTa, Cupid, DIANA, miranda_May_2021, mirbase, mirCoX, mirmap_May_2021, mirzag, miRcode, miRDB_v6, miRTar2GO, MBStar, MirAncesTar, MirSNPInTarget, MirTar2, MiRNATIP, MultiMiTar, PACCMIT, PITA_May_2021, rnahybrid_May_2021, RNA22, TargetScan_v7_2- Use exact spelling.
- occurrences: minimum number of sources that must report a prediction (string number, allowed range typically
"1"to"24").
What it does
- Queries mirDIP for predictions present in at least
occurrencesof the specifiedsources, intersecting both provided genes and microRNAs. - Internally calls the mirDIP
Http_Bendpoint.
Example
resp = client.search_bidirectional(
"AKAP17A,AKR1C2,APP,ZZZ3,MARK4,C17orf51",
"hsa-miR-603,hsa-let-7a-3p,hsa-miR-625-5p,hsa-miR-7852-3p,hsa-miR-17-5p,hsa-miR-4321,hsa-miR-758-3p",
"Very High",
"bitargeting_May_2021, BCmicrO, CoMeTa, Cupid, DIANA, miranda_May_2021, mirbase, mirCoX, mirmap_May_2021, mirzag, miRcode, miRDB_v6, miRTar2GO, MBStar, MirAncesTar, MirSNPInTarget, MirTar2, MiRNATIP, MultiMiTar, PACCMIT, PITA_May_2021, rnahybrid_May_2021, RNA22, TargetScan_v7_2",
"2",
)
print(resp.db_occurrences)
print(resp.sources)
print(resp.results_size)
print(resp.results)Available convenience properties:
generated_at: timestamp of response creationgene_symbols: echo of input gene list (if provided)micro_rnas: echo of input microRNA list (if provided)minimum_score: echo of selected score classdb_occurrences: echo of selected occurrences (bidirectional)sources: echo of selected sources (bidirectional)results_size: number of rows returnedresults: tab-delimited content (header + rows)to_dataframe(): returns a pandas DataFrame from the tab-delimitedresultsstring (requirespandas).
The CLI mirrors the Python methods.
mirdip genes "AKAP17A,AKR1C2,APP" "Very High"- Prints a tab-delimited table to stdout.
- Options:
--base-urlto override server,--timeoutfor request timeout.
mirdip micrornas "hsa-miR-603,hsa-let-7a-3p" "High"mirdip bidirectional \
"AKAP17A,AKR1C2" \
"hsa-miR-603,hsa-let-7a-3p" \
"Medium" \
"TargetScan_v7_2, miRDB_v6" \
2Global options usable on any subcommand:
--base-url URL(defaulthttp://ophid.utoronto.ca/mirDIP)--timeout SECONDS(default60.0)
A full example script is provided at examples/example.py demonstrating all three queries and printing selected fields and the tab-delimited results.
- Ensure score strings are exact:
"Very High" | "High" | "Medium" | "Low". occurrencesmust be a stringified integer within the valid range for the data snapshot (commonly"1"–"24").- Network errors/timeouts: set a higher
timeoutor retry. - The server response is not JSON; use
resp.resultsor parse it into a DataFrame as shown above.
See CONTRIBUTING.md for development, testing, and release instructions.
If you use this package or the mirDIP service in your work, please cite:
- Tokar T, Pastrello C, Rossos AEM, Abovsky M, Hauschild AC, Tsay M, Lu R, Jurisica I. mirDIP 4.1-integrative database of human microRNA target predictions. Nucleic Acids Res. 2018 Jan 4;46(D1):D360-D370. doi: 10.1093/nar/gkx1144. PubMed PMID: 29194489; PubMed Central PMCID: PMC5753284
- Shirdel EA, Xie W, Mak TW, Jurisica I, 2011 NAViGaTing the Micronome. Using Multiple MicroRNA Prediction Databases to Identify Signalling Pathway-Associated MicroRNAs. PLoS ONE 6(2): e17429. doi:10.1371/journal.pone.0017429