<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[fasta fastq]]></title><description><![CDATA[<p dir="auto"><a href="https://bioinformatics.stackexchange.com/questions/14/what-is-the-difference-between-fasta-fastq-and-sam-file-formats#:~:text=FASTA%20to%20store%20the%20reference,the%20sequence%20fragments%20after%20mapping" rel="nofollow ugc">https://bioinformatics.stackexchange.com/questions/14/what-is-the-difference-between-fasta-fastq-and-sam-file-formats#:~:text=FASTA to store the reference,the sequence fragments after mapping</a>.</p>
<p dir="auto">Let’s start with what they have in common: All three formats store</p>
<p dir="auto">sequence data, and<br />
sequence metadata.<br />
Furthermore, all three formats are text-based.</p>
<p dir="auto">However, beyond that all three formats are different and serve different purposes.</p>
<p dir="auto">Let’s start with the simplest format:</p>
<p dir="auto">FASTA<br />
FASTA stores a variable number of sequence records, and for each record it stores the sequence itself, and a sequence ID. Each record starts with a header line whose first character is &gt;, followed by the sequence ID. The next lines of a record contain the actual sequence.</p>
<p dir="auto">The Wikipedia artice gives several examples for peptide sequences, but since FASTQ and SAM are used exclusively (?) for nucleotide sequences, here’s a nucleotide example:</p>
<blockquote>
<p dir="auto">Mus_musculus_tRNA-Ala-AGC-1-1 (chr13.trna34-AlaAGC)<br />
GGGGGTGTAGCTCAGTGGTAGAGCGCGTGCTTAGCATGCACGAGGcCCTGGGTTCGATCC<br />
CCAGCACCTCCA<br />
Mus_musculus_tRNA-Ala-AGC-10-1 (chr13.trna457-AlaAGC)<br />
GGGGGATTAGCTCAAATGGTAGAGCGCTCGCTTAGCATGCAAGAGGtAGTGGGATCGATG<br />
CCCACATCCTCCA<br />
The ID can be in any arbitrary format, although several conventions exist.</p>
</blockquote>
<p dir="auto">In the context of nucleotide sequences, FASTA is mostly used to store reference data; that is, data extracted from a curated database; the above is adapted from GtRNAdb (a database of tRNA sequences).</p>
<p dir="auto">FASTQ<br />
FASTQ was conceived to solve a specific problem arising during sequencing: Due to how different sequencing technologies work, the confidence in each base call (that is, the estimated probability of having correctly identified a given nucleotide) varies. This is expressed in the Phred quality score. FASTA had no standardised way of encoding this. By contrast, a FASTQ record contains a sequence of quality scores for each nucleotide.</p>
<p dir="auto">A FASTQ record has the following format:</p>
<p dir="auto">A line starting with @, containing the sequence ID.<br />
One or more lines that contain the sequence.<br />
A new line starting with the character +, and being either empty or repeating the sequence ID.<br />
One or more lines that contain the quality scores.<br />
Here’s an example of a FASTQ file with two records:</p>
<p dir="auto">@071112_SLXA-EAS1_s_7:5:1:817:345<br />
GGGTGATGGCCGCTGCCGATGGCGTC<br />
AAATCCCACC<br />
+<br />
IIIIIIIIIIIIIIIIIIIIIIIIII<br />
IIII9IG9IC<br />
@071112_SLXA-EAS1_s_7:5:1:801:338<br />
GTTCAGGGATACGACGTTTGTATTTTAAGAATCTGA<br />
+<br />
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII6IBI<br />
FASTQ files are mostly used to store short-read data from high-throughput sequencing experiments. The sequence and quality scores are usually put into a single line each, and indeed many tools assume that each record in a FASTQ file is exactly four lines long, even though this isn’t guaranteed.</p>
<p dir="auto">As with FASTA, the format of the sequence ID isn’t standardised, but different producers of FASTQ use fixed notations that follow strict conventions.</p>
<p dir="auto">SAM<br />
SAM files are so complex that a complete description [PDF] takes 15 pages. So here’s the short version.</p>
<p dir="auto">The original purpose of SAM files is to store mapping information for sequences from high-throughput sequencing. As a consequence, a SAM record needs to store more than just the sequence and its quality, it also needs to store information about where and how a sequence maps into the reference.</p>
<p dir="auto">Unlike the previous formats, SAM is tab-based, and each record, consisting of either 11 or 12 fields, fills exactly one line. Here’s an example (tabs replaced by fixed-width spacing):</p>
<p dir="auto">r001  99  chr1  7 30  17M         =  37  39  TTAGATAAAGGATACTG   IIIIIIIIIIIIIIIII<br />
r002  0   chrX  9 30  3S6M1P1I4M  *  0   0   AAAAGATAAGGATA      IIIIIIIIII6IBI    NM:i:1<br />
For a description of the individual fields, refer to the documentation. The relevant bit is this: SAM can express exactly the same information as FASTQ, plus, as mentioned, the mapping information. However, SAM is also used to store read data without mapping information.</p>
<p dir="auto">In addition to sequence records, SAM files can also contain a header, which stores information about the reference that the sequences were mapped to, and the tool used to create the SAM file. Header information precede the sequence records, and consist of lines starting with @.</p>
<p dir="auto">SAM itself is almost never used as a storage format; instead, files are stored in BAM format, which is a compact binary representation of SAM. It stores the same information, just more efficiently and, in conjunction with a search index, allows fast retrieval of individual records from the middle of the file (= fast random access). BAM files are also much more compact than compressed FASTQ or FASTA files.</p>
<p dir="auto">The above implies a hierarchy in what the formats can store: FASTA ⊂ FASTQ ⊂ SAM.</p>
<p dir="auto">In a typical high-throughput analysis workflow, you will encounter all three file types:</p>
<p dir="auto">FASTA to store the reference genome/transcriptome that the sequence fragments will be mapped to.<br />
FASTQ to store the sequence fragments before mapping.<br />
SAM/BAM to store the sequence fragments after mapping.</p>
]]></description><link>http://an.forum.genostack.com/topic/54/fasta-fastq</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 09:22:12 GMT</lastBuildDate><atom:link href="http://an.forum.genostack.com/topic/54.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Aug 2020 03:08:00 GMT</pubDate><ttl>60</ttl></channel></rss>