FASTQ Files
Raw sequencing output is typically stored in FASTQ format, frequently compressed as .fq.gz. Each read occupies four lines:
- Line 1: identifier starting with
@ - Line 2: nucleotide sequence
- Line 3: a separator (usually
+) - Line 4: per‑base quality scores (ASCII-encoded)
Common inspection commands:
# Display the first two reads
zcat sample_R1.fq.gz | head -8
# Count total reads (in millions)
echo "$(zcat sample_R1.fq.gz | wc -l) / 4 / 1000000" | bc -l
Alternatively, use awk to tally total bases:
zcat sample_R1.fq.gz | awk 'NR%4==0 {bases += length($0)} END {printf "%.2f Gb\n", bases/1e9}'
FASTA Genome Files
The reference genome, often obtained from Ensembl, is distributed in FASTA format. Each sequence begins with a header line (starting with >), followed by one or more lines of nucleotides. Soft‑masked genomes use lowercase letters for repetitive regions; unknown bases appear as N.
olenTo harmonise chromosome names by adding a chr prefix and stripping superfluous annotations:
awk '/^>/ {if($0 !~ /^>chr/) sub(/^>/,">chr"); split($1,a," "); print a[1]; next} {print}' \
Homo_sapiens.GRCh38.dna.primary_assembly.fa > GRCh38.fa
Gene Annotation: GTF and GFF
Both GTF (Gene Transfer Format) and GFF (General Feature Format) are nine‑column, tab‑delimited tables that describe gene models. Columns 1‑8 are16 nearly identical; the ninth column encodes different attributes. To prepare an Ensembl GTF for downstream analysis, remove comment lines (prefix #) and ensure chromosome names match the reference:
zcat Homo_sapiens.GRCh38.94.gtf.gz | grep -v '^#' | sed '/^[^chr]/ s/^/chr/' > GRCh38.gtf
BED Files
BED files define genomic intervals using a zero‑based, half‑open coordinate system. Unlike GTF/GFF, each row usually represents an entire gene. The three mandatory columns are: chrom, chromStart, chromEnd. Optional columns include:
name– identifiolenscore– display value (0‑1000)strand–+,-, or.thickStart/thickEnd– CDS boundariesitemRgb– RGB colour valueblockCount,blockSizes,blockStarts– exon structure (BED12)
SAM and BAM Alignment Files
The SAM (Sequence Alignment/Map) format stores read alignmenst as plain text; BAM is its binary, compressed counterpart. Use samtools view to inspect BAM files:
# Read without header
samtools view alignments.bam | less -S
# Include header
samtools view -h alignments.bam | less -S
Header sections start with @ and carry metadata about sequences (@SQ), read groups (@RG), and programs (@PG). Each alignment record contains 12 mandatory tab‑delimited fields: read name, bitwise flag, reference name, leftmost position, mapping quality, CIGAR string, mate information, sequence, and quality.
The FLAG field (column 2) is a bitwise combination of descriptors (e.g., read paired, read unmapped). Flags like 99 or 147 indicate properly paired reads. Flag statistics can be generated with:
samtools flagstat alignments.bam
Online decoders such as SAM Format simplify flag interpretation.
Wiggle, BigWig, and BedGraph
These formats encode coverage or density signals for genome browsers.
- bedGraph: a four‑column format (
chrom,chromStart,chromEnd,value), zero‑based. - Wiggle (WIG): variable‑step or fixed‑step tracks describing per‑position27 intensity.
- bigWig: indexed binary version of WIG, generated with the
wigToBigWigtool.
lierThey are frequently produced in ChIP‑seq call peak steps and visualised in IGV. See the UCSC documentation for detailed specifications of wiggle, bedGraph, and bigWig.