bio-metagenomics-kraken

Taxonomic classification of metagenomic reads using Kraken2. Fast k-mer based classification against RefSeq database. Use when performing initial taxonomic classification of shotgun metagenomic reads before abundance estimation with Bracken.

1,802 stars

Best use case

bio-metagenomics-kraken is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Taxonomic classification of metagenomic reads using Kraken2. Fast k-mer based classification against RefSeq database. Use when performing initial taxonomic classification of shotgun metagenomic reads before abundance estimation with Bracken.

Teams using bio-metagenomics-kraken should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/bio-metagenomics-kraken/SKILL.md --create-dirs "https://raw.githubusercontent.com/FreedomIntelligence/OpenClaw-Medical-Skills/main/skills/bio-metagenomics-kraken/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/bio-metagenomics-kraken/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How bio-metagenomics-kraken Compares

Feature / Agentbio-metagenomics-krakenStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Taxonomic classification of metagenomic reads using Kraken2. Fast k-mer based classification against RefSeq database. Use when performing initial taxonomic classification of shotgun metagenomic reads before abundance estimation with Bracken.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

## Version Compatibility

Reference examples tested with: Kraken2 2.1+, MetaPhlAn 4.1+, pandas 2.2+

Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures
- CLI: `<tool> --version` then `<tool> --help` to confirm flags

If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.

# Kraken2 Classification

**"Classify what organisms are in my metagenomic sample"** → Assign taxonomic labels to sequencing reads using exact k-mer matching against a reference database for fast initial classification.
- CLI: `kraken2 --db db --paired R1.fastq R2.fastq --report report.txt`

## Basic Classification

```bash
# Classify reads against standard database
kraken2 --db /path/to/kraken2_db \
    --output output.kraken \
    --report report.txt \
    reads.fastq.gz
```

## Paired-End Reads

```bash
kraken2 --db /path/to/kraken2_db \
    --paired \
    --output output.kraken \
    --report report.txt \
    reads_R1.fastq.gz reads_R2.fastq.gz
```

## Common Options

```bash
kraken2 --db /path/to/kraken2_db \
    --threads 8 \                  # CPU threads
    --confidence 0.1 \             # Confidence threshold
    --minimum-base-quality 20 \    # Quality filter
    --output output.kraken \
    --report report.txt \
    --use-names \                  # Add taxon names to output
    --gzip-compressed \            # Input is gzipped
    reads.fastq.gz
```

## Memory-Efficient Mode

```bash
# For systems with limited RAM
kraken2 --db /path/to/kraken2_db \
    --memory-mapping \             # Use disk-based database
    --output output.kraken \
    --report report.txt \
    reads.fastq.gz
```

## Report Only (No Per-Read Output)

```bash
# Save space by not writing per-read classifications
kraken2 --db /path/to/kraken2_db \
    --report report.txt \
    --report-zero-counts \         # Include taxa with 0 counts
    reads.fastq.gz
```

## Classified/Unclassified Output

```bash
# Separate classified and unclassified reads
kraken2 --db /path/to/kraken2_db \
    --classified-out classified#.fq \     # # replaced by 1/2 for PE
    --unclassified-out unclassified#.fq \
    --output output.kraken \
    --report report.txt \
    --paired \
    reads_R1.fastq.gz reads_R2.fastq.gz
```

## Build Custom Database

**Goal:** Create a custom Kraken2 database with specific organism libraries for targeted classification.

**Approach:** Download NCBI taxonomy, add desired library sequences (bacteria, archaea, viral), build the k-mer index, and clean up intermediate files.

```bash
# Download taxonomy
kraken2-build --download-taxonomy --db custom_db

# Download specific libraries
kraken2-build --download-library bacteria --db custom_db
kraken2-build --download-library archaea --db custom_db
kraken2-build --download-library viral --db custom_db

# Build database
kraken2-build --build --db custom_db --threads 8

# Clean up intermediate files
kraken2-build --clean --db custom_db
```

## Add Custom Sequences

```bash
# Add FASTA sequences to library
kraken2-build --add-to-library custom_genomes.fasta --db custom_db

# Then build
kraken2-build --build --db custom_db
```

## Inspect Database

```bash
# View database contents
kraken2-inspect --db /path/to/kraken2_db | head -50
```

## Report Format

```
 17.45  1745    1745    U   0       unclassified
 82.55  8255    48      R   1       root
 82.07  8207    2       R1  131567    cellular organisms
 81.99  8199    132     D   2           Bacteria
 76.23  7623    178     P   1224          Proteobacteria
```

Columns:
1. Percentage of reads
2. Number of reads rooted at taxon
3. Number of reads directly assigned
4. Rank code (U, R, D, P, C, O, F, G, S)
5. NCBI taxon ID
6. Scientific name

## Parse Kraken Output in Python

```python
import pandas as pd

report = pd.read_csv('report.txt', sep='\t', header=None,
                      names=['pct', 'reads_clade', 'reads_taxon', 'rank', 'taxid', 'name'])

report['name'] = report['name'].str.strip()

species = report[report['rank'] == 'S']
species_sorted = species.sort_values('pct', ascending=False)
species_sorted.head(20)
```

## Filter Report by Rank

```bash
# Get only species-level classifications
awk '$4 == "S"' report.txt > species_report.txt

# Get genus level
awk '$4 == "G"' report.txt > genus_report.txt
```

## Key Parameters

| Parameter | Default | Description |
|-----------|---------|-------------|
| --db | required | Database path |
| --threads | 1 | CPU threads |
| --confidence | 0.0 | Confidence threshold (0-1) |
| --minimum-base-quality | 0 | Phred quality threshold |
| --memory-mapping | false | Use disk-based database |
| --paired | false | Paired-end mode |
| --use-names | false | Include taxon names |
| --report-zero-counts | false | Include 0-count taxa |

## Database Libraries

| Library | Content |
|---------|---------|
| bacteria | RefSeq complete bacterial genomes |
| archaea | RefSeq complete archaeal genomes |
| viral | RefSeq complete viral genomes |
| plasmid | RefSeq plasmid nucleotide sequences |
| human | GRCh38 human genome |
| fungi | RefSeq fungi |
| protozoa | RefSeq protozoa |
| UniVec_Core | Common vector sequences |

## Related Skills

- abundance-estimation - Estimate abundances with Bracken
- metaphlan-profiling - Alternative marker-based profiling
- metagenome-visualization - Visualize results

Related Skills

claw-metagenomics

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Shotgun metagenomics profiling — taxonomy, resistome, and functional pathways

bio-metagenomics-visualization

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Visualize metagenomic profiles using R (phyloseq, microbiome) and Python (matplotlib, seaborn). Create stacked bar plots, heatmaps, PCA plots, and diversity analyses. Use when creating publication-quality figures from MetaPhlAn, Bracken, or other taxonomic profiling output.

bio-metagenomics-strain-tracking

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Track bacterial strains using MASH, sourmash, fastANI, and inStrain. Compare genomes, detect contamination, and monitor strain-level variation. Use when needing sub-species resolution for outbreak tracking, transmission analysis, or within-host strain dynamics.

bio-metagenomics-metaphlan

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Marker gene-based taxonomic profiling using MetaPhlAn 4. Provides accurate species-level relative abundances using clade-specific markers. Use when accurate taxonomic profiling is needed and computational resources are limited, or for comparison with HMP/other MetaPhlAn studies.

bio-metagenomics-functional-profiling

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Profile functional potential of metagenomes using HUMAnN3 and similar tools. Use when obtaining pathway abundances, gene family counts, or functional annotations from metagenomic data.

bio-metagenomics-amr-detection

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Detect antimicrobial resistance genes using AMRFinderPlus, ResFinder, and CARD. Screen isolates and metagenomes for resistance determinants. Use when characterizing resistance profiles in clinical isolates, surveillance samples, or metagenomic data.

bio-metagenomics-abundance

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Species abundance estimation using Bracken with Kraken2 output. Redistributes reads from higher taxonomic levels to species for more accurate estimates. Use when accurate species-level abundances are needed from Kraken2 classification output.

zinc-database

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Access ZINC (230M+ purchasable compounds). Search by ZINC ID/SMILES, similarity searches, 3D-ready structures for docking, analog discovery, for virtual screening and drug discovery.

zarr-python

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Chunked N-D arrays for cloud storage. Compressed arrays, parallel I/O, S3/GCS integration, NumPy/Dask/Xarray compatible, for large-scale scientific computing pipelines.

xlsx

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

writing-skills

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Use when creating new skills, editing existing skills, or verifying skills work before deployment

writing-plans

1802
from FreedomIntelligence/OpenClaw-Medical-Skills

Use when you have a spec or requirements for a multi-step task, before touching code