High-speed, accurate NLR annotation in Rust

FastNLR

FastNLR scans the six reading frames of a genome assembly for amino-acid motifs and assembles them into complete and partial NLR loci with multithreading, memory-mapped input, checkpoint resume, and coordinate-consistent output.

Install conda install bioconda::fastnlr
GPL-3.0 License
Rust 1.70+ toolchain
bioconda Linux & macOS
fastnlr — annotate NLR loci
$ fastnlr -i genome.fasta -o result -t 8
# scanning six reading frames ...
# 12,482 motifs scored in 4.7s
✓ assembled 218 NLR loci
✓ result.nlr.txt
✓ result.nlr.gff
✓ result.nlr.bed
✓ result.motifs.bed
✓ result.nbarc.fasta
Done in 8.3s
Install

Up and running in one command

Install from bioconda, grab the prebuilt binary, or compile from source. Every path produces the same self-contained executable.

shell
# recommended: install from bioconda
conda install bioconda::fastnlr

# add channels explicitly if they are not in your conda config
# (conda-forge must come before bioconda)
conda install -c conda-forge -c bioconda bioconda::fastnlr

# mamba / micromamba are drop-in and much faster
mamba install -c conda-forge -c bioconda bioconda::fastnlr

# then annotate a genome
fastnlr -i genome.fasta -o result

The -o directory contains the full result set prefixed by the genome filename: *.nlr.txt, *.nlr.gff, *.nlr.bed, *.motifs.bed, *.nbarc.fasta, *.loci.fasta, *.stats.tsv, *.summary.txt, and *.plots/. Package page: anaconda.org/bioconda/fastnlr.

Usage

Common workflows

One flag, one job. Compose exactly the outputs you need.

Basic annotation
fastnlr -i genome.fasta -o results
Multithreading
fastnlr -i genome.fasta -o results -t 8
Flexible seeding (on by default)
fastnlr -i genome.fasta -o results --no-flexible-seed # opt out
Custom motif config
fastnlr -i genome.fasta -x custom_mot.txt -y custom_store.txt -o results
Extended RNL / TIR library
source data/motif_library_rnl_tir/flags.sh # adds 8 motifs
Protein mode (HMM domains)
fastnlr --protein -i proteins.fa -o protein_results

CLI reference

Short options are -i/-x/-y/-o/-t/-n; everything else is long-form. Run fastnlr --help for the same reference on the command line.

InputDescription
-i <genome.fasta>Input genome FASTA, may be gzip-compressed. Required.
-x <mot.txt>PWM config (optional; default: built-in).
-y <store.txt>CDF config (optional; default: built-in).
Motif library metadata — only for custom librariesDescription
--motif-category ID=CATDeclare the domain category for a motif id outside the built-in tables, e.g. 21=CC,25=TIR. Repeatable or comma-separated.
--seed-combination IDSAdd a seed motif-id combination, e.g. 21,4; separate combinations with semicolons.
--signature IDSAdd a fragment signature, e.g. 25,26; multiple signatures separated with semicolons.
Sensitivity / recallDescription
--flexible-seed <n>Flexible seeding threshold: seed when at least n NB-ARC motifs appear in strictly increasing rank order (a repeated motif does not qualify). On by default (n = 3). Additive — exact motif-id seed combinations stay active, so loci found without this flag are never lost.
--no-flexible-seedDisable flexible seeding and fall back to the exact motif-id seed combinations only.
--require-ploopRequire the P-loop motif (motif_1) for flexible seeding (higher precision).
--relaxed-seed <n>Relaxed seeding: accept a consecutive hit run with at least n NB-ARC motifs. Off by default and mutually exclusive with flexible seeding — pass --no-flexible-seed to use it.
--motif-accept-p <p>Final motif-accept p-value threshold (default 1e-5).
--motif-prelim-p <p>Fragment prefilter p-value threshold (default 1e-4).
Output & run controlDescription
-o <OUTPUT.DIR>Output directory (created if missing). Required. All results are written here with the input genome filename as prefix.
--flank <bp>Flanking bases for loci sequence extraction (default 2000).
-t <n>Threads (default: auto-detect).
-n <n>Fragments per batch (default 1000).
--checkpoint <dir>Save/load motif results to skip rescan.
--tmpdir <dir>Temp directory.
--progress <auto|bar|simple|off>Progress bar (default auto).
--log-level <lvl>trace / debug / info / warn / error (default info).
Protein modeDescription
--proteinTreat -i as a protein FASTA and scan domains with HMMER instead of translating a genome. Mutually exclusive with the genome-only flags (--flank, --relaxed-seed, --flexible-seed, --require-ploop, --signature, --seed-combination, --checkpoint).
--hmm <FILE>Extra HMM domain models (repeatable, may hold several models per file). A model with the same accession replaces the built-in one; new accessions are appended.

Output formats

Everything below is written by default into -o, prefixed by the input genome filename (without the .fa/.fasta/.fna/.gz extension).

Genome (DNA) modeContents
<prefix>.nlr.txtOne row per NLR: seqname, name, domain-class, start, end, strand.
<prefix>.nlr.gffGFF3 with a live timestamp; source column = FastNLR.
<prefix>.nlr.bedBED12, colour-coded blocks (green = complete, orange = partial, red = contains stop codon).
<prefix>.motifs.bedMotif intervals with p-values (the full per-motif hit detail).
<prefix>.nbarc.fastaP-loop-anchored NB-ARC multiple alignment with gap padding.
<prefix>.loci.fastaExtracted ±flanking sequence, reverse-complemented on the reverse strand.
<prefix>.stats.tsvGlobal / per-chromosome / per-motif statistics.
<prefix>.summary.txtHuman-readable run summary (counts, class breakdown, output list).
<prefix>.plots/PNG statistics plots: motif counts, per-chromosome NLRs, NLR types.
<prefix>.nlr.gff — header
##gff-version 2
##source-version FastNLR V1.5.3
##date 2026-10-12 15:23:36
##Type DNA
Protein mode (--protein)Contents
<prefix>.domains.tsvOne row per domain hit: protein id, source (hmm/pwm), model, model name, category, coordinates, bitscore, p-value, whether it passed the Pfam gathering threshold.
<prefix>.nlr.tsvOne row per NLR candidate: class, N-terminal domain, has_nbarc/has_tir/has_lrr, completeness and a compact domain map.
<prefix>.summary.txt · .plots/Model set, thresholds, counts by class, and PNG plots.
Features

Built for speed, shipped self-contained

A self-contained pipeline that installs from bioconda and runs out of the box on any FASTA — no extra config files, no setup.

High performance

Rust with rayon multithreading, memory-mapped FASTA parsing, and SIMD (wide) cross-window scoring. Plant genomes finish in seconds to minutes.

Zero-config binary

The standard mot.txt (PWM) and store.txt (CDF) configs are embedded at compile time. Run on any FASTA with no extra files.

Coordinate-consistent

Loci FASTA extraction matches the reported GFF/BED coordinates exactly across every contig.

Protein mode

Run --protein on a protein FASTA to scan NLR domains with a bundled HMMER 3.4 port (Pfam NB-ARC / TIR / Rx_N / RPW8 / R1-type at gathering thresholds) plus the PWM LRR motifs, and get a domain architecture call per protein. --hmm adds your own models.

Resumable runs

--checkpoint saves motif results after the scan; reruns skip the expensive scanning step and go straight to assembly.

Rich reporting

Human-readable summary, TSV statistics (global / per-chromosome / per-motif), and PNG plots out of the box — no external tools.

Flexible seeding, on by default

Category/rank-based seeding runs out of the box and recovers divergent NLR/RNL loci. It is additive — it never drops a locus that the exact motif-id seed combinations would have found (--no-flexible-seed restores the strict behaviour).

HMM-confirmed architecture

Every assembled locus is re-scanned with the same bundled HMMER profiles used in protein mode, so N-terminal CC/TIR domains the PWM library misses are still reported instead of collapsing to a bare NBARC-LRR.

Tandem-repeat aware assembly

Repeated or duplicated domain units and trailing NB-ARC segments are merged back into their parent locus, so a single gene is not reported as several split loci.

Motif library

Extended RNL / TIR library

The default build ships the built-in 20-motif profile. The repository also contains an optional library that adds eight motifs.

MotifsWhat they add
21–24RNL / helper-NLR N-terminal CC motifs (ADR1, NRG1 and Solanaceous NRC).
25–28TIR-family motifs, covering short and TIR-only loci that the standard [18,15,13] seed could miss.
shell
# enable the extended library (declares categories, seeds and signatures)
source data/motif_library_rnl_tir/flags.sh
fastnlr -i genome.fasta -o out \
  -x data/motif_library_rnl_tir/mot.txt \
  -y data/motif_library_rnl_tir/store.txt \
  --motif-category "$TIS_MOTIF_CATEGORY" \
  --seed-combination "$TIS_SEED_COMBINATION" \
  --signature "$TIS_SIGNATURE"

Because these motifs live outside the built-in rule tables they must be enabled together with their declared categories, seeds and signatures; flags.sh holds the complete parameter lists. Measured effect: RNL / helper-NLR recall rises from 3/8 to 8/8, at the cost of more TIR loci being split — see the library README for the design rationale and regeneration workflow.

Architecture

A layered Cargo workspace

Each crate owns a single responsibility; the dependency graph flows bottom-up.

01
FASTA
chop · overlap
→
02
Translate
six frames
→
03
Scan
PWM + CDF
→
04
Filter
signature
→
05
Assemble
3-step
→
06
Output
multi-format
nlr-coreDomain model + hardcoded rule tables (rank / class / color / seed / signature / consensus).
nlr-configParse mot.txt (PWM) and store.txt (CDF); embedded default config support.
nlr-seqSix-frame translation, reverse complement, codon table, FASTA reader, chopper.
nlr-scanSliding-window scoring + non-overlap arbitration + signature pre-filter (SIMD).
nlr-assemblefindSeeds → mergeSeeds → elongate three-step assembly, plus tandem-repeat absorption.
nlr-domainProtein-mode HMMER domain scanning (NB-ARC / TIR / CC) + architecture classification.
nlr-outputtxt / GFF / BED / motifBED / alignment-fasta / loci-fasta / TSV output.
nlr-reportRun statistics aggregation.
nlr-plotplotters statistics plots (bundled font backend, no system font deps).
nlr-cliclap CLI entry + pipeline orchestration (rayon + checkpoint + SIGINT); binary: fastnlr.
Performance

Genome-scale, memory-efficient

Memory-mapped FASTA parsing and SIMD scoring keep throughput flat across two orders of magnitude of genome size. Measured on 18 plant genomes, 8 threads, median of 3 runs.

18
Genomes benchmarked
69
Tests passing
6
Reading frames
4
Conda platforms
GenomeSizeThreadsWall timePeak RSS
Cucumis sativus197 Mb853.5 s210 MB
Glycine max991 Mb8269.5 s968 MB
Hordeum vulgare4.3 Gb81174 s4159 MB
Zanthoxylum bungeanum4.7 Gb81230 s4625 MB

Throughput holds at roughly 3.7 Mb/s end to end, and peak memory stays close to 1:1 with genome size (ratios 0.97–1.15 in the benchmark) — budget RAM of the same order as the assembly. Multithreading scales 13–19× from 4 to 128 threads on the largest genomes; keep -t at or below the physical core count, since oversubscription costs performance.

Recall on RefPlantNLR (400 curated NLR CDS)Gene recallRNL / helper NLR
Default (20 motifs)98.25%3 / 8
Flexible seed99.50%8 / 8
Extended (28 motifs)99.50%8 / 8
Protein mode (HMM)99.50%8 / 8

DNA mode reaches 96.49% domain-architecture agreement with the curated annotation — 98.19% once the 12 reference entries whose Structure and Subclass columns contradict each other are excluded — with per-domain F1 of 1.000 (NB-ARC), 0.999 (LRR), 0.995 (TIR) and 0.989 (CC). LRR calls reach 99.7% sensitivity at 100% specificity, and no gene is reported as split loci.

Correctness

Implementation notes

69 unit and integration tests cover coordinate mapping, six-frame translation, motif scanning, three-step assembly with tandem-repeat absorption, protein-mode domain classification, seeding rules, log formatting, and every output format.

1The NB-ARC alignment FASTA uses corrected P-loop location logic.
2The NB-ARC alignment FASTA replaces stop codons and unknown amino acids with _.
3The loci FASTA applies a unified coordinate clamp on the last contig.
4The loci FASTA extracts from every contig, not only the first.
5The loci FASTA keeps extracted coordinates consistent with the reported GFF/BED coordinates.
6##date reflects the current system time.
7GFF ##source-version and source column relabeled FastNLR.
8p-value rendering in motif BED / export TSV uses scientific notation for very small values.
Citation

Acknowledgements

FastNLR is developed and maintained by Jiwen Zhao. A dedicated manuscript is in preparation; until then, please cite this repository:

Jiwen Zhao. FastNLR: a high-speed, accurate NLR annotation tool. github.com/CropCoder/FastNLR