flashalign(1) Bioinformatics tools flashalign(1)

flashalign - long-read DNA and spliced RNA alignment against a reference genome

* Indexing the reference (optional):

flashalign index [-x preset] ref.fa [out.faix]
flashalign index [-k kmer] [-s smer] [-I batchSize] ref.fa [out.faix]

* Long-read alignment with CIGAR:

flashalign align -a [-x preset] ref.faix reads.fq > output.sam
flashalign align -c [-x preset] ref.fa reads.fq > output.paf

* Long-read mapping without CIGAR:

flashalign align [-x preset] [-t nThreads] ref.fa reads.fq > output.paf

* Long-read overlap without CIGAR:

flashalign align -x ava-ont [-t nThreads] reads.fq reads.fq > output.paf

* Spliced alignment of long RNA reads:

flashalign align -ax splice ref.fa reads.fq > output.sam

FlashAlign maps long reads to a reference genome: noisy Nanopore reads, accurate long reads such as PacBio HiFi, and long cDNA, direct-RNA and Iso-Seq reads, which it aligns across introns. It outputs in the PAF or SAM format, PAF by default; it writes no BAM, so BAM is made by piping SAM to samtools.

Reads may be FASTA/FASTQ (plain, gzip or BGZF) or BAM/uBAM regular files. Legal additional BGZF extra subfields are accepted. Confirmed BAM container or record damage and non-gzip trailing bytes are errors; a missing final BGZF EOF marker alone warns and succeeds. Discard partial output after an error. Embedded empty BGZF blocks do not end the input.

Seeds are closed syncmers, so an index is defined by the pair (k, s). flashalign index writes a reusable .faix index (ref.fa.faix unless out.faix is given) and records in it the preset it was built with; flashalign align adopts that preset unless -x is given. The target of align may equally be a reference FASTA, which is indexed transiently in memory and never written out. FASTA or FASTQ (plain or gzip) and .faix targets are told apart by content, not by name, and any other file is refused.

The index owns the seeding: align has no -k and no -s. A FASTA target is indexed with the preset's (k, s), a .faix target supplies its own, and mapping under another pair means running flashalign index -k/-s first.

Preset [lr]. It fixes the seeding of the index and is written into it. Available STR are lr (-k21 -s9), lr:hq (-k21 -s5), splice and splice:hq (-k15 -s10), the experimental asm5, asm10 and asm20 (-k21 -s9), and the experimental ava-ont (-k17 -s9) and ava-hifi (-k21 -s5). See Preset options.
Syncmer k-mer length [21], no larger than 23. Every preset maps an index of any such k; Nanopore direct RNA maps on a -k14 splice index. A k-mer that is its own reverse complement, possible at an even value only, is never a seed.
Closed-syncmer s-mer size, 1 to k [9]. A closed syncmer is a k-mer whose minimal s-mer sits at one of its two ends; the seed density is about 2/(k-s+1). A preset's s larger than k is taken as k.
Load at most NUM target bases into RAM for indexing [no split]. If there are more than NUM bases in ref.fa, flashalign needs to read reads.fq multiple times to map it against each batch of target sequences. This would create a multi-part index. NUM may be ending with k/K/m/M/g/G. NB: mapping quality is incorrect given a multi-part index.
Don't store target sequences in the index. It saves disk space and memory but the index generated with this option will not work with -a or -c: it serves plain PAF output only, so SAM output, --cs, --MD and the splice presets refuse it. This option is not listed on the help screen.
Number of threads [all].
Suppress non-error logging, including the version, command line and resource usage printed at the end of the run.
Print the index help message to stdout and exit.

Stop alignment elongation if there are no seeds within NUM-bp [5000]. It bounds how far base alignment extends toward a read end, and under a DNA preset two pieces of a read join into one record only across gaps of at most NUM. Under a DNA preset chaining links anchors across at most the larger of it and -r's second value, so values under that band leave the chain unchanged. Under a splice preset it bounds base alignment and is also the maximum query gap of the fine chain; there -G bounds introns. Untyped, lr and lr:hq use 5000, the assembly presets 10000 and the splice presets 2000. NUM may be ending with k/K/m/M/g/G.
Bandwidth for base alignment, and for gap filling and chaining [500,20000]. Under a DNA preset, NUM1 is used for alignment extension toward the read ends and for inverted middles, and NUM2 for closing gaps between anchors, both only when base-level alignment runs (-c, SAM). NUM2 is also the band of the dense chain over the whole read, one for each contig and strand of the read's candidates: each candidate contributes every anchor of its window, which widens by at most the band, and the chain links anchors within the band across at most the band, or -g where that is larger, whatever the read length. So NUM2 acts on placement, and so also on plain PAF output. ava-ont and ava-hifi refuse -r; their chains band at 20000. A single value sets NUM1 only. Each value may be ending with k/K/m/M/g/G, and NUM1 may not exceed NUM2. Under a splice preset NUM1 is the diagonal band of the fine chain and NUM2 only bounds NUM1; neither bands base alignment there, and -G sets both [200000,200000].
Discard alignments with chaining score <INT [40; 100 on ava-ont, ava-hifi]. Chaining score equals the approximate number of matching bases minus a concave gap penalty. With a CIGAR the test counts the alignment's matching bases; in plain PAF output it reads the chain score. A rival chain scoring under INT is weighed as scoring INT in the mapping quality; an inverted middle is aligned only when both its spans reach INT; and base alignment trims a bad read end until 2*INT matching bases. At least 1. The long form is --min-chain-score. DNA presets only.
Minimal secondary-to-primary score ratio to output secondary mappings [0.8]. Under a splice preset it retains a rival: a retained rival is aligned, is what md and XA report, and is a record of its own under --secondary=yes. Under a DNA preset it decides which chains attached to an owner are kept as secondary alignments, aligned beside it with a CIGAR and written from their chains without one: those whose chain scores at least FLOAT times the owner's, or within 2k of it.
Retain at most INT secondary alignments [5]. Under a DNA preset both lanes keep up to INT per read whether or not they are printed; with a CIGAR they are aligned and the best of them prices the mapping quality, and without one each is written from its whole chain. Under lr and lr:hq, a secondary alignment ends where its alignment first splits, at a Z-drop or at a gap too large to align. No secondary alignment is kept past INT. -N0 is --secondary=no.
Absolute chain-score band that retains a rival beside -p [30]. Splice presets only.
Minimal number of seeds on a vote peak [3].
Ignore a seed whose reference occurrence is above INT when voting, under a DNA preset when chaining too, and under a splice preset in every later step that reads seeds; 0 turns occurrence filtering off [200]. Unset, the cap is the larger of 200 and the occurrence of the top 1.81e-4 fraction (1.62e-3 under splice and splice:hq) of the most frequent seeds in the index, at most 500 under lr:hq, and the DNA chaining gates take the same cap. Under a DNA preset a vote tile whose seeds are all above the cap still votes with its rarest seed of at most 4095 occurrences (lr) or 1024 (lr:hq), and chaining keeps that seed.
Keep every vote peak whose vote is at least FLOAT of the best peak's [0.25; 0 on ava-ont, ava-hifi]. 0 keeps the top four peaks by count instead. DNA presets only.
Drop a seed whose genome-wide reference occurrence is above INT from the pool handed to chaining; 0 disables the gate [200]. Unset, the gate is the voting cap (--max-vote-occ). A seed an empty vote tile kept passes the gate. Only this gate bounds the seeds chaining receives: with 0, repeats can cost several times the CPU and memory. The same value removes, before voting, every seed whose k-mer occurs in the read itself more than INT times and in more than the fraction of the read's seeds that --q-occ-frac sets, as minimap2 does (not under ava-ont and ava-hifi); 0 removes none. DNA presets only.
Before voting, drop every seed whose k-mer occurs in the read more times than the occurrence cap and in more than FLOAT of the read's seeds, as minimap2's option of the same name does [0.01]; 0 turns this filter off. The cap is the chaining cap (--max-chain-occ) under lr, lr:hq, asm5, asm10 and asm20, and the voting cap (--max-vote-occ) under splice and splice:hq. Not under ava-ont and ava-hifi.
In each run of the read's seeds whose occurrence is above the occurrence cap, between two seeds at or under it or a read end, keep the rarest seeds anyway, one per INT bases of the run and at most 128, except a seed that occurs more than 4095 times, as minimap2's option of the same name does; 0 turns this off [0; 500 under splice and splice:hq]. Every stage that applies the cap takes the kept seeds. Under the DNA presets it is off unless given, and unmeasured.
Seeds per strand that vote, and query tiles per read [128,128]. The read is cut into NUM1 equal tiles and each tile votes with one of its seeds; 0 votes with every seed. Above 128, the preset keeps the seeds the 128-tile cut picks and adds seeds of the NUM1-tile cut, each the farthest from those kept, until it holds as many as that cut picks; a rescued seed that would exceed the strand's budget of rescued occurrences is skipped, so the count can stop short. The exact refinement of the vote peaks uses the seeds of both cuts. NUM2 is the number of equal query tiles on which a candidate's seed support over the read is counted for its admission to the catalogue, 1 to 4096, of which admission by --vote-ratio compares at most 2048; under lr:hq the blocks of a split read are also measured in these tiles when their mapping-quality rivals are chosen. A single value sets NUM1 only. Neither --min-support nor --max-cands scales with NUM1; a vote peak needs --min-support votes, so a NUM1 below that places few reads or none. The Python field for NUM1 is Config.max_query_seeds. DNA presets only; the splice presets take --vote-spacing.
Width in reference bases of the diagonal bin a seed votes into, and the divisor of the read-length term that widens it [64,128]: a read of length L votes into bins of width max(NUM1, L/NUM2), at most --dw-max. A single value sets NUM1 only and keeps the preset's divisor; a NUM2 of 0 drops the term and fixes the width at NUM1. The splice presets take NUM1 alone: their width is fixed.
Largest width the read-length term of -W may reach, greater than 0 and, while that term is on, not below NUM1 [2048]. DNA presets only.
Vote peaks and placement candidates kept per strand, 1 to 64 [16]; 1 to 16383 [16383] under ava-ont and ava-hifi, which chain each contig and strand of the read once. Elsewhere, unset, it is 16 when vote peaks are admitted by their ratio to the best (--vote-ratio), where it only bounds the cost, and 4 when --vote-ratio is 0, where it selects; a value replaces whichever applies. With a CIGAR the secondary alignments come from these candidates' chains, so a wider bound can add secondaries. DNA presets only.

Under a DNA preset, -A, -B, -O, -E, -z and --score-N set the scoring of the gap fills between anchors, and that row is checked: -O and -E positive, E1>E2 and O1+E1<O2+E2 unless the two pieces are equal, (O1+E1)+(O2+E2) at most 127, --score-N below -B, -A and -B within [1,127] and --end-bonus at least -1; a row that fails exits 1. The read-end extensions use the preset's own row, which also scores every alignment, so AS, -S and --end-bonus are in its units: for lr -A2 -B4 -O4,24 -E2,1 -z400,200 --score-N 1, for lr:hq -A1 -B4 -O6,26 -E2,1 -z400,200 --score-N 1. Under asm5, asm10 and asm20, as under the splice presets, the gap fills and the read-end extensions use one row, and these options set it. The defaults below are those of lr.

Matching score [4].
Mismatching penalty [8]. Use a larger value for lower divergence.
Gap open penalty [8,48]. If the second INT is not specified, it is set to the first.
Gap extension penalty [4,1]. A gap of length k costs min{O1+k*E1,O2+k*E2}. If the second INT is not specified, it is set to the first.
Truncate an alignment if the running alignment score drops too quickly along the diagonal of the DP matrix (diagonal X-drop, or Z-drop) [800,200]. Under a DNA preset, a drop above INT2 tests the dropped region for a small inversion, aligning the reverse complement of the query there; under lr:hq, only where the read's own seeds of the other strand chain inside that region. If INT2 is not specified, it is set to INT1; it may not exceed INT1.
Minimal peak DP alignment score to output [80]. Under a splice preset it is also the floor of a supplementary piece, which needs 3 anchors and 40 matching bases besides; the primary is exempt. Under a DNA preset an alignment also needs at least -m (40) matching bases; a value of 0 or less turns off the score test, not the base count. Plain PAF output, which has no DP, is not filtered by this score; under a DNA preset it prints no record whose chaining score is below -m. The long form is --min-dp-score.
Penalty of a mismatch involving ambiguous bases [2].
Score bonus when alignment extends to the end of the query sequence [-1].

Minimal reference gap that chaining accepts as an intron [20]; a shorter gap is left to base alignment as a deletion. It does not decide the `N' CIGAR operator: base alignment writes a gap as `N' once the second gap penalty makes the long gap cheaper (see -O and -E). Splice presets only.
Maximum gap on the reference (effective with a splice preset), that is the maximum intron length [200k]. It also sets both values of -r, as in minimap2; when both -G and -r are given, the later one decides them. NUM may be ending with k/K/m/M/g/G. The long form is --max-intron-len. Splice presets only.
How to find canonical splicing sites GT-AG - f: transcript strand; b: both strands; r: reverse strand; n: no attempt to match GT-AG [b]. Under n no ts tag is stamped. Use f for reads already on the transcript strand, such as direct RNA and Iso-Seq. Splice presets only.
Junctions to prefer during base alignment []. FILE can be gene annotations in the BED12 format (aka 12-column BED), or intron positions in 6-column BED with the strand column required. BED12 file can be converted from GTF/GFF3 with `paftools.js gff2bed anno.gtf'. Splice presets only.
Score bonus for a splice donor or acceptor found in annotation [9]. Effective with --junc-bed. INT ranges from 0 to 127. Splice presets only.
One vote seed per INT query bases [8; splice:hq 16]: a read of length L votes with max(128, ceil(L/INT)) seeds per strand, one per equal tile, so a read of at most 128 times INT bases votes with 128 seeds as before; 0 keeps the fixed 128. The vote serves plain PAF and base-level output alike. The Python field is Config.vote_seed_spacing. Splice presets only.

Output alignments to FILE [stdout].
Generate CIGAR. In PAF, the CIGAR is written to the `cg' custom tag. PAF without -c is placement-only: it runs no base-level dynamic programming, so its coordinates and its AS:i differ from those of a base-level alignment. -c, --cs and --MD turn base-level alignment on in PAF; SAM output always has it.
Output the cs tag. If no argument is given, `short' is set [none]. Implies -c.
Output the MD tag (see the SAM spec). Implies -c.
Output =/X CIGAR operators for sequence match/mismatch. It rewrites every CIGAR the run realizes - the SAM CIGAR, SA:Z and PAF's cg:Z - and implies nothing, so plain PAF needs -c beside it.
In SAM output, use soft clipping for supplementary alignments. The default is hard clipping.
SAM read group line in a format like @RG\tID:foo\tSM:bar []. It must start with @RG and carry an ID field, and it adds RG:Z as the first tag of every SAM record.
In SAM, don't output unmapped reads.
In PAF, output unmapped queries; the strand and the reference name fields are set to `*', and every count to 0.
Don't output the SAM header.
With an overlap preset, whether an overlap is printed from each of its reads that finds it (yes) or once, from the shorter read, ties going to the read whose name sorts first (no), minimap2's --dual [no] (minimap2 prints from the read whose name sorts first). With no a read is not compared with a target read shorter than itself, or as long and earlier by name. Refused with any other preset.
Whether to output secondary alignments [no]. With yes, each alternative alignment of a read is written after the primary and its supplementary records: FLAG 0x100, or 0x900 on its continuation segments, tp:A:S in PAF, mapping quality 0, and `*' for SEQ and QUAL. A secondary record carries ms and its own chain's cm and s1, but no md, s2, SA or XA. Under a DNA preset with a CIGAR the secondary alignments are those of the chains aligned beside an owner that, after alignment, overlap a primary record by more than half of the shorter, at most -N per read; they are listed on the primary's XA. Without a CIGAR they are the chains kept beside an owner (-p), at most -N per read, each written from its whole chain, with no ms. The value may also be given as a separate word (--secondary yes); typed twice, the last one wins.
Copy input FASTA/Q comments to output, verbatim, as the last field of every record the read produces.
Number of threads [all-2]: mapping runs on the machine's hardware threads less the reader and the writer. An explicit value is the whole mapping budget, and decompression of compressed input borrows from it rather than adding to it: -t/8 threads, from 1 to 8, when every read input qualifies (BGZF or BAM of at least 16 MiB at any -t of 2 or more; other gzip of at least 64 MiB from -t 32) and --batch-window is above 1.
Number of bases loaded into memory to process in a mini-batch [500M]. As with -I, a k/K/m/M/g/G suffix is accepted. Output bytes and output order do not depend on it.
Print the fully resolved configuration to stdout and exit 0. It reads no reference base and no read, so flashalign align -x lr:hq --show-config is a complete invocation; of a .faix target it reads the header, except that with a DNA or splice preset and a single-part index it loads the index without its bases (with them under --junc-bed) and appends rows tagged [resolved]: the seed occurrence cap and its parts, and under a DNA preset the rescue window, the vote's bin width at four read lengths and the chain's band and reach.
Print a summary of the run to stderr: reads and bases, mapped reads, records written, wall time, throughput and peak memory.
Print per-batch progress to stderr.
Suppress non-error logging, including the three lines a run ends with on stderr: the version, the command line, and the real time, CPU time and peak memory.
Generate CIGAR and output alignments in the SAM format. FlashAlign outputs in PAF by default.
Number of batches in flight in the compute stage [the preset's: 1 on asm5, asm10 and asm20, 3 otherwise]. With 1, all threads finish a batch before the next one starts. Output bytes and order are identical for every value.
Ceiling, in MiB, on the decompressed gzip input staged ahead of the reader; 0 scales it with -t [0]. A non-zero value must be at least 64. BGZF and BAM input is not affected.

Preset [lr]. This option applies multiple options at the same time. An explicit -x also overrides the preset recorded in a .faix target; the index keeps its own (k, s). Available STR are:
Align noisy long reads of ~10% error rate to a reference genome. This is the default mode. (-k21 -s9 --min-support 3 -A4 -B8 -O8,48 -E4,1 -z800,200 --score-N 2 -r500,20000 -m40 -p0.8 -S80).
Align accurate long reads (error rate <1%), such as PacBio HiFi reads, to a reference genome (-k21 -s5 --min-support 3 -A3 -B12 -O18,78 -E6,1 -z1200,600 --score-N 3 -r500,20000 -g5000 -m40 -p0.8 -W48,64 -S200). Its alignments are scored with minimap2's map-hifi scoring (-A1 -B4 -O6,26 -E2,1, -S200).
Long-read spliced alignment (-k15 -s10 --min-support 2 -A1 -B2 -O2,32 -E1,0 -z200,100 -S80 --min-intron 20 -g2000 -G200k -ub --junc-bonus 9 -p0.8 -N5). In the splice mode a long deletion is taken as an intron and represented as the `N' CIGAR operator, and -m is refused. For Nanopore direct RNA, index with -k14 (flashalign index -x splice -k 14 ref.fa) and align with -x splice -u f.
Spliced alignment for accurate long RNA-seq reads such as PacBio Iso-Seq (-xsplice -B4 -O6,24 -W48). It differs from splice in scoring and also in the vote's diagonal bin (48 against 64), the vote spacing (16 against 8; see --vote-spacing) and the MAPQ coverage threshold (0.70 against 0.55).
Experimental. Long assembly to reference mapping (-k21 -s9 -A1 -B19 -O39,81 -E3,1 -z200,200 --score-N 1 -r1000,100000 -S200 -v4096,2048). Use this preset if the average divergence is not much higher than 0.1%.
Experimental. Long assembly to reference mapping (-xasm5 -B9 -O16,41 -E2,1). Use this if the average divergence is around 1%.
Experimental. Long assembly to reference mapping (-xasm5 -B4 -O6,26 -E2,1). Use this if the average divergence is around several percent.
Experimental. Oxford Nanopore all-vs-all overlap mapping (-k17 -s9 --min-support 2 -v256 --vote-ratio 0 -W64,64 --max-cands 16383 -m100 --dual=no). Output is PAF without CIGAR; -a and -c are refused. Read names must be unique.
Experimental. PacBio HiFi all-vs-all overlap mapping (-k21 -s5 --min-support 3 --vote-ratio 0 -W48,64 --max-cands 16383 -m100 --dual=no).

Print the help screen of the subcommand to stdout and exit 0. A subcommand invoked with no arguments prints the same screen to stderr and exits 2. The help screen lists the common options; this page lists every option.
Print the version number to stdout. flashalign --version and flashalign -V print the same line. Both spellings are top-level only: neither is an align or index option.

FlashAlign outputs in the PAF format by default; without -c, PAF output is approximate mapping, with no base-level alignment. -a selects the SAM format. FlashAlign writes no BAM; pipe its SAM to samtools sort for one, as in flashalign align -a ref.fa reads.fq | samtools sort -o out.bam. PAF is a TAB-delimited text format with each line consisting of at least 12 fields as are described in the following table:

Col Type Description
1 string Read name
2 int Read length
3 int Read start coordinate (0-based)
4 int Read end coordinate (0-based)
5 char `+' for forward strand; `-' for reverse
6 string Contig name
7 int Contig length
8 int Contig start coordinate on the original strand
9 int Contig end coordinate on the original strand
10 int Number of matching bases
11 int Number of bases in alignment
12 int Mapping quality (0-60)

When alignment is available, column 11 gives the total number of sequence matches, mismatches and gaps in the alignment; column 10 divided by column 11 gives the BLAST-like alignment identity. When alignment is unavailable, these two columns are approximate. SAM and PAF may optionally have additional fields in the SAM-like typed key-value format. FlashAlign may output the following tags:

Tag Type Description
AS i Alignment score from dynamic programming
ms i Score of the maximum scoring segment
md i Max score minus secondary max score
NM i Edit distance
nn i Number of ambiguous bases in the alignment
tp A Type of aln: P/primary, S/secondary, I/inversion
cm i Number of anchors on the chain; FlashAlign's anchors are syncmers
s1 i Chaining score
s2 i Chaining score of the best secondary chain
de f Gap-compressed per-base sequence divergence
ts A Transcript strand (splice mode only)
RG Z Read group ID from -R (SAM only)
SA Z List of other supplementary alignments (SAM only)
XA Z Secondary hits in (ctg,strandPos,CIGAR,NM;)+ (SAM only)
cg Z CIGAR (PAF only)
cs Z Difference string
MD Z Difference string in the SAM spec

Tags md, s2 and XA are not written on a secondary alignment. cm and s1 describe the chain a record comes from, the chain s2 is compared against. s2 is taken over every rival the mapping quality weighs, before -p applies, as in minimap2. A secondary alignment carries its own chain's. Under the DNA presets but ava-ont and ava-hifi, a primary or supplementary record carries the anchor count and score of its own part of that chain. A record without a chain, such as the inverted middle of a DNA alignment, carries none of the three.

In SAM, the tags of a BAM input record ride every record of its read, spelled as samtools view spells them, after FlashAlign's own tags and before SA. MM, ML, MN and a B array with one element per base of the read are left off a record whose SEQ is not the whole read: a hard-clipped supplementary and a secondary alignment. An input tag that FlashAlign writes itself is dropped with a warning. The headers of the BAM inputs are merged: their @PG lines come before FlashAlign's, whose PP names the first input's last program, and their @RG and @CO lines after it; one read group ID declared differently by two inputs is an error. An aligned BAM is read as reads: its secondary and supplementary records are skipped and a mapped record loses its alignment tags. PAF carries no input tag.

The cs tag encodes difference sequences in the short form or the entire query AND reference sequences in the long form. It consists of a series of operations:

Op Regex Description
= [ACGTN]+ Identical sequence (long form)
: [0-9]+ Identical sequence length
* [acgtn][acgtn] Substitution: ref to query
+ [acgtn]+ Insertion to the reference
- [acgtn]+ Deletion from the reference
~ [acgtn]{2}[0-9]+[acgtn]{2} Intron length and splice signal

0
Success, and every --help path, which prints to stdout.
1
Runtime failure: a missing or unreadable input, a write failure, CRAM or SAM text handed in as reads, a closed output, or an option the resolved preset cannot honour, such as a scoring row that fails its check or a -r pair whose first value exceeds the second. One error line on stderr, no hint.
2
Usage error: an unknown command, an unknown option, a bad value or a missing operand. One error line plus one hint line on stderr. flashalign with no arguments, and flashalign align or flashalign index with no arguments, print their help screen to stderr and exit 2 instead.

*
Long reads only: a read has to carry enough anchors to be collapsed into one or more diagonals.
*
FlashAlign requires SSE4.1 instructions on x86 CPUs or NEON on ARM CPUs. A build without them is not provided.
*
The assembly and overlap presets are experimental.

samtools(1).

21 October 2026 flashalign-0.4.0