Reverse Complement (FASTQ)

Generate reverse-complemented FASTQ reads while preserving quality scores

Supported formats: FASTQ, FQ and compressed FASTQ files (.fastq.gz, .fq.gz) (Maximum size: 500 MB)

Reverse Complement

Function

Generates the reverse complement of each read in a FASTQ file. Sequences are reversed and complemented (A↔T, C↔G), while quality score strings are reversed to maintain base-quality correspondence.


Input Format

  • FASTQ files (.fastq, .fq)
  • Compressed FASTQ files (.fastq.gz, .fq.gz)
  • Optional output file name.

Output Format

  • Reverse-complemented FASTQ file.
  • Read identifiers remain unchanged.
  • Quality scores are reversed.
  • Same number of reads as input.

Applications

  • Strand correction.
  • Preparing reads for downstream tools.
  • Adapter and primer analysis.
  • Handling reverse-strand sequencing protocols.
  • Comparative motif analysis.

Example

Original

@read1
ATCG
+
FFFF

↓

@read1
CGAT
+
FFFF

SeqKit Example

seqkit seq -r -p \
input.fastq.gz \
-o revcomp.fastq.gz

FASTX Toolkit Example

fastx_reverse_complement \
-i input.fastq \
-o revcomp.fastq

Biopython Example

from Bio import SeqIO

with open("revcomp.fastq", "w") as out:
    for record in SeqIO.parse(
            "input.fastq",
            "fastq"):
        SeqIO.write(
            record.reverse_complement(
                id=record.id,
                description=""
            ),
            out,
            "fastq"
        )

Suggested Reading


Important Notes:
  • Quality strings are reversed along with sequences to preserve alignment between bases and quality scores.
  • Read identifiers remain unchanged.
  • Reverse complementing already correctly oriented reads may lead to incorrect downstream analysis.
  • Use only when strand orientation needs to be flipped.
  • Keep the original FASTQ file as a backup.