Lably
Skip to content

FASTQ format

  • 14 min read
  • 4 chapters

Related on Lably

Through File format, ASCII and De facto and de jure

It was originally developed at the Wellcome Trust Sanger Institute to bundle a FASTA formatted sequence and its quality data, but has become the de facto standard for storing the output of high-throughput sequencing instruments such as the Illumina Genome Analyzer.

Format

A FASTQ file has four line-separated fields per sequence:

  • Field 1 begins with a '@' character and is followed by a sequence identifier and an optional description (like a FASTA title line).
  • Field 2 is the raw sequence letters.
  • Field 3 begins with a '+' character and is optionally followed by the same sequence identifier (and any description) again.
  • Field 4 encodes the quality values for the sequence in Field 2, and must contain the same number of symbols as letters in the sequence.

A FASTQ file containing a single sequence might look like this:

@SEQ_ID GATTTGGGGTTCAAAGCAGTATCGATCAAATAGTAAATCCATTTGTTCAACTCACAGTTT + !''*((((***+))%%%++)(%%%%).1***-+*''))**55CCF>>>>>>CCCCCCC65

The byte representing quality runs from 0x21 (lowest quality; '!' in ASCII) to 0x7e (highest quality; '~' in ASCII). Here are the quality value characters in left-to-right increasing order of quality (ASCII):

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

The original Sanger FASTQ files split long sequences and quality strings over multiple lines, as is typically done for FASTA files. Accounting for this makes parsing more complicated due to the choice of "@" and "+" as markers (as these characters can also occur in the quality string). Multi-line FASTQ files (and consequently multi-line FASTQ parsers) are less common now that the majority of sequencing carried out is short-read Illumina sequencing, with typical sequence lengths of around 100bp.

Illumina sequence identifiers

Sequences from the Illumina software use a systematic identifier:

<span id="mwKw"></span><span class="s" id="mwLA">@HWUSI-EAS100R</span><span class="p" id="mwLQ">:</span><span class="m" id="mwLg">6</span><span class="p" id="mwLw">:</span><span class="m" id="mwMA">73</span><span class="p" id="mwMQ">:</span><span class="m" id="mwMg">941</span><span class="p" id="mwMw">:</span><span class="m" id="mwNA">1973</span><span class="s" id="mwNQ">#0/1</span>

Versions of the Illumina pipeline since 1.4 appear to use #NNNNNN instead of #0 for the multiplex ID, where NNNNNN is the sequence of the multiplex tag.

With Casava 1.8 the format of the '@' line has changed:

<span id="mwVQ"></span><span class="s" id="mwVg">@EAS139</span><span class="p" id="mwVw">:</span><span class="m" id="mwWA">136</span><span class="p" id="mwWQ">:</span>FC706VJ<span class="p" id="mwWg">:</span><span class="m" id="mwWw">2</span><span class="p" id="mwXA">:</span><span class="m" id="mwXQ">2104</span><span class="p" id="mwXg">:</span><span class="m" id="mwXw">15343</span><span class="p" id="mwYA">:</span><span class="m" id="mwYQ">197393</span> 1<span class="p" id="mwYg">:</span><span class="s" id="mwYw">Y</span><span class="p" id="mwZA">:</span><span class="m" id="mwZQ">18</span><span class="p" id="mwZg">:</span>ATCACG

Note that more recent versions of Illumina software output a sample number (defined by the order of the samples in the sample sheet) in place of an index sequence when an index sequence is not explicitly specified for a sample in the sample sheet. For example, the following header might appear in a FASTQ file belonging to the first sample of a batch of samples:

<span id="mwjg"></span><span class="s" id="mwjw">@EAS139</span><span class="p" id="mwkA">:</span><span class="m" id="mwkQ">136</span><span class="p" id="mwkg">:</span>FC706VJ<span class="p" id="mwkw">:</span><span class="m" id="mwlA">2</span><span class="p" id="mwlQ">:</span><span class="m" id="mwlg">2104</span><span class="p" id="mwlw">:</span><span class="m" id="mwmA">15343</span><span class="p" id="mwmQ">:</span><span class="m" id="mwmg">197393</span> 1<span class="p" id="mwmw">:</span><span class="s" id="mwnA">N</span><span class="p" id="mwnQ">:</span><span class="m" id="mwng">18</span><span class="p" id="mwnw">:</span><span class="m" id="mwoA">1</span>

NCBI Sequence Read Archive

FASTQ files from the INSDC Sequence Read Archive often include a description, e.g.

<span id="mwpw"></span><span class="s" id="mwqA">@SRR001666.1 071112_SLXA-EAS1_s_7</span><span class="p" id="mwqQ">:</span><span class="m" id="mwqg">5</span><span class="p" id="mwqw">:</span><span class="m" id="mwrA">1</span><span class="p" id="mwrQ">:</span><span class="m" id="mwrg">817</span><span class="p" id="mwrw">:</span><span class="m" id="mwsA">345</span> length<span class="s" id="mwsQ">=36</span> GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACC <span class="s" id="mwsg">+SRR001666.1 071112_SLXA-EAS1_s_7</span><span class="p" id="mwsw">:</span><span class="m" id="mwtA">5</span><span class="p" id="mwtQ">:</span><span class="m" id="mwtg">1</span><span class="p" id="mwtw">:</span><span class="m" id="mwuA">817</span><span class="p" id="mwuQ">:</span><span class="m" id="mwug">345</span> length<span class="s" id="mwuw">=36</span> IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9IC

In this example there is an NCBI-assigned identifier, and the description holds the original identifier from Solexa/Illumina (as described above) plus the read length. Sequencing was performed in paired-end mode (~500bp insert size), see SRR001666. The default output format of fastq-dump produces entire spots, containing any technical reads and typically single or paired-end biological reads.

<span id="mwwQ"></span><span class="gp" id="mwwg">$ </span>fastq-dump.2.9.0<span class="w" id="mwww"> </span>-Z<span class="w" id="mwxA"> </span>-X<span class="w" id="mwxQ"> </span><span class="m" id="mwxg">2</span><span class="w" id="mwxw"> </span>SRR001666 <span class="go" id="mwyA">Read 2 spots for SRR001666</span> <span class="go" id="mwyQ">Written 2 spots for SRR001666</span> <span class="go" id="mwyg">@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=72</span> <span class="go" id="mwyw">GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACCAAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA</span> <span class="go" id="mwzA">+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=72</span> <span class="go" id="mwzQ">IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9ICIIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/</span> <span class="go" id="mwzg">@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=72</span> <span class="go" id="mwzw">GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGAAGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT</span> <span class="go" id="mw0A">+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=72</span> <span class="go" id="mw0Q">IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBIIIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I</span>

Modern usage of FASTQ almost always involves splitting the spot into its biological reads, as described in submitter-provided metadata:

<span id="mw1Q"></span><span class="gp" id="mw1g">$ </span>fastq-dump<span class="w" id="mw1w"> </span>-X<span class="w" id="mw2A"> </span><span class="m" id="mw2Q">2</span><span class="w" id="mw2g"> </span>SRR001666<span class="w" id="mw2w"> </span>--split-3 <span class="go" id="mw3A">Read 2 spots for SRR001666</span> <span class="go" id="mw3Q">Written 2 spots for SRR001666</span> <span class="gp" id="mw3g">$ </span>head<span class="w" id="mw3w"> </span>SRR001666_1.fastq<span class="w" id="mw4A"> </span>SRR001666_2.fastq <span class="go" id="mw4Q">==> SRR001666_1.fastq <==</span> <span class="go" id="mw4g">@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36</span> <span class="go" id="mw4w">GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACC</span> <span class="go" id="mw5A">+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36</span> <span class="go" id="mw5Q">IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9IC</span> <span class="go" id="mw5g">@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36</span> <span class="go" id="mw5w">GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGA</span> <span class="go" id="mw6A">+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36</span> <span class="go" id="mw6Q">IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBI</span> <span class="go" id="mw6g">==> SRR001666_2.fastq <==</span> <span class="go" id="mw6w">@SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36</span> <span class="go" id="mw7A">AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA</span> <span class="go" id="mw7Q">+SRR001666.1 071112_SLXA-EAS1_s_7:5:1:817:345 length=36</span> <span class="go" id="mw7g">IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/</span> <span class="go" id="mw7w">@SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36</span> <span class="go" id="mw8A">AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT</span> <span class="go" id="mw8Q">+SRR001666.2 071112_SLXA-EAS1_s_7:5:1:801:338 length=36</span> <span class="go" id="mw8g">IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I</span>

When present in the archive, fastq-dump can attempt to restore read names to original format. NCBI does not store original read names by default:

<span id="mw9g"></span><span class="gp" id="mw9w">$ </span>fastq-dump<span class="w" id="mw-A"> </span>-X<span class="w" id="mw-Q"> </span><span class="m" id="mw-g">2</span><span class="w" id="mw-w"> </span>SRR001666<span class="w" id="mw_A"> </span>--split-3<span class="w" id="mw_Q"> </span>--origfmt <span class="go" id="mw_g">Read 2 spots for SRR001666</span> <span class="go" id="mw_w">Written 2 spots for SRR001666</span> <span class="gp" id="mwAQA">$ </span>head<span class="w" id="mwAQE"> </span>SRR001666_1.fastq<span class="w" id="mwAQI"> </span>SRR001666_2.fastq <span class="go" id="mwAQM">==> SRR001666_1.fastq <==</span> <span class="go" id="mwAQQ">@071112_SLXA-EAS1_s_7:5:1:817:345</span> <span class="go" id="mwAQU">GGGTGATGGCCGCTGCCGATGGCGTCAAATCCCACC</span> <span class="go" id="mwAQY">+071112_SLXA-EAS1_s_7:5:1:817:345</span> <span class="go" id="mwAQc">IIIIIIIIIIIIIIIIIIIIIIIIIIIIII9IG9IC</span> <span class="go" id="mwAQg">@071112_SLXA-EAS1_s_7:5:1:801:338</span> <span class="go" id="mwAQk">GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGA</span> <span class="go" id="mwAQo">+071112_SLXA-EAS1_s_7:5:1:801:338</span> <span class="go" id="mwAQs">IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBI</span> <span class="go" id="mwAQw">==> SRR001666_2.fastq <==</span> <span class="go" id="mwAQ0">@071112_SLXA-EAS1_s_7:5:1:817:345</span> <span class="go" id="mwAQ4">AAGTTACCCTTAACAACTTAAGGGTTTTCAAATAGA</span> <span class="go" id="mwAQ8">+071112_SLXA-EAS1_s_7:5:1:817:345</span> <span class="go" id="mwARA">IIIIIIIIIIIIIIIIIIIIDIIIIIII>IIIIII/</span> <span class="go" id="mwARE">@071112_SLXA-EAS1_s_7:5:1:801:338</span> <span class="go" id="mwARI">AGCAGAAGTCGATGATAATACGCGTCGTTTTATCAT</span> <span class="go" id="mwARM">+071112_SLXA-EAS1_s_7:5:1:801:338</span> <span class="go" id="mwARQ">IIIIIIIIIIIIIIIIIIIIIIGII>IIIII-I)8I</span>

In the example above, the original read names were used rather than the accessioned read name. NCBI accessions runs and the reads they contain. Original read names, assigned by sequencers, are able to function as locally unique identifiers of a read, and convey exactly as much information as a serial number. The ids above were algorithmically assigned based upon run information and geometric coordinates. Early SRA loaders parsed these ids and stored their decomposed components internally. NCBI stopped recording read names because they are frequently modified from the vendors' original format in order to associate some additional information meaningful to a particular processing pipeline, and this caused name format violations that resulted in a high number of rejected submissions. Without a clear schema for read names, their function remains that of a unique read id, conveying the same amount of information as a read serial number. See various SRA Toolkit issues for details and discussions.

Also note that fastq-dump converts this FASTQ data from the original Solexa/Illumina encoding to the Sanger standard (see encodings below). This is because the SRA serves as a repository for NGS information, rather than format. The various *-dump tools are capable of producing data in several formats from the same source. The requirements for doing so have been dictated by users over several years, with the majority of early demand coming from the 1000 Genomes Project.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Biology