{"id":"bioservices","name":"bioservices","summary":"40+バイオインフォマティクスサービスへの統一Pythonインターフェース。複数のデータベース(UniProt、KEGG、ChEMBL、Reactome)を一つのワークフローで一貫したAPIでクエリする際に使うことができます。","body":"# BioServices\n\n## Overview\n\nBioServices is a Python package providing programmatic access to approximately 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. The package handles both REST and SOAP/WSDL protocols transparently.\n\n**Version note:** Examples target **bioservices 1.16.0** (PyPI, Mar 2026). Requires **Python 3.9–3.12**. UniProt REST changes in mid-2022 (bioservices ≥1.10) mainly affect tabular `columns` names — see upstream `_legacy_names` if parsing breaks. ChEMBL wrappers changed at 1.6.0 (2018 API); use `get_similarity`, `get_substructure`, `get_molecule` instead of pre-1.6 method names.\n\n## When to Use This Skill\n\nThis skill should be used when:\n- Retrieving protein sequences, annotations, or structures from UniProt, PDB, Pfam\n- Analyzing metabolic pathways and gene functions via KEGG or Reactome\n- Searching compound databases (ChEBI, ChEMBL, PubChem) for chemical information\n- Converting identifiers between different biological databases (KEGG↔UniProt, compound IDs)\n- Running sequence similarity searches (BLAST, MUSCLE alignment)\n- Querying gene ontology terms (QuickGO, GO annotations)\n- Accessing protein-protein interaction data (PSICQUIC, IntactComplex)\n- Mining genomic data (BioMart, ArrayExpress, ENA)\n- Integrating data from multiple bioinformatics resources in a single workflow\n\n## Core Capabilities\n\n### 1. Protein Analysis\n\nRetrieve protein information, sequences, and functional annotations:\n\n```python\nfrom bioservices import UniProt\n\nu = UniProt(verbose=False)\n\n# Search for protein by name\nresults = u.search(\"ZAP70_HUMAN\", frmt=\"tab\", columns=\"id,genes,organism\")\n\n# Retrieve FASTA sequence\nsequence = u.retrieve(\"P43403\", \"fasta\")\n\n# Map identifiers between databases\nkegg_ids = u.mapping(fr=\"UniProtKB_AC-ID\", to=\"KEGG\", query=\"P43403\")\n```\n\n**Key methods:**\n- `search()`: Query UniProt with flexible search terms\n- `retrieve()`: Get protein entries in various formats (FASTA, XML, tab)\n- `mapping()`: Convert identifiers between databases\n\nReference: `references/services_reference.md` for complete UniProt API details.\n\n### 2. Pathway Discovery and Analysis\n\nAccess KEGG pathway information for genes and organisms:\n\n```python\nfrom bioservices import KEGG\n\nk = KEGG()\nk.organism = \"hsa\"  # Set to human\n\n# Search for organisms\nk.lookfor_organism(\"droso\")  # Find Drosophila species\n\n# Find pathways by name\nk.lookfor_pathway(\"B cell\")  # Returns matching pathway IDs\n\n# Get pathways containing specific genes\npathways = k.get_pathway_by_gene(\"7535\", \"hsa\")  # ZAP70 gene\n\n# Retrieve and parse pathway data\ndata = k.get(\"hsa04660\")\nparsed = k.parse(data)\n\n# Extract pathway interactions\ninteractions = k.parse_kgml_pathway(\"hsa04660\")\nrelations = interactions['relations']  # Protein-protein interactions\n\n# Convert to Simple Interaction Format\nsif_data = k.pathway2sif(\"hsa04660\")\n```\n\n**Key methods:**\n- `lookfor_organism()`, `lookfor_pathway()`: Search by name\n- `get_pathway_by_gene()`: Find pathways containing genes\n- `parse_kgml_pathway()`: Extract structured pathway data\n- `pathway2sif()`: Get protein interaction networks\n\nReference: `references/workflow_patterns.md` for complete pathway analysis workflows.\n\n### 3. Compound Database Searches\n\nSearch and cross-reference compounds across multiple databases:\n\n```python\nfrom bioservices import KEGG, UniChem\n\nk = KEGG()\n\n# Search compounds by name\nresults = k.find(\"compound\", \"Geldanamycin\")  # Returns cpd:C11222\n\n# Get compound information with database links\ncompound_info = k.get(\"cpd:C11222\")  # Includes ChEBI links\n\n# Cross-reference KEGG → ChEMBL using UniChem\nu = UniChem()\nchembl_id = u.get_compound_id_from_kegg(\"C11222\")  # Returns CHEMBL278315\n```\n\n**Version caveat:** the per-source `get_compound_id_from_*` helpers are gone from\nbioservices 1.16.0 — check `hasattr(u, \"get_compound_id_from_kegg\")` first, and\notherwise use the current UniChem API (`u.get_compounds(compound, source_type)`\nand read `res[\"compounds\"][0][\"sources\"]`). ChEMBL lookups follow the same rule:\n`get_molecule`, not the pre-1.6 `get_compound_by_chemblId`.\n\n**Common workflow:**\n1. Search compound by name in KEGG\n2. Extract KEGG compound ID\n3. Use UniChem for KEGG → ChEMBL mapping\n4. ChEBI IDs are often provided in KEGG entries\n\nReference: `references/identifier_mapping.md` for complete cross-database mapping guide.\n\n### 4. Sequence Analysis\n\nRun BLAST searches and sequence alignments. NCBI requires a contact email — prefer the `NCBI_EMAIL` environment variable (same convention as BioPython Entrez and other repo skills):\n\n```python\nimport os\nfrom bioservices import NCBIblast\n\ns = NCBIblast(verbose=False)\nemail = os.environ[\"NCBI_EMAIL\"]  # set before running: export NCBI_EMAIL=you@lab.org\n\n# Run BLASTP against UniProtKB\njobid = s.run(\n    program=\"blastp\",\n    sequence=protein_sequence,\n    stype=\"protein\",\n    database=\"uniprotkb\",\n    email=email,\n)\n\n# Check job status and retrieve results\ns.getStatus(jobid)\nresults = s.getResult(jobid, \"out\")\n```\n\n**Note:** BLAST jobs are asynchronous. Check status before retrieving results.\n\n### 5. Identifier Mapping\n\nConvert identifiers between different biological databases:\n\n```python\nfrom bioservices import UniProt, KEGG\n\n# UniProt mapping (many database pairs supported)\nu = UniProt()\nresults = u.mapping(\n    fr=\"UniProtKB_AC-ID\",  # Source database\n    to=\"KEGG\",              # Target database\n    query=\"P43403\"          # Identifier(s) to convert\n)\n\n# KEGG gene ID → UniProt\nkegg_to_uniprot = u.mapping(fr=\"KEGG\", to=\"UniProtKB_AC-ID\", query=\"hsa:7535\")\n\n# For compounds, use UniChem\nfrom bioservices import UniChem\nu = UniChem()\nchembl_from_kegg = u.get_compound_id_from_kegg(\"C11222\")\n```\n\n**Supported mappings (UniProt):**\n- UniProtKB ↔ KEGG\n- UniProtKB ↔ Ensembl\n- UniProtKB ↔ PDB\n- UniProtKB ↔ RefSeq\n- And many more (see `references/identifier_mapping.md`)\n\n### 6. Gene Ontology Queries\n\nAccess GO terms and annotations:\n\n```python\nfrom bioservices import QuickGO\n\ng = QuickGO(verbose=False)\n\n# Retrieve GO term information\nterm_info = g.Term(\"GO:0003824\", frmt=\"obo\")\n\n# Search annotations\nannotations = g.Annotation(protein=\"P43403\", format=\"tsv\")\n```\n\n### 7. Protein-Protein Interactions\n\nQuery interaction databases via PSICQUIC. **PSICQUIC is not shipped by every\nrelease — it is absent from 1.16.0** — so import it defensively and fall back to\n`IntactComplex`, `OmniPath`, or `STRING` when it is missing:\n\n```python\nfrom bioservices import PSICQUIC\n\ns = PSICQUIC(verbose=False)\n\n# Query specific database (e.g., MINT)\ninteractions = s.query(\"mint\", \"ZAP70 AND species:9606\")\n\n# List available interaction databases\ndatabases = s.activeDBs\n```\n\n**Available databases:** MINT, IntAct, BioGRID, DIP, and 30+ others.\n\n## Multi-Service Integration Workflows\n\nBioServices excels at combining multiple services for comprehensive analysis. Common integration patterns:\n\n### Complete Protein Analysis Pipeline\n\nExecute a full protein characterization workflow:\n\n```bash\nexport NCBI_EMAIL=your.email@example.com\npython scripts/protein_analysis_workflow.py ZAP70_HUMAN\n# Or pass email as optional second argument if NCBI_EMAIL is unset\npython scripts/protein_analysis_workflow.py ZAP70_HUMAN your.email@example.com\n```\n\nThis script demonstrates:\n1. UniProt search for protein entry\n2. FASTA sequence retrieval\n3. BLAST similarity search\n4. KEGG pathway discovery\n5. PSICQUIC interaction mapping\n\n### Pathway Network Analysis\n\nAnalyze all pathways for an organism:\n\n```bash\npython scripts/pathway_analysis.py hsa output_directory/\n```\n\nExtracts and analyzes:\n- All pathway IDs for organism\n- Protein-protein interactions per pathway\n- Interaction type distributions\n- Exports to CSV/SIF formats\n\n### Cross-Database Compound Search\n\nMap compound identifiers across databases:\n\n```bash\npython scripts/compound_cross_reference.py Geldanamycin\n```\n\nRetrieves:\n- KEGG compound ID\n- ChEBI identifier\n- ChEMBL identifier\n- Basic compound properties\n\n### Batch Identifier Conversion\n\nConvert multiple identifiers at once:\n\n```bash\npython scripts/batch_id_converter.py input_ids.txt --from UniProtKB_AC-ID --to KEGG\n```\n\n## Best Practices\n\n### Output Format Handling\n\nDifferent services return data in various formats:\n- **XML**: Parse using BeautifulSoup (most SOAP services)\n- **Tab-separated (TSV)**: Pandas DataFrames for tabular data\n- **Dictionary/JSON**: Direct Python manipulation\n- **FASTA**: BioPython integration for sequence analysis\n\n### Rate Limiting and Verbosity\n\nControl API request behavior:\n\n```python\nfrom bioservices import KEGG\n\nk = KEGG(verbose=False)  # Suppress HTTP request details\nk.TIMEOUT = 30  # Adjust timeout for slow connections\n```\n\n### Error Handling\n\nWrap service calls in try-except blocks:\n\n```python\ntry:\n    results = u.search(\"ambiguous_query\")\n    if results:\n        # Process results\n        pass\nexcept Exception as e:\n    print(f\"Search failed: {e}\")\n```\n\n### Organism Codes\n\nUse standard organism abbreviations:\n- `hsa`: Homo sapiens (human)\n- `mmu`: Mus musculus (mouse)\n- `dme`: Drosophila melanogaster\n- `sce`: Saccharomyces cerevisiae (yeast)\n\nList all organisms: `k.list(\"organism\")` or `k.organismIds`\n\n### Integration with Other Tools\n\nBioServices works well with:\n- **BioPython**: Sequence analysis on retrieved FASTA data\n- **Pandas**: Tabular data manipulation\n- **PyMOL**: 3D structure visualization (retrieve PDB IDs)\n- **NetworkX**: Network analysis of pathway interactions\n- **Galaxy**: Custom tool wrappers for workflow platforms\n\n## Resources\n\n### scripts/\n\nExecutable Python scripts demonstrating complete workflows:\n\n- `protein_analysis_workflow.py`: End-to-end protein characterization\n- `pathway_analysis.py`: KEGG pathway discovery and network extraction\n- `compound_cross_reference.py`: Multi-database compound searching\n- `batch_id_converter.py`: Bulk identifier mapping utility\n\nScripts can be executed directly or adapted for specific use cases.\n\n### references/\n\nDetailed documentation loaded as needed:\n\n- `services_reference.md`: Comprehensive list of all 40+ services with methods\n- `workflow_patterns.md`: Detailed multi-step analysis workflows\n- `identifier_mapping.md`: Complete guide to cross-database ID conversion\n\nLoad references when working with specific services or complex integration tasks.\n\n## Installation\n\n```bash\nuv pip install \"bioservices==1.16.0\"\n```\n\nDependencies are installed automatically. Upstream CI tests Python 3.9–3.12 ([PyPI](https://pypi.org/project/bioservices/), [docs](https://bioservices.readthedocs.io/)).\n\n## Credentials\n\nMost services need no API key. Exceptions:\n\n| Service | Requirement |\n|---------|-------------|\n| NCBI BLAST | Contact email via `NCBI_EMAIL` or `email=` in `NCBIblast.run()` |\n| Some EBI services | Optional; check service docs if rate-limited |\n\nSet once per shell session:\n\n```bash\nexport NCBI_EMAIL=your.email@example.com\n```\n\nUse a real institutional or lab address — NCBI may contact you about heavy BLAST usage.\n\n## Additional Information\n\nFor detailed API documentation and advanced features, refer to:\n- Official documentation: https://bioservices.readthedocs.io/\n- Source code: https://github.com/cokelaer/bioservices\n- Service-specific references in `references/services_reference.md`","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/bioservices","license":"MIT","category":"coding","lang":"en","tokens":2808,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/identifier_mapping.md","size":17551,"sha256":"02fe1d022d767379e718f717c47d79c23dbfb2e5dd7c84e1abe678d6924b9ba5"},{"path":"references/services_reference.md","size":13026,"sha256":"7aeaa8092373c9a0ae9cd940ea48f4f408bd9edc3f3d72534cc0fb42d2374dea"},{"path":"references/workflow_patterns.md","size":20184,"sha256":"8590ed6566006753607e745eb1604b995223b0822ca76bc3caf114459918fed2"},{"path":"scripts/batch_id_converter.py","size":10892,"sha256":"488b3b95a7b43e5cd97ebd8ccead0be81364efadde7b535bb387ccf28d9cfe4f"},{"path":"scripts/compound_cross_reference.py","size":11779,"sha256":"73654c4838d136d88b189718f67e08b30a72249ee779b4e57bd62a6cab316f32"},{"path":"scripts/pathway_analysis.py","size":9547,"sha256":"59ed88cbddc01a3c1fab7c1caf04349482c338b0b71d537bae189149a4e50b36"},{"path":"scripts/protein_analysis_workflow.py","size":13467,"sha256":"820ca720822b79397949d6a53cf989c69c9dacb09a983be40dd16a0317228dd5"}],"requires":{"mcp":[],"tools":["Read Write Edit Bash"]},"safety":{"flags":[{"code":"net.endpoints","kind":"exfiltration","excerpt":"bioservices.readthedocs.io","message":"bundled scripts reach 1 external host(s)","severity":"warn"}],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":["bioservices.readthedocs.io"]}}