
Interpro Database
- 1.3k installs
- 2.6k repo stars
- Updated July 7, 2026
- google-deepmind/science-skills
interpro-database is an agent skill that queries the InterPro biological protein domain database from agent workflows using clean, validated API parameters for developers who need programmatic access to InterPro annotati
About
interpro-database is a Google DeepMind science skill that documents every InterPro REST API query parameter for use inside agent workflows via fetch_interpro_data and get_interpro_count helpers. Parameters follow the official InterPro Swagger specification at interpro7-swagger.yml, including a global page_size int that defaults to 20 with a maximum of 200. The skill notes that page_size=1 combined with get_interpro_count enables rapid bulk aggregations without downloading full result pages. Developers reach for interpro-database when building bioinformatics pipelines, protein annotation tools, or research agents that must query InterPro entries, domains, and families with validated pagination and filter parameters instead of guessing API shapes.
- Comprehensive reference for all InterPro API query parameters based on official Swagger spec
- Global parameters including page_size (max 200) and optimized count retrieval with page_size=1
- Entry-specific filters for protein families, domains, GO terms, annotations and member databases
- Detailed notes on parameter validity, failures, and context-dependent options like group_by
- Ready-to-use parameter dictionary examples for fetch_interpro_data function calls
Interpro Database by the numbers
- 1,257 all-time installs (skills.sh)
- +167 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Ranked #360 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/google-deepmind/science-skills --skill interpro-databaseAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.3k |
|---|---|
| repo stars | ★ 2.6k |
| Security audit | 3 / 3 scanners passed |
| Last updated | July 7, 2026 |
| Repository | google-deepmind/science-skills ↗ |
How do you query InterPro API from code?
Query the InterPro biological database from within an agent workflow using clean, validated parameters.
Who is it for?
Bioinformatics developers building agents or pipelines that need programmatic InterPro protein domain and family annotation lookups.
Skip if: General web developers who need unrelated biological databases like UniProt or PDB without InterPro-specific queries.
When should I use this skill?
The user asks to query InterPro, fetch protein domain annotations, or use InterPro API parameters in an agent workflow.
What you get
Validated InterPro API responses with paginated protein domain annotations and optional bulk count aggregations.
- InterPro API query results
- Bulk count aggregations
- Validated query_params dictionaries
By the numbers
- page_size defaults to 20 with a maximum of 200
- Parameters sourced from InterPro interpro7-swagger.yml specification
Files
InterPro Database Access
Prerequisites
1. `uv`: Read the uv skill and follow its Setup instructions to ensure uv is installed and on PATH. 2. User Notification: If LICENSE_NOTIFICATION.txt does not already exist in this skill directory then (1) prominently notify the user to check the terms at https://www.ebi.ac.uk/interpro/ and https://www.ebi.ac.uk/about/terms-of-use/, then (2) create the file recording the notification text and timestamp.
Overview
InterPro combines signatures from multiple, diverse databases into a single searchable resource, reducing redundancy and helping users interpret their sequence analysis results. By uniting these member databases (e.g., Pfam, CDD, SMART), InterPro capitalises on their individual strengths to produce a powerful diagnostic tool and integrated resource.
Use interpro-database to:
- Identify what domains, families, and sites are found in a particular
protein.
- Identify all proteins that belong to a protein family or contain a
particular domain, even when the names and activities of the proteins are highly variable.
- Examine the species in which a particular protein family or domain is found.
- Annotate genomes with protein family information and Gene Ontology (GO)
terms.
This skill provides a robust utility, interpro_client.py, to interact with the InterPro API seamlessly. It natively handles rate limiting (HTTP 429), background query sleep tracking (HTTP 408), terminal errors (HTTP 404/410), and lazy pagination.
Core Rules
- Use the Wrapper: ALWAYS execute the
scripts/interpro_client.pyhelper
script to query the database rather than accessing the database directly. The scripts automatically enforce fair use and implement retry logic.
- For exploratory queries: ALWAYS use the CLI with a strict
--limit.
This allows you to rapidly understand the data schema without polluting your context window or fetching millions of results.
- Output to file: Use the CLI with --output to output to a file rather
than attempting to print it all to the console. Process the output using jq or code.
- For more complex pipelines import the module natively into your Python
scripts to consume the generator directly, preventing the need to deserialize CLI strings in large workflows.
- Notification: If this skill is used, ensure this is mentioned in the
output.
Examples:
uv run ./scripts/interpro_client.py fetch protein --source_db reviewed --limit 2 --query_params tax_id=9606 --output exploratory_results.jsonlimport sys
sys.path.append('scripts')
from interpro_client import fetch_interpro_data
import itertools
# fetch_interpro_data lazily yields results page-by-page
results = fetch_interpro_data(
endpoint="entry",
source_db="pfam",
query_params={"page_size": 10}
)
for match in itertools.islice(results, 10):
print(match["metadata"]["accession"])4 Ways to Construct Endpoints:
The arguments strictly map to the four common API path constructions. Do not format your own `/` separated strings:
1. `/{endpoint}` (e.g. /entry) uv run ./scripts/interpro_client.py fetch entry --limit 10 --output entries.jsonl 2. `/{endpoint}/{sourceDB}` (e.g. /entry/pfam) uv run ./scripts/interpro_client.py fetch entry --source_db pfam --limit 10 --output pfam_entries.jsonl 3. `/{endpoint}/{sourceDB}/{accession}` (e.g. /entry/pfam/PF00001) uv run ./scripts/interpro_client.py fetch entry --source_db pfam --accession PF00001 --limit 10 --output pf00001_entry.jsonl 4. `/{endpoint}/{sourceDB}/{linked_endpoint}/{sourceDB}/{accession}` (e.g. /entry/interpro/protein/uniprot/P04637) uv run ./scripts/interpro_client.py fetch entry \ --source_db interpro \ --linked_endpoint protein \ --linked_source_db uniprot \ --linked_accession P04637 \ --limit 10 --output p04637_entries.jsonl
Valid Source Databases (--source_db)
Each endpoint only accepts specific source_db values. Using an invalid value returns a 404 error.
- `/entry` (16 values):
interpro,pfam,cathgene3d,ssf,
panther, cdd, profile, smart, ncbifam, prosite, prints, hamap, pirsf, sfld, antifam.
- `/protein` (3 values):
uniprot(all),reviewed(SwissProt),
unreviewed (TrEMBL).
- `/structure` (1 value):
pdb. - `/taxonomy` (1 value):
uniprot. - `/proteome` (1 value):
uniprot. - `/set` (2 values):
pfam,cdd.
Quick Reference / Core Endpoints & Parameters
For a complete, exhaustive list of all query parameters, see the [Full API Reference](references/api_reference.md).
The API is fully open and supports 6 core endpoints. You can combine them using the linked parameters described above. Below is a nested list of the specific query parameters available for each endpoint:
- `/entry` (Domain, family, active site, repeat, or homologous superfamily
entries)
-
integrated: Filter by integrated status (e.g.,pfam). -
type: Filter by type (e.g.,family,domain,
homologous_superfamily).
-
go_term/go_category: Filter by Gene Ontology. -
ida_search/ida_ignore/exact/ordered: Filter by domain
architecture (see IDA Search section).
-
extra_fields: Request additional data (e.g.,countersfor match
coordinates).
-
group_by/sort_by: Aggregate or sort results *(valid values depend
on context, see Full API Reference)*.
- Example: `uv run ./scripts/interpro_client.py count entry --source_db
pfam --query_params type=domain --output count.jsonl`
- `/protein` (Protein records matching entries or domains)
-
tax_id: Filter by taxonomy ID (does not search lineage). -
match_presence: Filter by proteins having InterPro matches
(true/false).
-
is_fragment: Filter complete vs. fragment sequences. -
group_by: Aggregate results (e.g.,taxonomy). -
extra_fields: Request sequence or match details. -
isoforms/residues/structureinfo: Include specific
sub-features.
-
conservation/extra_features: Append residue conservation flags or
Mobidb/coil features (only valid for `/protein/{source_db}/{accession}`).
- Example: `uv run ./scripts/interpro_client.py fetch protein
--source_db uniprot --limit 20 --query_params tax_id=9606 --output human_proteins.jsonl`
- `/structure` (PDB structures linked to InterPro entries)
-
experiment_type: Filter by experimental method (e.g., `X-RAY
DIFFRACTION`).
-
resolution: Filter by resolution limit. -
extra_fields: Include additional structural metadata. -
group_by: Aggregate results. - Example: `./scripts/interpro_client.py fetch structure --source_db pdb
--accession 1ATP --limit 10 --output 1atp_structures.jsonl`
- `/taxonomy` (Taxonomy distribution nodes)
-
key_species: Filter to limit to key species. -
with_names: Include scientific names. -
filter_by_entry/filter_by_entry_db: Filter intersection with
specific entries.
-
extra_fields: Additional taxonomic metadata. - Example: `./scripts/interpro_client.py fetch taxonomy --source_db
uniprot --accession 9606 --limit 10 --output human_taxonomy.jsonl`
- `/proteome` (Complete proteomes linked to InterPro)
-
extra_fields: General query expansion. - Example: `uv run ./scripts/interpro_client.py fetch proteome
--source_db uniprot --accession UP000005640 --limit 10 --output proteome.jsonl`
- `/set` (Curated sets of related entries, e.g., Pfam clans)
-
extra_fields: Additional metadata *(only valid for
/set/{sourceDB})*.
- Example: `uv run ./scripts/interpro_client.py fetch set --source_db
pfam --accession CL0001 --limit 10 --output pfam_clan.jsonl`
InterPro Domain Architecture (IDA) Search
InterPro provides powerful tools for searching proteins by their domain architecture (the exact combination and order of domains). Because the API does not allow querying proteins directly by multiple domains at once (e.g., "give me proteins with PF00069 AND PF00017"), finding proteins with specific domain combinations requires a two-step process.
Step 1: Find matching architectures (ida_search)
The ida_search parameter is used on the root /entry endpoint to find all Domain Architectures (IDAs) containing the domains you specify.
- Constraints:
- Valid ONLY on the root
/entryendpoint. - Cannot be combined with non-IDA parameters.
- Modifiers (Only valid with
ida_search): -
ida_ignore: Ignores the given domains in the search (query param). -
ordered: Ensures domains appear in the exact specified order (flag). -
exact: Ensures the architecture matches exactly (no additional
domains) (flag). Requires `ordered` flag to be present.
Example: Find architectures containing both a kinase domain (PF00069) and an SH2 domain (PF00017), in that exact order:
uv run scripts/interpro_client.py fetch entry
--query_params ida_search=PF00069,PF00017
--flags ordered exact
--output architectures.jsonlNote: This returns the architectures and their unique `ida_id`s, not all individual proteins.
Step 2: Fetch proteins for those architectures (ida)
Once you have the ida_ids (e.g., 619edbb...) from Step 1, you can fetch all the actual proteins that share that precise layout by filtering the /protein endpoint.
Constraints:
- Valid on
/proteinand/entry/{sourceDB}/{accession}endpoints.
Example: Fetch proteins matching one of the architecture IDs from Step 1:
uv run scripts/interpro_client.py fetch protein
--source_db uniprot
--query_params ida=619edbb2b445bfa3ad51bd894e3c115b025a5f25
--output matching_proteins.jsonl(When building pipelines or querying comprehensively, you would loop through all the `ida_id`s from Step 1 and run Step 2 for each one).
InterPro Entry Types
Each InterPro entry is assigned a type indicating what you can infer when a protein matches the entry:
- Domain: Distinct functional, structural or sequence units that may exist
in a variety of biological contexts. Example: PH domain or classical C2H2 zinc finger.
- Family: A group of proteins sharing a common evolutionary origin
reflected by related functions, sequence similarities, or primary/secondary/tertiary structures.
- Homologous Superfamily: Proteins sharing an evolutionary origin
reflected by structural similarity but often displaying very low sequence similarity. Usually comprises signatures from the SUPERFAMILY and CATH-Gene3D databases.
- Repeat: A short sequence that is typically repeated within a protein,
often <50 amino acids long. Example: Leucine Rich Repeats or WD40 repeats.
- Site: Includes
Active site(sequence containing conserved residues for
catalytic activity) and Binding site (sequence containing conserved residues forming a protein interaction site).
InterPro-N Predictions
InterPro-N is a deep-learning-based extension of the standard InterPro database. It utilizes an AI architecture inspired by computer vision to treat protein sequence annotation as a "panoptic segmentation" task, labeling residues and distinguishing between domains.
When to use InterPro-N
Standard InterPro signatures are the "gold standard" and should not be discarded in favor of InterPro-N predictions. Use InterPro-N primarily to fill in gaps or refine results.
In addition to standard InterPro:
- Analyzing "Dark Matter" (Uncharacterised Proteins): Use when a protein
returns no hits in standard InterPro. InterPro-N excels at identifying remote homologs.
- Resolving Complex Repeats: Use for proteins with multiple tandem repeats
(e.g., TPR or WD40) where standard HMMs might merge or miss them.
- Predicting Discontinuous Domains: Use when a domain sequence is
interrupted by a completely different inserted sequence.
Instead of standard InterPro (specific scenarios):
- Precise Boundary Delineation: When you need more accurate start-and-stop
coordinates for a domain than fuzzy standard hits provide.
- Large-Scale Metagenomic Screening: For initial high-recovery screening
of fragmented or highly divergent sequences.
Fallback Strategy: Checking InterPro-N
When you are asked to find annotations for a protein and standard InterPro queries return no results or no annotations, you MUST check InterPro-N as a fallback.
Example Scenario: If a user asks to "List the SSF annotations for protein X" and the standard query returns no hits, you should retry the query with the interpro_n flag.
This fallback is crucial because InterPro-N can identify remote homologs and domains in "dark matter" proteins that standard methods miss.
If found, ALWAYS report to the user that these annotations are deep learning predictions from InterPro-N.
How to Use
InterPro-N predictions are accessed by passing the interpro_n flag to the protein endpoint with uniprot as the source database.
Via CLI:
uv run ./scripts/interpro_client.py fetch protein
--source_db uniprot
--accession A0A096LNN2
--flags interpro_n
--output A0A096LNN2_interpro_n.jsonlVia Python Pipeline:
results = fetch_interpro_data(
endpoint="protein",
source_db="uniprot",
accession="A0A096LNN2",
flags=["interpro_n"])Strict Lookup Rules
1. Always Use UniProt Accessions, NEVER Gene Names: When looking up proteins in InterPro, you MUST use their UniProt Accessions (e.g. P04637). InterPro does not natively support or reliably map gene names (e.g. TP53). If the user provides a gene name, you must use a database like Ensembl or UniProt first to resolve it to an accession.
2. NEVER Iterate to Count: When asked for an aggregate count (e.g., "How many domains are there?"), you MUST read the count field from the initial API JSON response using the get_interpro_count() helper. NEVER iterate over the fetch_interpro_data generator to tally elements. Iterating over an endpoint with 50,000+ entries just to count them silently hangs the agent and abuses the API. Every time. No exceptions.
✅ Correct:
Via CLI:
uv run ./scripts/interpro_client.py count entry
--source_db interpro
--query_params type=domain
--output count.jsonVia Python Pipeline:
from interpro_client import get_interpro_count
cnt = get_interpro_count(
endpoint="entry",
source_db="interpro",
query_params={"type": "domain"},
)❌ Wrong (Iterating over fetch):
# NEVER DO THIS:
uv run ./scripts/interpro_client.py fetch entry
--source_db interpro
--query_params type=domain
--output output.jsonl
&& wc -l output.jsonlQuick examples
For detailed examples of the invocations and JSON output schemas returned by various endpoints, see the [Example Responses Reference](references/example_responses.tsv). This TSV contains command-line calls, Python equivalents, and the corresponding JSON payload structures.
1. Determining all protein domains
# Fetches InterPro Entries within UniProt protein P04637
# URL equivalent: /entry/interpro/protein/uniprot/P04637
uv run ./scripts/interpro_client.py fetch entry
--source_db interpro
--linked_endpoint protein
--linked_source_db uniprot
--linked_accession P04637
--output p04637_domains.jsonl2. Fetching all PDB structures for an Entry
# URL equivalent: /structure/pdb/entry/interpro/IPR011615
# Only fetch the first 5 structures
uv run ./scripts/interpro_client.py fetch structure
--source_db pdb
--linked_endpoint entry
--linked_source_db interpro
--linked_accession IPR011615
--output ipr011615_structures.jsonlInterPro API Query Parameters Reference
This document provides a comprehensive list of all query parameters available for the InterPro API endpoints, based on the official InterPro Swagger documentation (https://www.ebi.ac.uk/interpro/api/static_files/interpro7-swagger.yml) These parameters can be passed into the query_params dictionary in fetch_interpro_data.
Global Parameters
Available on all endpoints.
-
page_size: (int) Number of results per page (typically defaults to 20,
max is 200). Use page_size=1 with get_interpro_count for rapid bulk aggregations without downloading pages.
--------------------------------------------------------------------------------
1. /entry Parameters
For exploring protein entries (genes, domains, families, repeats).
General Filters
-
type: (str) Filter by entry type (e.g.,family,domain,
active_site, binding_site, conserved_site, ptms, repeat, homologous_superfamily).
-
integrated: (str) Comma-separated list of Member Databases (e.g.,
pfam, smart) to filter integrated status. (Fails if source_db=interpro)
-
go_term: (str) Filter by exact Gene Ontology term (e.g.,GO:0016301). -
annotation: (str) Filter by annotation type (logo,alignment,
hmm). (Works only when `source_db` is a member database).
-
group_by: (str) Aggregation method. *Note: Valid values depend on the
context!*
-
/entry(and/entry/integrated,/entry/unintegrated,/entry/all):
type, source_database, tax_id, go_terms.
-
/entry/interpro:type,tax_id,source_database,
member_databases, go_terms, go_categories.
-
/entry/{sourceDB}:type,tax_id,source_database,go_terms,
go_categories.
-
sort_by: (str) Sort criteria (e.g.,accession,name). -
interpro_status: (str) Value"interpro_status"counts how many entries
are integrated and how many are not. (Fails unless sourceDB is a member Database).
-
ida: (str) Included architectures strings. -
extra_fields: (str) Include additional data (e.g.,counters,
entry_id, short_name, description, wikipedia, literature, hierarchy, cross_references, entry_date, is_featured, overlaps_with). (Only available for `/entry/{sourceDB}` and `/entry/{sourceDB}/{accession}`).
InterPro-Specific (source_db="interpro")
-
go_category: (str) Filter by top-level GO (biological_process,
molecular_function, cellular_component).
-
signature_in: (str) Filter to entries matching a given member database. -
latest_entries: (str) Pass"latest_entries"to filter for entries
modified in the most recent release.
-
interactions: (str) Pass"interactions"to limit to entries with known
structural interactions.
-
pathways: (str) Pass"pathways"to filter for entries linked to
pathway datasets.
-
has_model: (str) Pass"has_model"to filter for entries with
structural models.
Source-DB Specific
-
subfamilies/subfamily: (str) Filter specifically against Panther
subfamilies. (Fails unless `source_db="panther"`).
-
model: (str) Included models frominterproorpfam.
IDA (Domain Architecture) Search
(Can ONLY be used on the root `/entry` endpoint. Invalidates aggregations).
-
ida_search: (str) Comma-separated list of domain accessions (InterPro or
Pfam) to find architectures containing them.
-
ida_ignore: (str) Architectures to ignore. (Requires `ida_search`). -
ordered: (str) Pass"ordered"to mandate domains appear sequentially.
(Requires `ida_search`).
-
exact: (str) Pass"exact"to mandate exact composition (no surplus
domains). (Requires `ida_search` and `ordered`).
--------------------------------------------------------------------------------
2. /protein Parameters
For finding proteins matching specific entries or properties.
-
tax_id: (str) Filter by NCBI Taxonomy ID (e.g.,9606for Human). Does
not automatically resolve lineage.
-
match_presence: (str)"true"or"false". Filters proteins
definitively known to have (or lack) InterPro matches.
-
is_fragment: (str)"true"(fragmented sequences) or"false"
(complete sequences).
-
protein_evidence: (str) Filter proteins by existence evidence level
(e.g., protein, transcript).
-
ida: (str) Used only to retrieve architectures alongside a protein or
/entry/{db}/{accession} call. Not used for filtering.
-
id: (str) Protein primary accession/ID. -
go_term: (str) Filter by specific Gene Ontology term. -
conservation: (str) Appends residue conservation flags. *(Only available
for /protein/{source_db}/{accession} endpoints).*
-
isoforms: (str) Included isoforms in output. -
extra_fields: (str) Include additional data (e.g.,counters,
identifier, description, sequence, gene, go_terms, evidence_code, residues, tax_id, proteome, extra_features, structure, is_fragment, ida_id, ida). (Only available for `/protein/{sourceDB}` and `/protein/{sourceDB}/{accession}`).
-
extra_features: (str) Gets a JSON containing additional features (e.g.,
mobidb, coil, etc.) of the selected protein. (Only available for `/protein/{source_db}/{accession}` endpoints).
-
residues/structureinfo: (str) Append sequence residue flags or
linked structural data.
-
group_by: (str) Aggregation method (e.g.,taxonomy).
--------------------------------------------------------------------------------
3. /structure Parameters
For PDB structures linked to InterPro entries.
-
experiment_type: (str) Filter by the experimental method (e.g., `"X-RAY
DIFFRACTION", "NMR", "ELECTRON MICROSCOPY"`).
-
resolution: (str) Filter by resolution limit limit (e.g.,<=2.0). -
group_by: (str) Aggregation method. -
extra_fields: (str) Include additional data (e.g.,release_date,
literature, chains, secondary_structures, counters). (Only available for `/structure/{sourceDB}` and `/structure/{sourceDB}/{accession}`).
--------------------------------------------------------------------------------
4. /taxonomy Parameters
For phylogenetic breakdowns and nodes.
-
key_species: (str)"true"or"false". Limits distribution to major
model organisms.
-
with_names: (str)"true"or"false". Includes full scientific names
rather than just node logic. (Cannot combine with cross-filters below).
-
filter_by_entry: (str) Limits taxonomic nodes strictly to those
containing a given accession.
-
filter_by_entry_db: (str) Limits nodes to those intersecting with a
specific member DB.
-
extra_fields: (str) Include additional data (e.g.,counters,
scientific_name, full_name, lineage, rank). (Only available for `/taxonomy/{sourceDB}`).
--------------------------------------------------------------------------------
5. /proteome Parameters
For specific, whole-proteome breakdowns.
-
is_reference: (str)"true"or"false". Filter specifically for
UniProt Reference Proteomes.
-
group_by: (str) Aggregation method. -
extra_fields: (str) Include additional data (e.g.,counters,strain,
assembly). (Only available for `/proteome/{sourceDB}`).
--------------------------------------------------------------------------------
6. /set Parameters
For curated entry clans (like Pfam clans).
-
extra_fields: (str) Include additional data (e.g.,counters,
description, relationships). (Only available for `/set/{sourceDB}`).
cli_command python_call response
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params page_size=1 next(fetch_interpro_data(endpoint='entry', query_params={'page_size': 1}, limit=1), None) {"entries": {"member_databases": {"pfam": 27208, "cathgene3d": 6566, "ssf": 2019, "panther": 15912, "cdd": 19760, "profile": 1399, "smart": 1322, "ncbifam": 33921, "prosite": 1311, "prints": 2106, "hamap": 2391, "pirsf": 3292, "sfld": 303, "antifam": 278}, "integrated": 65333, "unintegrated": 53354, "interpro": 51897, "all": 171069}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params search=kinase next(fetch_interpro_data(endpoint='entry', query_params={'search': 'kinase'}, limit=1), None) {"entries": {"member_databases": {"pfam": 27208, "cathgene3d": 6566, "ssf": 2019, "panther": 15912, "cdd": 19760, "profile": 1399, "smart": 1322, "ncbifam": 33921, "prosite": 1311, "prints": 2106, "hamap": 2391, "pirsf": 3292, "sfld": 303, "antifam": 278}, "integrated": 65333, "unintegrated": 53354, "interpro": 51897, "all": 171069}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params extra_fields=counters next(fetch_interpro_data(endpoint='entry', query_params={'extra_fields': 'counters'}, limit=1), None) {"entries": {"member_databases": {"pfam": 27208, "cathgene3d": 6566, "ssf": 2019, "panther": 15912, "cdd": 19760, "profile": 1399, "smart": 1322, "ncbifam": 33921, "prosite": 1311, "prints": 2106, "hamap": 2391, "pirsf": 3292, "sfld": 303, "antifam": 278}, "integrated": 65333, "unintegrated": 53354, "interpro": 51897, "all": 171069}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params type=family next(fetch_interpro_data(endpoint='entry', query_params={'type': 'family'}, limit=1), None) {"entries": {"member_databases": {"panther": 15912, "pfam": 12025, "ncbifam": 22958, "prints": 2013, "hamap": 2391, "pirsf": 3292, "sfld": 303}, "integrated": 36793, "unintegrated": 21908, "interpro": 27283, "all": 86549}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params integrated=pfam next(fetch_interpro_data(endpoint='entry', query_params={'integrated': 'pfam'}, limit=1), None) []
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params go_term=GO:0016301 next(fetch_interpro_data(endpoint='entry', query_params={'go_term': 'GO:0016301'}, limit=1), None) {"entries": {"member_databases": {"pfam": 27208, "cathgene3d": 6566, "ssf": 2019, "panther": 15912, "cdd": 19760, "profile": 1399, "smart": 1322, "ncbifam": 33921, "prosite": 1311, "prints": 2106, "hamap": 2391, "pirsf": 3292, "sfld": 303, "antifam": 278}, "integrated": 65333, "unintegrated": 53354, "interpro": 51897, "all": 171069}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params sort_by=accession next(fetch_interpro_data(endpoint='entry', query_params={'sort_by': 'accession'}, limit=1), None) 404 Not Found: The request is incorrect. URL: https://www.ebi.ac.uk/interpro/api/entry | Response Body: {"Error":"aggregations"}
uv run scripts/interpro_client.py fetch entry --limit 1 --source_db interpro --query_params go_category=molecular_function next(fetch_interpro_data(endpoint='entry', source_db='interpro', query_params={'go_category': 'molecular_function'}, limit=1), None) []
uv run scripts/interpro_client.py fetch entry --limit 1 --source_db interpro --query_params signature_in=pfam next(fetch_interpro_data(endpoint='entry', source_db='interpro', query_params={'signature_in': 'pfam'}, limit=1), None) {"metadata": {"accession": "IPR000001", "name": "Kringle", "source_database": "interpro", "type": "domain", "integrated": null, "member_databases": {"cdd": {"cd00108": "KR"}, "profile": {"PS50070": "Kringle domain profile"}, "pfam": {"PF00051": "Kringle domain"}, "smart": {"SM00130": "Kringle domain"}}, "go_terms": null}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params ida_search=IPR000001 next(fetch_interpro_data(endpoint='entry', query_params={'ida_search': 'IPR000001'}, limit=1), None) {"ida": "PF00024:IPR003609-PF00051:IPR000001-PF00051:IPR000001-PF00051:IPR000001-PF00051:IPR000001-PF00089:IPR001254", "ida_id": "6f24219b752ec39e33f815c725cb83832c3ebaa8", "representative": {"accession": "P17945", "length": 728, "domains": [{"accession": "PF00024", "name": "PAN_1", "coordinates": [{"fragments": [{"start": 43, "end": 124}]}]}, {"accession": "IPR003609", "name": "Pan_app", "coordinates": [{"fragments": [{"start": 43, "end": 124}]}]}, {"accession": "PF00051", "name": "Kringle", "coordinates": [{"fragments": [{"start": 129, "end": 207}]}]}, {"accession": "IPR000001", "name": "Kringle", "coordinates": [{"fragments": [{"start": 129, "end": 207}]}]}, {"accession": "PF00051", "name": "Kringle", "coordinates": [{"fragments": [{"start": 212, "end": 289}]}]}, {"accession": "IPR000001", "name": "Kringle", "coordinates": [{"fragments": [{"start": 212, "end": 289}]}]}, {"accession": "PF00051", "name": "Kringle", "coordinates": [{"fragments": [{"start": 306, "end": 384}]}]}, {"accession": "IPR000001", "name": "Kringle", "coordinates": [{"fragments": [{"start": 306, "end": 384}]}]}, {"accession": "PF00051", "name": "Kringle", "coordinates": [{"fragments": [{"start": 392, "end": 470}]}]}, {"accession": "IPR000001", "name": "Kringle", "coordinates": [{"fragments": [{"start": 392, "end": 470}]}]}, {"accession": "PF00089", "name": "Trypsin", "coordinates": [{"fragments": [{"start": 497, "end": 719}]}]}, {"accession": "IPR001254", "name": "Trypsin_dom", "coordinates": [{"fragments": [{"start": 497, "end": 719}]}]}]}, "unique_proteins": 1907}
uv run scripts/interpro_client.py fetch protein --limit 1 --query_params tax_id=9606 next(fetch_interpro_data(endpoint='protein', query_params={'tax_id': '9606'}, limit=1), None) {"proteins": {"reviewed": 20632, "unreviewed": 185527, "uniprot": 205321}}
uv run scripts/interpro_client.py fetch protein --limit 1 --source_db uniprot --accession A0A0C5B5G6 --query_params conservation=true next(fetch_interpro_data(endpoint='protein', source_db='uniprot', accession='A0A0C5B5G6', query_params={'conservation': 'true'}, limit=1), None) {"sequence": "MRWQEMGYIFYPRKLR", "true": {"entries": {}}}
uv run scripts/interpro_client.py fetch protein --limit 1 --source_db uniprot --accession A0A0C5B5G6 --query_params extra_features=mobidb next(fetch_interpro_data(endpoint='protein', source_db='uniprot', accession='A0A0C5B5G6', query_params={'extra_features': 'mobidb'}, limit=1), None) {}
uv run scripts/interpro_client.py fetch structure --limit 1 --query_params experiment_type=NMR next(fetch_interpro_data(endpoint='structure', query_params={'experiment_type': 'NMR'}, limit=1), None) {"structures": {"pdb": 12328}}
uv run scripts/interpro_client.py fetch structure --limit 1 --query_params resolution=<=2.0 next(fetch_interpro_data(endpoint='structure', query_params={'resolution': '<=2.0'}, limit=1), None) {"structures": {"pdb": 237068}}
uv run scripts/interpro_client.py fetch taxonomy --limit 1 --query_params with_names=true next(fetch_interpro_data(endpoint='taxonomy', query_params={'with_names': 'true'}, limit=1), None) {"taxa": {"uniprot": 2678841}}
uv run scripts/interpro_client.py fetch taxonomy --limit 1 --query_params filter_by_entry=IPR000001 next(fetch_interpro_data(endpoint='taxonomy', query_params={'filter_by_entry': 'IPR000001'}, limit=1), None) {"taxa": {"uniprot": 2678841}}
uv run scripts/interpro_client.py fetch taxonomy --limit 1 --query_params filter_by_entry_db=pfam next(fetch_interpro_data(endpoint='taxonomy', query_params={'filter_by_entry_db': 'pfam'}, limit=1), None) {"taxa": {"uniprot": 2678841}}
uv run scripts/interpro_client.py fetch taxonomy --limit 1 --query_params with_names=true filter_by_entry=IPR000001 next(fetch_interpro_data(endpoint='taxonomy', query_params={'with_names': 'true', 'filter_by_entry': 'IPR000001'}, limit=1), None) {"taxa": {"uniprot": 2678841}}
uv run scripts/interpro_client.py fetch proteome --limit 1 --query_params is_reference=true next(fetch_interpro_data(endpoint='proteome', query_params={'is_reference': 'true'}, limit=1), None) {"proteomes": {"uniprot": 34194}}
uv run scripts/interpro_client.py fetch set --limit 1 --source_db pfam --query_params extra_fields=counters next(fetch_interpro_data(endpoint='set', source_db='pfam', query_params={'extra_fields': 'counters'}, limit=1), None) {"metadata": {"accession": "CL0001", "name": "EGF", "source_database": "pfam"}, "extra_fields": {"counters": {"domain_architectures": 67254, "entries": {"pfam": 49, "total": 49}, "proteins": 808166, "proteomes": 2472, "structures": 1164, "taxa": 5767}}}
uv run scripts/interpro_client.py fetch entry --limit 1 --query_params ida_search=PF00069,PF00017 --flags ordered next(fetch_interpro_data(endpoint='entry', query_params={'ida_search': 'PF00069,PF00017'}, flags=['ordered'], limit=1), None) {"ida": "PF00069-PF00017", "ida_id": "dummy_ida_id", "representative": {"accession": "P00519", "length": 1130, "domains": []}, "unique_proteins": 42}
uv run scripts/interpro_client.py fetch protein --limit 1 --source_db uniprot --accession A0A096LNN2 --flags interpro_n next(fetch_interpro_data(endpoint='protein', source_db='uniprot', accession='A0A096LNN2', flags=['interpro_n'], limit=1), None) {"G3DSA:1.10.630.10": {"accession": "G3DSA:1.10.630.10", "name": "Cytochrome P450", "type": "homologous_superfamily", "short_name": null, "source_database": "cathgene3d", "integrated": {"accession": "IPR036396", "name": "Cytochrome P450 superfamily", "short_name": "Cyt_P450_sf", "source_database": "interpro", "type": "homologous_superfamily", "member_databases": {"cathgene3d": {"G3DSA:1.10.630.10": "Cytochrome P450"}, "ssf": {"SSF48264": "Cytochrome P450"}}, "go_terms": [{"identifier": "GO:0004497", "name": "monooxygenase activity", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0005506", "name": "iron ion binding", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0016705", "name": "oxidoreductase activity, acting on paired donors, with incorporation or reduction of molecular oxygen", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0020037", "name": "heme binding", "category": {"code": "F", "name": "molecular_function"}}]}, "entry_protein_locations": [{"fragments": [{"start": 1, "end": 90, "dc-status": "CONTINUOUS"}], "representative": true, "model": "G3DSA:1.10.630.10", "score": 0.996}], "in_interpro": true, "is_preferred": true}, "PF00067": {"accession": "PF00067", "name": "Cytochrome P450", "type": "domain", "short_name": "p450", "source_database": "pfam", "integrated": {"accession": "IPR001128", "name": "Cytochrome P450", "short_name": "Cyt_P450", "source_database": "interpro", "type": "family", "member_databases": {"pfam": {"PF00067": "Cytochrome P450"}, "prints": {"PR00385": "P450"}}, "go_terms": [{"identifier": "GO:0004497", "name": "monooxygenase activity", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0005506", "name": "iron ion binding", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0016705", "name": "oxidoreductase activity, acting on paired donors, with incorporation or reduction of molecular oxygen", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0020037", "name": "heme binding", "category": {"code": "F", "name": "molecular_function"}}]}, "entry_protein_locations": [{"fragments": [{"start": 2, "end": 68, "dc-status": "CONTINUOUS"}], "representative": false, "model": "PF00067", "score": 1.0}], "in_interpro": false, "is_preferred": true}, "SSF48264": {"accession": "SSF48264", "name": "Cytochrome P450", "type": "homologous_superfamily", "short_name": null, "source_database": "ssf", "integrated": {"accession": "IPR036396", "name": "Cytochrome P450 superfamily", "short_name": "Cyt_P450_sf", "source_database": "interpro", "type": "homologous_superfamily", "member_databases": {"cathgene3d": {"G3DSA:1.10.630.10": "Cytochrome P450"}, "ssf": {"SSF48264": "Cytochrome P450"}}, "go_terms": [{"identifier": "GO:0004497", "name": "monooxygenase activity", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0005506", "name": "iron ion binding", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0016705", "name": "oxidoreductase activity, acting on paired donors, with incorporation or reduction of molecular oxygen", "category": {"code": "F", "name": "molecular_function"}}, {"identifier": "GO:0020037", "name": "heme binding", "category": {"code": "F", "name": "molecular_function"}}]}, "entry_protein_locations": [{"fragments": [{"start": 2, "end": 74, "dc-status": "CONTINUOUS"}], "representative": false, "model": "SSF48264", "score": 1.0}], "in_interpro": true, "is_preferred": true}, "PTHR24286": {"accession": "PTHR24286", "name": "Cytochrome P450 monooxygenases", "type": "family", "short_name": "Cytochrome_P450_monoxygenases", "source_database": "panther", "integrated": null, "entry_protein_locations": [{"fragments": [{"start": 2, "end": 70, "dc-status": "CONTINUOUS"}], "representative": true, "model": "PTHR24286", "score": 0.821}], "in_interpro": true, "is_preferred": true}}
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""InterPro API client for fetching data with pagination and backoff."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "scienceskillscommon",
# ]
# [tool.uv.sources]
# scienceskillscommon = { path = "../../scienceskillscommon" }
# ///
from __future__ import annotations
import argparse
from collections.abc import Iterator
import json
import sys
import time
from typing import Any
import urllib.parse
from science_skills.skills.scienceskillscommon import http_client
BASE_URL = "https://www.ebi.ac.uk/interpro/api/"
DEFAULT_PAGE_SIZE = 200
CLIENT = http_client.HttpClient(BASE_URL, qps=2.0)
def build_interpro_url(
endpoint: str,
source_db: str | None = None,
accession: str | None = None,
linked_endpoint: str | None = None,
linked_source_db: str | None = None,
linked_accession: str | None = None,
) -> str:
"""Constructs a full InterPro API URL from an endpoint path.
If endpoint starts with 'http', it assumes it's a full URL and returns it.
Otherwise, it builds the canonical InterPro path:
`/{endpoint}/{source_db}/{accession}/{linked_endpoint}/{linked_source_db}/{linked_accession}`
Args:
endpoint: The API endpoint (e.g., 'entry' or 'protein').
source_db: The source database (e.g., 'interpro' or 'uniprot').
accession: The specific accession (e.g., 'IPR0001').
linked_endpoint: A secondary endpoint to link entities.
linked_source_db: The database of the linked entity.
linked_accession: The accession of the linked entity.
Returns:
The full URL to fetch.
"""
if source_db and not endpoint:
raise ValueError(
"Invalid arguments: 'source_db' is set but 'endpoint' is missing. "
"An 'endpoint' is required when specifying a 'source_db'."
)
if linked_source_db and not linked_endpoint:
raise ValueError(
"Invalid arguments: 'linked_source_db' is set but 'linked_endpoint' "
"is missing. A 'linked_endpoint' is required when specifying a "
"'linked_source_db'."
)
if accession and not source_db:
raise ValueError(
"Invalid arguments: 'accession' is set but 'source_db' is missing. "
"A 'source_db' is required when specifying an 'accession'."
)
if linked_accession and not linked_source_db:
raise ValueError(
"Invalid arguments: 'linked_accession' is set but 'linked_source_db' "
"is missing. A 'linked_source_db' is required when specifying a "
"'linked_accession'."
)
if endpoint and endpoint.startswith("http"):
return endpoint
parts = [endpoint.strip("/")]
for part in [
source_db,
accession,
linked_endpoint,
linked_source_db,
linked_accession,
]:
if part:
parts.append(part.strip("/"))
path = "/".join(parts)
return urllib.parse.urljoin(BASE_URL, path)
def _safe_fetch(
url: str, max_minutes_to_wait: int = 5
) -> dict[str, Any] | None:
"""Fetch JSON and handle HTTP 408 Background Task Timeout gracefully."""
headers = {"Accept": "application/json"}
retries_408 = 0
while True:
try:
resp = CLIENT.fetch(url, headers=headers)
if resp.status_code == 204:
return None
return resp.json()
except http_client.HttpError as e:
if e.status_code == 408 and retries_408 < max_minutes_to_wait:
print("Query is running in the background. Waiting for 1 minute...")
time.sleep(60)
retries_408 += 1
continue
raise
def get_interpro_count(
endpoint: str,
source_db: str | None = None,
accession: str | None = None,
linked_endpoint: str | None = None,
linked_source_db: str | None = None,
linked_accession: str | None = None,
query_params: dict[str, Any] | None = None,
flags: list[str] | None = None,
max_minutes_to_wait_for_background_task: int = 5,
) -> int:
"""Fetches the total count of items matching the query without downloading them.
Args:
endpoint: The API endpoint (e.g., 'entry' or 'protein').
source_db: The source database (e.g., 'interpro' or 'uniprot').
accession: The specific accession (e.g., 'IPR0001').
linked_endpoint: A secondary endpoint to link entities.
linked_source_db: The database of the linked entity.
linked_accession: The accession of the linked entity.
query_params: Optional dictionary of query string parameters.
flags: Optional list of boolean flags.
max_minutes_to_wait_for_background_task: Maximum minutes to wait for
background queries (HTTP 408).
Returns:
The integer count of matching items.
"""
url = build_interpro_url(
endpoint=endpoint,
source_db=source_db,
accession=accession,
linked_endpoint=linked_endpoint,
linked_source_db=linked_source_db,
linked_accession=linked_accession,
)
params_list = []
if query_params:
for k, v in query_params.items():
params_list.append(f"{k}={urllib.parse.quote_plus(v)}")
if flags:
for flag in flags:
params_list.append(flag)
# Ensure page_size=1 is included, but only if not already specified.
if not any(p.startswith("page_size=") for p in params_list):
params_list.append("page_size=1")
query_string = "&".join(params_list)
full_url = f"{url}?{query_string}" if query_string else url
data = _safe_fetch(full_url, max_minutes_to_wait_for_background_task)
if data is None:
return 0
return data.get("count", 0)
def fetch_interpro_data(
endpoint: str,
source_db: str | None = None,
accession: str | None = None,
linked_endpoint: str | None = None,
linked_source_db: str | None = None,
linked_accession: str | None = None,
query_params: dict[str, Any] | None = None,
flags: list[str] | None = None,
limit: int | None = None,
max_minutes_to_wait_for_background_task: int = 5,
) -> Iterator[dict[str, Any]]:
"""Fetches data from the InterPro REST API.
This function dynamically yields items as the iterator progresses, fetching
subsequent pages only when necessary (lazy evaluation). This prevents
downloading the entire dataset and allows you to fetch just the "first 100
items" instantly using `itertools.islice()` or breaking early from a loop.
Handles single-item responses and paginated list responses gracefully.
Employs exponential back-off for HTTP 429 and 50x errors.
Args:
endpoint: The API endpoint (e.g., 'entry' or 'protein').
source_db: The source database (e.g., 'interpro' or 'uniprot').
accession: The specific accession (e.g., 'IPR0001').
linked_endpoint: A secondary endpoint to link entities.
linked_source_db: The database of the linked entity.
linked_accession: The accession of the linked entity.
query_params: Optional dictionary of query string parameters.
flags: Optional list of boolean flags.
limit: Optional limit on the number of items to fetch, cannot exceed
DEFAULT_PAGE_SIZE.
max_minutes_to_wait_for_background_task: Maximum minutes to wait for
background queries (HTTP 408).
Yields:
Individual data objects (dictionaries) from the API.
"""
current_url = build_interpro_url(
endpoint=endpoint,
source_db=source_db,
accession=accession,
linked_endpoint=linked_endpoint,
linked_source_db=linked_source_db,
linked_accession=linked_accession,
)
params_list = []
if query_params:
for k, v in query_params.items():
params_list.append(f"{k}={urllib.parse.quote_plus(v)}")
if flags:
for flag in flags:
params_list.append(flag)
# Add page_size
if not any(p.startswith("page_size=") for p in params_list):
ps = min(limit or DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE)
params_list.append(f"page_size={ps}")
query_string = "&".join(params_list)
if query_string:
current_url += f"?{query_string}"
fetched_count = 0
while current_url:
data = _safe_fetch(current_url, max_minutes_to_wait_for_background_task)
if data is None:
break
# If the response is a paginated list
if "results" in data and isinstance(data["results"], list):
total_count = data.get("count")
for item in data["results"]:
yield item
fetched_count += 1
if limit is not None and fetched_count >= limit:
return
# Update current_url for the next iteration (lazy loading)
current_url = data.get("next")
# Print progress if we have to fetch another page
if current_url:
if limit is not None and total_count is not None:
total_display = min(limit, total_count)
elif limit is not None:
total_display = limit
elif total_count is not None:
total_display = total_count
else:
total_display = "unknown"
print(
f"Progress: retrieved {fetched_count} / {total_display}",
file=sys.stderr,
)
# Single item response
else:
yield data
fetched_count += 1
current_url = None
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="InterPro API CLI Interface")
# Action commands
subparsers = parser.add_subparsers(dest="command", required=True)
fetch_parser = subparsers.add_parser(
"fetch", help="Fetch data from InterPro API"
)
fetch_parser.add_argument(
"endpoint",
help="The primary API endpoint (e.g., 'entry', 'protein', 'structure')",
)
fetch_parser.add_argument(
"--limit",
type=int,
help="Limit the number of results to fetch (highly recommended)",
default=None,
)
fetch_parser.add_argument(
"--output",
required=True,
help="Output file to write the JSON lines to",
)
# Optional path arguments
fetch_parser.add_argument(
"--source_db",
help="Source database (e.g., 'interpro', 'pfam', 'uniprot')",
default=None,
)
fetch_parser.add_argument(
"--accession", help="Specific accession (e.g., 'IPR0001')", default=None
)
fetch_parser.add_argument(
"--linked_endpoint",
help="Secondary endpoint to link entities",
default=None,
)
fetch_parser.add_argument(
"--linked_source_db", help="Database of the linked entity", default=None
)
fetch_parser.add_argument(
"--linked_accession", help="Accession of the linked entity", default=None
)
# Dynamic query parameters
fetch_parser.add_argument(
"--query_params",
nargs="*",
help=(
"Query parameters as key=value pairs (e.g., tax_id=9606"
" is_fragment=true). All parameters must include '='."
),
default=None,
)
fetch_parser.add_argument(
"--flags",
nargs="*",
help="Boolean flags (e.g., ordered exact)",
default=None,
)
fetch_parser.add_argument(
"--max_minutes_to_wait_for_background_task",
type=int,
help="Maximum minutes to wait for background queries (HTTP 408)",
default=5,
)
count_parser = subparsers.add_parser(
"count",
help="Get the total count of results without downloading them",
)
count_parser.add_argument(
"endpoint",
help="The primary API endpoint (e.g., 'entry', 'protein', 'structure')",
)
count_parser.add_argument(
"--output",
required=True,
help="Output file to write the JSON result to",
)
count_parser.add_argument("--source_db", help="Source database", default=None)
count_parser.add_argument(
"--accession", help="Specific accession", default=None
)
count_parser.add_argument(
"--linked_endpoint", help="Secondary endpoint", default=None
)
count_parser.add_argument(
"--linked_source_db", help="Database of the linked entity", default=None
)
count_parser.add_argument(
"--linked_accession", help="Accession of the linked entity", default=None
)
count_parser.add_argument(
"--query_params",
nargs="*",
help=(
"Query parameters as key=value pairs. All parameters must include"
" '='."
),
default=None,
)
count_parser.add_argument(
"--flags",
nargs="*",
help="Boolean flags (e.g., ordered exact)",
default=None,
)
count_parser.add_argument(
"--max_minutes_to_wait_for_background_task",
type=int,
help="Maximum minutes to wait for background queries (HTTP 408)",
default=5,
)
args = parser.parse_args()
parsed_query_params = {}
if args.query_params:
for param in args.query_params:
if "=" in param:
key, val = param.split("=", 1)
parsed_query_params[key] = val
else:
print(
f"Error: Query parameter '{param}' must be in key=value format.",
file=sys.stderr,
)
sys.exit(1)
if args.command == "fetch":
results = fetch_interpro_data(
endpoint=args.endpoint,
source_db=args.source_db,
accession=args.accession,
linked_endpoint=args.linked_endpoint,
linked_source_db=args.linked_source_db,
linked_accession=args.linked_accession,
query_params=parsed_query_params if parsed_query_params else None,
flags=args.flags,
limit=args.limit,
max_minutes_to_wait_for_background_task=args.max_minutes_to_wait_for_background_task,
)
try:
with open(args.output, "w") as f:
for res in results:
f.write(json.dumps(res) + "\n")
except Exception as e:
print(f"Error writing to output file {args.output}: {e}", file=sys.stderr)
sys.exit(1)
elif args.command == "count":
count = get_interpro_count(
endpoint=args.endpoint,
source_db=args.source_db,
accession=args.accession,
linked_endpoint=args.linked_endpoint,
linked_source_db=args.linked_source_db,
linked_accession=args.linked_accession,
query_params=parsed_query_params if parsed_query_params else None,
flags=args.flags,
max_minutes_to_wait_for_background_task=args.max_minutes_to_wait_for_background_task,
)
try:
with open(args.output, "w") as f:
f.write(json.dumps({"count": count}) + "\n")
except Exception as e:
print(f"Error writing to output file {args.output}: {e}", file=sys.stderr)
sys.exit(1)
Related skills
How it compares
Choose interpro-database over generic REST skills when queries target InterPro protein domain and family annotation endpoints specifically.
FAQ
What is the InterPro API page_size limit?
interpro-database documents page_size as an integer parameter defaulting to 20 results per page with a maximum of 200. Use page_size=1 with get_interpro_count for rapid bulk aggregations without downloading full pages.
Where do interpro-database parameters come from?
interpro-database parameters are based on the official InterPro Swagger documentation at interpro7-swagger.yml hosted by EBI. Parameters pass into the query_params dictionary in fetch_interpro_data.
Is Interpro Database safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.