alterlab-bioservices — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited alterlab-bioservices (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
BioServices is a Python package providing programmatic access to roughly 40 bioinformatics web services and databases. Retrieve biological data, perform cross-database queries, map identifiers, analyze sequences, and integrate multiple biological resources in Python workflows.
Recent changes that break old scripts (verified against bioservices 1.16.0):
WSDLService class and its suds dependency are gone.
STRING class (added in 1.14) or IntactComplex; from bioservices import PSICQUIC raises ImportError.
{"results": [{"from": ..., "to": ...}, ...], "failedIds": [...]} — not a {source_id: [target_ids]} dict. See "Identifier Mapping" below.
get_status, get_result, get_result_types,wait); the old getStatus/getResult camelCase names are gone. 1.16 also adds ncbiblastapi.NCBIBlastAPI, which submits to NCBI directly instead of EBI.
This skill should be used when:
| Scenario | Use Instead |
|---|---|
| A single quick lookup (one gene, one structure, one enrichment) | alterlab-gget |
| Parsing sequence/structure files or scripting Entrez directly | alterlab-biopython |
Local BLAST+ / makeblastdb / DIAMOND on your own database | alterlab-blast |
| Deep work in one database (full KEGG, UniProt, or ChEMBL feature set) | alterlab-kegg, alterlab-uniprot, alterlab-chembl |
| Cheminformatics on the retrieved structures (descriptors, fingerprints) | alterlab-rdkit |
Retrieve protein information, sequences, and functional annotations:
from bioservices import UniProt
u = UniProt(verbose=False)
# Search for protein by name. frmt is one of xlsx/fasta/json/gff/tsv — "tab" was
# retired with the June-2022 UniProt API and now raises.
results = u.search("ZAP70_HUMAN", frmt="tsv", columns="accession,gene_names,organism_name")
# Retrieve FASTA sequence (frmt defaults to json)
sequence = u.retrieve("P43403", frmt="fasta")
# Map identifiers between databases -> {"results": [{"from": ..., "to": ...}], "failedIds": [...]}
job = u.mapping(fr="UniProtKB_AC-ID", to="KEGG", query="P43403")
kegg_ids = [r["to"] for r in job["results"]]Key methods:
search(): Query UniProt with flexible search terms (frmt="tsv", columns as UniProtreturn-field names such as accession, gene_names, organism_name, length)
retrieve(): Get protein entries in various formats (json, txt, xml, rdf, gff, fasta)mapping(): Submit an ID-mapping job and return its results payloadReference: references/services_reference.md for complete UniProt API details.
Access KEGG pathway information for genes and organisms:
from bioservices import KEGG
k = KEGG()
k.organism = "hsa" # Set to human
# Search for organisms
k.lookfor_organism("droso") # Find Drosophila species
# Find pathways by name
k.lookfor_pathway("B cell") # Returns matching pathway IDs
# Get pathways containing specific genes
pathways = k.get_pathway_by_gene("7535", "hsa") # ZAP70 gene
# Retrieve and parse pathway data
data = k.get("hsa04660")
parsed = k.parse(data)
# Extract pathway interactions
interactions = k.parse_kgml_pathway("hsa04660")
relations = interactions['relations'] # Protein-protein interactions
# Convert to Simple Interaction Format
sif_data = k.pathway2sif("hsa04660")Key methods:
lookfor_organism(), lookfor_pathway(): Search by nameget_pathway_by_gene(): Find pathways containing genesparse_kgml_pathway(): Extract structured pathway datapathway2sif(): Get protein interaction networksReference: references/workflow_patterns.md for complete pathway analysis workflows.
Search and cross-reference compounds across multiple databases:
from bioservices import KEGG
k = KEGG()
# Search compounds by name — the tab-separated result rows are "C11222\tGeldanamycin"
results = k.find("compound", "Geldanamycin")
# Get compound information with database links
compound_info = k.get("cpd:C11222") # Includes ChEBI links
# Cross-reference KEGG compound → ChEBI (KEGG→ChEMBL has no direct API)
mapping = k.conv("chebi", "compound")
mapping["cpd:C11222"] # -> 'chebi:5292' (Geldanamycin)Common workflow:
KEGG.conv for KEGG → ChEBI mapping (ChEBI IDs are also embedded in KEGG entries)chembl_webresource_client, or the live UniChem REST API directly) — there is no bioservices UniChem convenience method for KEGG → ChEMBLReference: references/identifier_mapping.md for complete cross-database mapping guide.
Run BLAST searches and sequence alignments:
from bioservices import NCBIblast
s = NCBIblast(verbose=False)
# Run BLASTP against UniProtKB via the EBI job service
jobid = s.run(
program="blastp",
sequence=protein_sequence,
stype="protein",
database="uniprotkb",
email="[email protected]" # a real address is required; jobs are killed without one
)
# Poll, then fetch. Method names are snake_case since the API refresh.
s.wait(jobid) # blocks until the job leaves RUNNING
status = s.get_status(jobid) # RUNNING | FINISHED | ERROR | FAILURE | NOT_FOUND
results = s.get_result(jobid, "out")
print(s.get_result_types(jobid)) # what formats this job can returnBLAST jobs are asynchronous — check the status (or call wait) before retrieving results. For jobs submitted to NCBI rather than EBI, bioservices 1.16 adds from bioservices import NCBIBlastAPI with the same run/get_status/get_result shape.
Convert identifiers between different biological databases:
from bioservices import UniProt, KEGG
# UniProt mapping (many database pairs supported)
u = UniProt()
job = u.mapping(
fr="UniProtKB_AC-ID", # Source database
to="KEGG", # Target database
query="P43403" # Identifier(s) to convert; a list is also accepted
)
# The payload is {"results": [{"from": ..., "to": ...}], "failedIds": [...]}.
# Collapse it yourself when you want a per-source-ID dict:
from collections import defaultdict
mapped = defaultdict(list)
for row in job["results"]:
mapped[row["from"]].append(row["to"])
# KEGG gene ID -> UniProt. Non-UniProt sources may only map *to* UniProtKB,
# so "KEGG" -> "UniProtKB" is valid while "KEGG" -> "UniProtKB_AC-ID" is not.
kegg_to_uniprot = u.mapping(fr="KEGG", to="UniProtKB", query="hsa:7535")
# For compounds, map KEGG → ChEBI via KEGG.conv
# (KEGG → ChEMBL has no direct API; obtain ChEMBL IDs separately
# via the ChEMBL web service / chembl_webresource_client or the
# live UniChem REST API directly)
k = KEGG()
kegg_to_chebi = k.conv("chebi", "compound")
chebi_from_kegg = kegg_to_chebi["cpd:C11222"] # -> 'chebi:5292'Supported mappings (UniProt):
references/identifier_mapping.md)Access GO terms and annotations:
from bioservices import QuickGO
g = QuickGO(verbose=False)
# Retrieve GO term information (returns parsed JSON from the QuickGO REST API)
term_info = g.get_go_terms("GO:0003824")
ancestors = g.get_go_ancestors("GO:0003824")
# Annotations: the parameters follow the QuickGO REST API, not the old
# protein=/format= signature. geneProductId is prefixed, limit is capped at 100.
annotations = g.Annotation(
geneProductId="UniProtKB:P43403",
includeFields="goName",
limit=100,
page=1,
)
for row in annotations["results"][:5]:
print(row["goId"], row["goName"], row["goAspect"])Annotation returns a dict with numberOfHits and results; page through it rather than raising limit (values above 100 raise a TypeError).
PSICQUIC and BioGRID were removed from bioservices in 1.14. Use the STRING service (or IntactComplex for curated complexes):
from bioservices import STRING
s = STRING()
# Functional + physical partners of a protein
partners = s.get_interaction_partners("ZAP70", species=9606, limit=20)
# Interactions within a given set of proteins
network = s.get_interactions(["ZAP70", "CD247", "LCK"], species=9606)
for row in partners:
print(row["preferredName_A"], row["preferredName_B"], row["score"])network_type="physical" restricts to physical complexes; required_score (0–1000) sets the confidence floor. STRING scores are 0–1 in the JSON output.
BioServices excels at combining multiple services for comprehensive analysis. Common integration patterns:
Execute a full protein characterization workflow:
python scripts/protein_analysis_workflow.py ZAP70_HUMAN [email protected]This script demonstrates:
Analyze all pathways for an organism:
python scripts/pathway_analysis.py hsa output_directory/Extracts and analyzes:
Map compound identifiers across databases:
python scripts/compound_cross_reference.py GeldanamycinRetrieves:
Convert multiple identifiers at once:
python scripts/batch_id_converter.py input_ids.txt --from UniProtKB_AC-ID --to KEGGDifferent services return data in various formats:
Control API request behavior:
from bioservices import KEGG
k = KEGG(verbose=False) # Suppress HTTP request details
k.TIMEOUT = 30 # Adjust timeout for slow connectionsWrap service calls in try-except blocks:
try:
results = u.search("ambiguous_query")
if results:
# Process results
pass
except Exception as e:
print(f"Search failed: {e}")Use standard organism abbreviations:
hsa: Homo sapiens (human)mmu: Mus musculus (mouse)dme: Drosophila melanogastersce: Saccharomyces cerevisiae (yeast)List all organisms: k.list("organism") or k.organismIds
BioServices works well with:
Executable Python scripts demonstrating complete workflows:
protein_analysis_workflow.py: End-to-end protein characterizationpathway_analysis.py: KEGG pathway discovery and network extractioncompound_cross_reference.py: Multi-database compound searchingbatch_id_converter.py: Bulk identifier mapping utilityScripts can be executed directly or adapted for specific use cases.
Detailed documentation loaded as needed:
services_reference.md: Comprehensive list of all 40+ services with methodsworkflow_patterns.md: Detailed multi-step analysis workflowsidentifier_mapping.md: Complete guide to cross-database ID conversionLoad references when working with specific services or complex integration tasks.
uv pip install bioservicesDependencies are automatically managed. Package is tested on Python 3.9-3.12.
For detailed API documentation and advanced features, refer to:
references/services_reference.mdPart of the AlterLab Academic Skills suite.
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.