Reading one FASTQ record
FASTQ: a sequence and confidence in its bases
Understand the input before choosing an analysis. This four-line example is synthetic, not real experimental data.
1. A typical four-line record
1 | @practice_read_001 |
The first line starts with @ and identifies the read. The second contains the bases. The third starts with +. The fourth encodes base qualities; its length must match the sequence. Check format requirements in the NCBI SRA FASTQ guide.
2. Quality is not a percentage
The Phred definition is:
$$Q=-10\log_{10}(P_{\mathrm{error}})$$
Directly from this definition, Q20 corresponds to error probability 0.01, and Q30 to 0.001. These are confidence values for individual base calls, not a reliability score for the entire read or sample.
Modern FASTQ commonly uses Phred+33: subtract 33 from the ASCII value of the quality character. Here I gives 73−33=40. Do not assume the encoding for unidentified legacy data; check its documentation first.
3. Preview without expanding the whole file
1 | gzip -cd sample_R1.fastq.gz | head -n 8 |
This previews two typical four-line records. It neither validates the entire file nor provides a general method for counting reads. With some shell settings, head stopping early can cause an upstream broken-pipe message; that alone is not evidence of file corruption.
4. What to check next
- Do sample identifiers match the experimental metadata?
- Is the library single-end or paired-end, and are R1/R2 paired correctly?
- Do read length, quality and adapters need more investigation?
- Are any samples clear outliers relative to comparable libraries?
Eight lines are insufficient to assess sequencing quality. Read a complete QC report in the context of the library type. See the official FastQC project for its modules and documentation.
Exercise
Remove one base from the example but leave the quality line unchanged. Explain the resulting inconsistency. Then independently calculate the error probability corresponding to Q10.
Continue
The bioinformatics handbook has additional Chinese workflow and QC chapters. The English collection contains other complete English guides.