| name | bioservices |
| description | Unified Python access to 40+ bioinformatics web services; use when you need to query multiple databases (e.g., UniProt/KEGG/ChEMBL/Reactome) with one consistent API in a single workflow, especially for cross-database analysis and identifier mapping. |
| license | MIT |
| author | AIPOCH |
Source: https://github.com/aipoch/medical-research-skills
When to Use
- You need to retrieve and combine biological data from multiple databases (e.g., UniProt + KEGG + GO) in one Python workflow.
- You need cross-database identifier mapping (e.g., UniProt ↔ KEGG, KEGG compound ↔ ChEMBL) as part of downstream analysis.
- You want to programmatically explore pathways and networks (e.g., KEGG pathway parsing, exporting interactions to SIF).
- You need service-agnostic access across many providers (REST and SOAP/WSDL) without writing custom clients per service.
- You are building integrated bioinformatics pipelines (protein → sequence → BLAST → pathways → interactions) that span multiple resources.
Key Features
- Unified API for ~40+ bioinformatics services (single Python package, consistent patterns).
- Transparent protocol handling (REST and SOAP/WSDL).
- Protein-centric workflows via UniProt (search, retrieve, ID mapping).
- Pathway discovery and parsing via KEGG (KGML parsing, relations extraction, SIF export).
- Compound lookup and cross-referencing (e.g., KEGG compounds + UniChem mapping to ChEMBL).
- Sequence analysis integrations (e.g., NCBI BLAST asynchronous jobs).
- Ontology and annotation queries (e.g., QuickGO).
- Protein–protein interaction queries via PSICQUIC-compatible services.
Dependencies
python >= 3.9
bioservices (install via pip/uv; version depends on your environment)
Optional (commonly used alongside returned formats):
pandas >= 1.5 (TSV/tabular outputs)
beautifulsoup4 >= 4.11 (XML parsing)
lxml >= 4.9 (faster XML parsing)
networkx >= 2.8 (network analysis of interactions)
biopython >= 1.81 (sequence handling for FASTA outputs)
Example Usage
A single runnable script that demonstrates a cross-service workflow:
- UniProt search + FASTA retrieval
- UniProt → KEGG ID mapping
- KEGG pathway lookup and KGML relation extraction
- QuickGO annotation query
- PSICQUIC interaction query
- KEGG compound lookup + UniChem mapping to ChEMBL
"""
Run:
uv pip install bioservices pandas
python bioservices_example.py
Notes:
- Some services may rate-limit or be temporarily unavailable.
- NCBI BLAST requires an email; this example does not run BLAST to stay lightweight.
"""
from bioservices import UniProt, KEGG, QuickGO, PSICQUIC, UniChem
def main():
u = UniProt(verbose=False)
tab = u.search("ZAP70_HUMAN", frmt="tab", columns="id,entry name,genes,organism")
print("UniProt search (tab):")
print(tab.splitlines()[0:3], "\n")
uniprot_ac = "P43403"
fasta = u.retrieve(uniprot_ac, "fasta")
print("UniProt FASTA header:")
print(fasta.splitlines()[0], "\n")
mapping = u.mapping(fr="UniProtKB_AC-ID", to="KEGG", query=uniprot_ac)
print("UniProt -> KEGG mapping:")
print(mapping, "\n")
k = KEGG(verbose=False)
k.organism = "hsa"
pathways = k.get_pathway_by_gene("7535", "hsa")
print("KEGG pathways containing hsa:7535:")
(pathways, )
pathway_id =
kgml_relations = k.parse_kgml_pathway(pathway_id).get(, [])
()
sif = k.pathway2sif(pathway_id)
()
(.join(sif.splitlines()[:]), )
g = QuickGO(verbose=)
ann = g.Annotation(protein=uniprot_ac, =)
()
(ann.splitlines()[], )
p = PSICQUIC(verbose=)
interactions = p.query(, )
()
(.join(interactions.splitlines()[:]), )
cpd_hits = k.find(, )
()
(cpd_hits, )
kegg_compound_id =
uc = UniChem(verbose=)
chembl_id = uc.get_compound_id_from_kegg(kegg_compound_id)
()
(chembl_id, )
__name__ == :
main()
Implementation Details
- Service objects: Each remote resource is exposed as a Python class (e.g.,
UniProt, KEGG, QuickGO, PSICQUIC, NCBIblast). You instantiate a client and call methods that wrap the underlying endpoints.
- Protocols: BioServices abstracts REST and SOAP/WSDL services behind similar method calls; returned payloads may be text (TSV), XML, JSON-like dicts, or FASTA.
- Common parameters
verbose: toggles HTTP/request logging (verbose=False is recommended for scripts).
TIMEOUT: per-service timeout control (useful for slow networks or large responses).
- Service-specific parameters (examples):
- UniProt:
search(query, frmt=..., columns=...), retrieve(accession, format), mapping(fr=..., to=..., query=...)
- KEGG:
find(db, query), get(entry_id), parse(raw), parse_kgml_pathway(pathway_id), pathway2sif(pathway_id)
- NCBI BLAST: asynchronous job model (
run(...) → getStatus(jobid) → getResult(jobid, ...))
- Data handling guidance
- TSV/tabular outputs: load into
pandas.read_csv(io.StringIO(text), sep="\t")
- XML outputs: parse with
BeautifulSoup or lxml
- Network exports (SIF): import into NetworkX/Cytoscape-compatible tooling
- Operational considerations
- Many endpoints are rate-limited; implement retries/backoff for production pipelines.
- Some services require contact information (e.g., NCBI BLAST email) and may enforce usage policies.
- Availability varies by provider; design workflows to degrade gracefully (try/except, fallbacks).