Count Reads / Sequences

Count reads, sequences, bases and length statistics from FASTA/FASTQ files

Supports FASTQ, FASTA and compressed (.gz) files. Multiple files allowed.
Count Bases & Average Read Length
Read-Length Histogram
Quiet Mode
Optional output file path.

Count Reads / Sequences

Function

Count Reads reports the total number of reads (FASTQ) or sequences (FASTA) in one or more input files. Optional statistics include total bases, average read length, and read-length distributions.


Input Format

  • FASTQ files (.fastq, .fq)
  • FASTA files (.fasta, .fa, .fna)
  • Compressed files (.gz)
  • Multiple files can be analyzed together.

Output Format

  • Read or sequence count.
  • Total base count.
  • Average read length.
  • Read length histogram (optional).
  • Text, TSV or JSON output.

Applications

  • Sequencing QC.
  • Sample size verification.
  • Dataset size estimation.
  • Pipeline validation.
  • Read length assessment.

Example Usage

Count reads in FASTQ:

echo $(wc -l < sample.fastq) / 4 | bc

Count reads in compressed FASTQ:

echo $(zcat sample.fastq.gz | wc -l) / 4 | bc

Count sequences in FASTA:

grep -c "^>" sample.fasta

Using SeqKit:

seqkit stats sample.fastq.gz

seqkit stats *.fastq.gz

Suggested Reading


Important Notes:
  • FASTQ counts are based on records, not simple line counts.
  • FASTA counts are based on sequence headers.
  • Base count statistics require reading every sequence.
  • Large files may take longer when histogram generation is enabled.
  • Auto-detection is performed using file contents rather than file extensions.