Introduction
BioClaw is a WhatsApp AI assistant built on the NanoClaw architecture and Claude Agent SDK, specifically designed for bioinformatics researchers. By sending messages in WhatsApp groups, users can directly run complex bioinformatics tasks such as BLAST searches, protein structure analysis, sequencing data quality control, and literature retrieval, without needing to log into any server or use a command-line interface.
The core advantage of BioClaw lies in combining powerful bioinformatics tools with the convenience of instant messaging, allowing researchers to perform professional biological data analysis on their mobile phones. Whether discussing experimental results with collaborators or checking protein structures on the go, BioClaw provides instant responses.
Official Repository: https://github.com/Runchuan-BU/BioClaw
Method 1: Using the Defapi Platform (Recommended)
Why choose Defapi?
Defapi is a platform that provides APIs for Claude and Gemini models at half the official price. For tools like BioClaw that require a large number of API calls to complete complex bioinformatics tasks, using Defapi can significantly reduce costs. Defapi is fully compatible with Anthropic's API protocol, allowing existing SDKs and code to migrate without modification.
Configuration Steps
-
Register a Defapi account: Visit https://defapi.org to register and obtain an API Key.
-
Modify BioClaw configuration: Edit the
.envfile in the project root directory and replaceANTHROPIC_API_KEYwith the Defapi API Key:
# Official API
# ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxx
# Defapi API (Price is half the official rate)
ANTHROPIC_API_KEY=dk-xxxxxxxxxxxxxxxx
- Configure API endpoint: Add the Defapi endpoint configuration in
src/container-runner.ts:
// Add to the secret whitelist
const allowedVars = ['CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_API_KEY'];
// Modify Agent Runner's environment variable settings
const sdkEnv: Record<string, string | undefined> = {
...process.env,
ANTHROPIC_BASE_URL: 'https://api.defapi.org/v1'
};
- Restart the service:
npm run build
npm start
Models Supported by Defapi
Defapi offers multiple model options, including:
| Model | Purpose | Price |
|---|---|---|
| claude-sonnet-4-20250514 | General conversation, complex reasoning | Half Price |
| claude-opus-4-6-20250514 | High-complexity tasks | Half Price |
| claude-haiku-4-5 | Fast response | Half Price |
| gemini-2.0-flash | Multimodal tasks | Half Price |
Verify Configuration
Run the following command to verify if the API is working correctly:
curl https://api.defapi.org/v1/messages \
-H "Authorization: Bearer dk-xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{"model":"claude-sonnet-4-20250514","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'
Method 2: Using Official Anthropic API
Configuration Steps
-
Obtain API Key: Visit https://anthropic.com to apply for an API Key.
-
Configure environment variables:
# Add to .env file
ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxxxxxx
- Start the service:
npm install
npm start
Use OAuth Token (Optional)
If using Claude Code's OAuth authentication:
CLAUDE_CODE_OAUTH_TOKEN=sk-xxxxxxxxxxxxxxxx
Method 3: Using OpenRouter
OpenRouter aggregates multiple AI providers and supports proxying for Claude models.
Configuration Steps
-
Obtain OpenRouter API Key: Visit https://openrouter.ai/settings
-
Modify configuration:
# .env file
ANTHROPIC_API_KEY=sk-or-v1-xxxxxxxxxxxxxxxx
- Add endpoint configuration: In
container/agent-runner/src/index.ts:
const sdkEnv: Record<string, string | undefined> = {
...process.env,
ANTHROPIC_BASE_URL: 'https://openrouter.ai/api/v1'
};
Verifying Operation
After completing the configuration, run the following verification steps:
1. Start the service
npm start
2. Send a test message in a WhatsApp group
@Bioclaw Hello, please tell me who you are?
3. Check logs
tail -f logs/bioclaw.log
If configured correctly, you should receive a reply from BioClaw in WhatsApp.
Internal Mechanisms of BioClaw
Container Isolation Architecture
BioClaw uses Docker containers to provide an isolated computing environment for each WhatsApp group. This design offers several key advantages:
First, containers are completely isolated from each other; an error in one group will not affect others. Second, each container comes pre-installed with a full bioinformatics toolchain, including BLAST+, BWA, SAMtools, FastQC, PyMOL, etc., eliminating the need for local software installation. Finally, containers automatically release resources after a period of inactivity to save computing costs.
Message Processing Workflow
When you send a message in WhatsApp, BioClaw's processing workflow is as follows: The Node.js orchestrator first polls WhatsApp for new messages, then checks if the message contains the trigger word @Bioclaw. After passing the trigger word check, the message is passed to the Docker container corresponding to that group. The Claude Agent SDK inside the container receives the message and calls the AI model to generate a response. Finally, the response is sent back to the group via the WhatsApp API.
The entire process takes anywhere from a few seconds to tens of seconds, depending on the complexity of the task.
Session Management
BioClaw supports multi-turn dialogue sessions. Each group has an independent session directory, and session states are stored in a SQLite database. This means that even if a container restarts, the dialogue context is not lost, and the Agent can understand the historical background of the conversation to provide more coherent responses.
Common Use Cases
BioClaw is particularly suited for the following five bioinformatics scenarios:
1. Sequence Similarity Search and Gene Identification
When you discover an unknown sequence, you can identify it via BLAST search:
@Bioclaw Run a BLAST search for this sequence: ATGCGATCGATCGATCGATCGATCGATCG
BioClaw will run blastn or blastp in the container, search the NCBI nr database, and return detailed information on similar sequences, including species origin, E-value, and alignment score. This is extremely helpful for gene identification, finding homologs, and studying evolutionary relationships.
2. Protein Structure Visualization
Viewing the 3D structure of a protein is a core requirement in structural biology:
@Bioclaw Please show the 3D structure of the P53 protein, rendered with PyMOL
BioClaw will download the structure file from the PDB database, generate a high-quality rendered image using PyMOL, and send it to the user. You can also specify particular rendering styles, such as showing specific residues, ligand binding sites, or hydrogen bond networks.
3. Sequencing Data Quality Control
When processing NGS data, the first step is usually to evaluate data quality:
@Bioclaw Analyze the FastQC report in the workspace
BioClaw will locate the FASTQ files in the workspace, run FastQC to generate a quality control report, and automatically interpret key metrics (GC content, sequence quality, duplication rates, etc.), helping users quickly determine if the data is suitable for downstream analysis.
4. Differential Expression Analysis and Visualization
Differential expression analysis of RNA-seq data is the core of transcriptomics research:
@Bioclaw Use counts.csv for differential expression analysis and plot a volcano plot
BioClaw will read the counts.csv file, use PyDESeq2 for differential expression analysis, and generate a Volcano Plot to visualize significantly up-regulated and down-regulated genes. This is invaluable for discovering disease biomarkers and understanding gene regulation mechanisms.
5. Scientific Literature Retrieval and Summarization
Tracking the latest research progress is a daily requirement for researchers:
@Bioclaw Search PubMed for the latest papers on CRISPR delivery methods
BioClaw will search the PubMed database and return a list of the most relevant papers, including title, authors, journal, publication date, and abstract. Users can further request a detailed interpretation of a specific paper.
Configuration Parameter Reference
BioClaw provides several configurable parameters that can be adjusted as needed:
| Parameter | Default Value | Description |
|---|---|---|
ASSISTANT_NAME | Bioclaw | Trigger word name |
CONTAINER_TIMEOUT | 1800000ms | Timeout for a single task |
IDLE_TIMEOUT | 1800000ms | Retention time after container is idle |
MAX_CONCURRENT_CONTAINERS | 5 | Maximum concurrent containers |
POLL_INTERVAL | 2000ms | Message polling interval |
These parameters can be modified in the src/config.ts file.