Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
gptomics avatar

Bio Metagenomics Kraken

  • 5 installs
  • 1.1k repo stars
  • Updated July 25, 2026
  • gptomics/bioskills

Classify metagenomic shotgun reads taxonomically with Kraken2 k-mer matching against RefSeq before abundance estimation with Bracken.

About

Performs fast k-mer-based taxonomic classification of shotgun metagenomic reads using Kraken2 against a RefSeq database. A developer uses it when doing initial taxonomic profiling before abundance estimation with Bracken.

  • Kraken2 k-mer taxonomic classification
  • RefSeq database, precedes Bracken abundance

Bio Metagenomics Kraken by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #1,598 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/gptomics/bioskills --skill bio-metagenomics-kraken

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
repo stars1.1k
Last updatedJuly 25, 2026
Repositorygptomics/bioskills

What it does

Classify metagenomic shotgun reads taxonomically with Kraken2 k-mer matching against RefSeq before abundance estimation with Bracken.

Files

SKILL.mdMarkdownGitHub ↗

Kraken2 Classification

Basic Classification

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

Paired-End Reads

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

Common Options

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

# 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)

# 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

# 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

# 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

# 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

# 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

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

# 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

ParameterDefaultDescription
--dbrequiredDatabase path
--threads1CPU threads
--confidence0.0Confidence threshold (0-1)
--minimum-base-quality0Phred quality threshold
--memory-mappingfalseUse disk-based database
--pairedfalsePaired-end mode
--use-namesfalseInclude taxon names
--report-zero-countsfalseInclude 0-count taxa

Database Libraries

LibraryContent
bacteriaRefSeq complete bacterial genomes
archaeaRefSeq complete archaeal genomes
viralRefSeq complete viral genomes
plasmidRefSeq plasmid nucleotide sequences
humanGRCh38 human genome
fungiRefSeq fungi
protozoaRefSeq protozoa
UniVec_CoreCommon vector sequences

Related Skills

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

Related skills

Data Science & MLpipelinesanalytics

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.