Read Preprocessing with Cutadapt, fastp, and Related Tools

  • Read preprocessing is an essential stage of bioinformatics analysis in which raw sequencing reads are examined, cleaned, filtered, and prepared for downstream applications. Sequencing instruments generate raw reads that may contain adapter sequences, low-quality bases, primer contamination, ambiguous nucleotides, short fragments, and other technical artifacts. These unwanted sequences can interfere with read alignment, genome assembly, variant detection, gene expression analysis, and metagenomic classification. Read preprocessing aims to improve the usability of sequencing data while preserving as much genuine biological information as possible. Several widely used tools, including Cutadapt, fastp, Trimmomatic, BBDuk, and related programs, support different aspects of this process.
  • Raw sequencing reads are commonly stored in FASTQ files, which contain nucleotide sequences and corresponding quality scores. Each read has a sequence identifier, the nucleotide sequence, a separator line, and a string of quality characters representing the confidence of each base call. The quality scores are commonly expressed using the Phred scale. A Phred score is calculated as (Q=-10\log_{10}(P)), where (P) is the estimated probability that a base call is incorrect. Low-quality bases have a greater probability of being incorrect and may reduce the reliability of downstream analyses.
  • Read preprocessing usually includes several operations. Adapter trimming removes artificial sequences introduced during library preparation. Primer trimming removes primer-derived sequences from amplicon or targeted sequencing reads. Quality trimming removes low-confidence bases, particularly near read ends. Read filtering excludes reads that do not satisfy selected quality, length, or ambiguity criteria. Additional processing may remove poly-G tails, poly-A sequences, low-complexity reads, or unwanted contaminants. The exact operations depend on the sequencing technology, library preparation method, and biological objective.
  • Adapter sequences are introduced during library preparation to enable sequencing, amplification, and attachment of DNA fragments to the sequencing platform. When the original DNA fragment is shorter than the sequencing read length, the instrument may continue reading into the adapter sequence. This produces adapter contamination, which can cause inaccurate alignment and assembly. Adapter sequences must therefore be identified and removed using the correct sequences for the library preparation protocol. The adapter sequence should not be assumed to be identical across all sequencing experiments.
  • Cutadapt is a widely used tool for identifying and removing adapter sequences, primers, and other unwanted sequence elements from sequencing reads. It supports single-end and paired-end reads and provides flexible options for handling adapters at the 5′ and 3′ ends, linked adapters, anchored adapters, and partially observed adapter sequences. It is particularly useful in amplicon sequencing, small RNA sequencing, RNA sequencing, and other workflows where specific primers or adapters must be removed.
  • A basic Cutadapt command for single-end sequencing is:

cutadapt \

  -a AGATCGGAAGAGC \

  -o trimmed.fastq.gz \

  sample.fastq.gz

  • The -a option specifies a 3′ adapter sequence, while -o specifies the output file. The adapter sequence shown is an illustrative common Illumina adapter motif and should be replaced with the actual adapter sequence used in the library preparation protocol.
  • For paired-end sequencing, Cutadapt uses separate input and output files for the forward and reverse reads. The following example demonstrates adapter trimming and quality filtering:

cutadapt \

  -a ADAPTER_R1 \

  -A ADAPTER_R2 \

  -q 20 \

  -m 50 \

  -o trimmed_R1.fastq.gz \

  -p trimmed_R2.fastq.gz \

  sample_R1.fastq.gz \

  sample_R2.fastq.gz

  • Here, -a and -A specify the adapter sequences for the first and second reads, respectively. The -q 20 option performs quality trimming using a Phred threshold of 20, while -m 50 discards reads shorter than 50 bases after processing. These values are examples rather than universal thresholds. They should be adjusted according to the sequencing experiment and downstream requirements.
  • Cutadapt can also remove primers from amplicon sequencing data. Primer removal is important because primer sequences are artificial components of the amplification process and may interfere with sequence classification, variant analysis, and multiple sequence alignment. Cutadapt supports flexible matching options that can account for partial primer sequences and mismatches. In paired-end amplicon workflows, both forward and reverse primers should be handled correctly, and researchers should verify that primer removal has not removed genuine target sequence.
  • fastp is another widely used tool for sequencing read preprocessing. It combines adapter detection, quality filtering, trimming, read length filtering, and several additional processing functions in a single program. It supports single-end and paired-end short-read data and produces both HTML and JSON quality-control reports. Its integrated functions make it useful for workflows that require rapid processing of large sequencing datasets.
  • A basic fastp command for paired-end sequencing is:

fastp \

  -i sample_R1.fastq.gz \

  -I sample_R2.fastq.gz \

  -o trimmed_R1.fastq.gz \

  -O trimmed_R2.fastq.gz \

  –detect_adapter_for_pe \

  –qualified_quality_phred 20 \

  –length_required 50 \

  –thread 8 \

  –html fastp_report.html \

  –json fastp_report.json

  • The -i and -I options specify the input forward and reverse reads, while -o and -O specify the processed output files. The –detect_adapter_for_pe option enables adapter detection for paired-end data. The –qualified_quality_phred option specifies the quality threshold used for base qualification, and –length_required defines the minimum retained read length. The HTML and JSON reports summarize the preprocessing results, including read counts, quality distributions, adapter removal, and filtering statistics.
  • fastp also supports additional operations, including poly-G trimming, poly-X trimming, correction of overlapping paired-end reads, and filtering based on ambiguous bases. Some options are particularly useful for particular sequencing platforms or library types. For example, poly-G trimming can help address certain two-colour Illumina sequencing artifacts. However, these options should be enabled only when appropriate for the sequencing data. Automatic detection and trimming do not replace examination of the original quality-control reports.
  • Trimmomatic is another established tool for preprocessing Illumina sequencing reads. It supports adapter removal, quality trimming, sliding-window filtering, and minimum read length filtering. It can process both single-end and paired-end datasets and provides options for handling paired reads that survive filtering separately from reads whose mates are removed.
  • A typical paired-end Trimmomatic command is:

trimmomatic PE \

  -threads 8 \

  sample_R1.fastq.gz \

  sample_R2.fastq.gz \

  trimmed_R1_paired.fastq.gz \

  trimmed_R1_unpaired.fastq.gz \

  trimmed_R2_paired.fastq.gz \

  trimmed_R2_unpaired.fastq.gz \

  ILLUMINACLIP:adapters.fa:2:30:10 \

  SLIDINGWINDOW:4:20 \

  MINLEN:50

  • The PE option indicates paired-end processing. ILLUMINACLIP removes adapter sequences using a supplied adapter file, while SLIDINGWINDOW:4:20 applies a sliding-window quality filter using a window of four bases and a minimum average quality threshold of 20. MINLEN:50 discards reads shorter than 50 bases. The paired and unpaired output files preserve information about whether both mates survived preprocessing. The adapter file should contain the appropriate sequences for the library preparation method.
  • BBDuk, part of the BBTools suite, provides another flexible approach to read preprocessing. It can remove adapters, filter contaminants, trim low-quality bases, filter reads by length, and identify or process reads containing specified sequence patterns. It can also support k-mer-based filtering against reference sequences. BBDuk is useful in genomic, metagenomic, and other sequencing workflows where several types of sequence filtering are required.
  • An illustrative BBDuk command for paired-end data is:

bbduk.sh \

  in1=sample_R1.fastq.gz \

  in2=sample_R2.fastq.gz \

  out1=trimmed_R1.fastq.gz \

  out2=trimmed_R2.fastq.gz \

  ref=adapters.fa \

  ktrim=r \

  k=23 \

  mink=11 \

  hdist=1 \

  qtrim=rl \

  trimq=20 \

  minlen=50 \

  threads=8

  • This example uses a reference adapter file and k-mer matching to identify adapter sequences. The ktrim=r option trims matching sequence from the right side, while qtrim=rl enables quality trimming from both ends. The trimq and minlen options specify the quality threshold and minimum read length. BBDuk has many additional parameters, so the reference sequences and settings should be selected according to the experimental design.
  • SeqKit is a general-purpose FASTA and FASTQ processing toolkit. It supports sequence inspection, filtering, conversion, extraction, statistics, and other sequence-manipulation operations. It is useful for checking read counts, identifying unusually short or long reads, extracting sequences by identifier, and performing basic filtering. SeqKit does not replace specialized adapter-trimming tools, but it can complement them in preprocessing pipelines.
  • For example, read statistics can be generated using:

seqkit stats sample_R1.fastq.gz sample_R2.fastq.gz

  • Reads can also be filtered by minimum length using:

seqkit seq \

  -m 50 \

  sample.fastq.gz \

  -o filtered.fastq.gz

  • This command retains sequences of at least 50 bases. Researchers should remember that length filtering alone does not evaluate base quality or remove adapters. It is generally used alongside other preprocessing operations.
  • Read preprocessing may also require removal of low-quality reads. A read can be filtered because its average quality is below a selected threshold, because too many bases have low quality, because it contains excessive ambiguous nucleotides, or because its final length is insufficient for downstream analysis. Filtering criteria should be chosen according to the sequencing platform and intended application. A threshold suitable for whole-genome sequencing may not be appropriate for short amplicons, small RNA sequencing, or long-read data.
  • Quality trimming and read filtering are related but distinct operations. Quality trimming removes low-quality bases from the ends or other specified regions of reads, while read filtering removes entire reads that fail selected criteria. For example, a read may initially be 150 bases long but become 110 bases after trimming. If the minimum acceptable length is 50 bases, the processed read can be retained. A read reduced to 35 bases may be discarded because it is too short for reliable downstream analysis.
  • Ambiguous nucleotide bases, commonly represented by N, may also require attention. A high proportion of ambiguous bases can indicate poor sequencing quality or uncertainty in base calling. Some preprocessing tools allow reads to be discarded when they contain too many ambiguous bases. However, ambiguous bases can also occur naturally in consensus sequences or datasets with unresolved genomic regions. Their treatment should therefore be determined by the data type and analysis objective.
  • Low-complexity sequences may also affect sequence alignment and similarity searches. These sequences contain repetitive or compositionally biased patterns, such as long homopolymer runs or simple repeats. They may generate misleading sequence matches or reduce the reliability of certain analyses. Tools such as BBDuk and specialized masking programs can identify or filter some low-complexity sequences. However, low-complexity regions can be genuine biological features, so they should not be removed indiscriminately.
  • In RNA sequencing, preprocessing may involve additional steps such as removal of residual adapters, trimming of poly-A or poly-T sequences, and filtering of ribosomal RNA reads where appropriate. The selection of poly(A) enrichment or ribosomal RNA depletion during library preparation affects the composition of the sequencing library. SortMeRNA can identify and filter ribosomal RNA sequences in suitable workflows. However, ribosomal RNA should not be removed when it is the intended target of the experiment.
  • In amplicon sequencing, primer trimming is particularly important because primers can remain attached to the amplified target sequences. Incorrect primer removal may lead to inaccurate sequence classification or taxonomic assignment. In microbial community analysis, preprocessing may also include quality filtering, paired-end merging, and chimera detection. Tools such as Cutadapt, DADA2, and VSEARCH are commonly used in marker-gene sequencing workflows. DADA2 also performs error-model-based sequence inference and should not be considered simply an adapter-trimming program.
  • For long-read sequencing, preprocessing strategies differ from conventional short-read workflows. Oxford Nanopore and PacBio reads have different error profiles, read-length distributions, and library preparation characteristics. Tools such as NanoFilt and NanoPack can support quality filtering and assessment of Oxford Nanopore reads, while Porechop and other specialized tools have been used for adapter processing in particular workflows. Researchers should verify whether a tool is actively maintained and compatible with the relevant platform and file format. PacBio data can be processed using platform-specific tools within SMRT Link and related software. Long-read preprocessing should preserve useful read length wherever possible, because aggressive trimming may remove valuable information for genome assembly, structural variant detection, and haplotype phasing.
  • Unique molecular identifiers and cell barcodes require special attention during preprocessing. UMIs identify original molecular templates, while cell barcodes identify cells or partitions in single-cell sequencing. These sequences must be extracted, corrected, or preserved according to the library protocol. Removing them as if they were ordinary adapter sequences can compromise molecular counting, cell identification, and downstream analysis. Tools such as UMI-tools support UMI extraction and processing, while platform-specific pipelines may handle barcode and UMI operations automatically.
  • After preprocessing, quality control should be repeated to determine whether the operations improved the data. FastQC can assess the processed FASTQ files, while MultiQC can summarize reports from multiple samples and tools. Important metrics include retained read counts, read length distributions, per-base quality, GC content, adapter content, duplication levels, and the proportion of reads removed. Comparing reports before and after preprocessing helps identify whether trimming and filtering were effective and whether excessive data loss occurred.
  • The following example illustrates a practical preprocessing workflow that combines FastQC, fastp, and MultiQC for paired-end sequencing data:

# Create output directories

mkdir -p qc_before trimmed qc_after multiqc_report

# Assess raw reads

fastqc sample_R1.fastq.gz sample_R2.fastq.gz \

  –outdir qc_before/

# Trim adapters and filter low-quality reads

fastp \

  -i sample_R1.fastq.gz \

  -I sample_R2.fastq.gz \

  -o trimmed/sample_R1.trimmed.fastq.gz \

  -O trimmed/sample_R2.trimmed.fastq.gz \

  –detect_adapter_for_pe \

  –qualified_quality_phred 20 \

  –length_required 50 \

  –thread 8 \

  –html trimmed/fastp_report.html \

  –json trimmed/fastp_report.json

# Assess processed reads

fastqc \

  trimmed/sample_R1.trimmed.fastq.gz \

  trimmed/sample_R2.trimmed.fastq.gz \

  –outdir qc_after/

# Generate a combined report

multiqc qc_before/ trimmed/ qc_after/ \

  –outdir multiqc_report/

  • This workflow provides a basic approach for evaluating raw reads, processing them, and assessing the resulting files. The selected quality threshold and minimum read length are illustrative. They should be adjusted to the sequencing experiment, and the output should be examined before proceeding to alignment, assembly, or other downstream analysis.
  • Tool selection depends on the research objective, sequencing technology, and type of preprocessing required. Cutadapt is particularly flexible for adapter and primer removal. fastp provides an integrated approach to adapter detection, quality filtering, and reporting. Trimmomatic offers configurable trimming and filtering strategies for short-read datasets. BBDuk provides flexible k-mer-based filtering and sequence processing, while SeqKit is useful for general FASTA and FASTQ manipulation. Long-read workflows may require specialized tools designed for their platform and error characteristics.
  • Read preprocessing has important limitations. Aggressive trimming can remove genuine biological sequence, reduce read length, and decrease the amount of usable data. Excessive filtering can introduce bias if particular sequence types, organisms, or genomic regions are disproportionately affected. Removing duplicate reads indiscriminately can also be inappropriate, especially in RNA sequencing, amplicon sequencing, and other experiments where identical reads may represent independent biological molecules. Similarly, trimming poly-A sequences or low-complexity regions without considering the experimental design may remove biologically meaningful information.
  • For reproducible bioinformatics analysis, researchers should document the original input files, preprocessing tools, software versions, adapter and primer sequences, quality thresholds, minimum read lengths, and other filtering parameters. The number of reads before and after processing should be recorded, and original sequencing files should be preserved. Workflow management systems such as Snakemake and Nextflow can automate preprocessing across multiple samples and maintain consistent processing steps. Container technologies such as Docker and Apptainer can help preserve software environments and improve reproducibility.
  • Read preprocessing with Cutadapt, fastp, and related tools is fundamental to reliable sequencing analysis. These tools help remove unwanted adapter and primer sequences, trim low-quality bases, filter unsuitable reads, and prepare sequencing data for downstream applications. The most appropriate preprocessing strategy depends on the sequencing platform, library preparation method, and biological research question. Careful parameter selection, post-processing quality assessment, and transparent documentation help preserve genuine biological information while reducing technical errors in bioinformatics workflows.
Author:

Leave a Reply

Your email address will not be published. Required fields are marked *