Rename Read IDs

Rename FASTQ read identifiers using a custom prefix and sequential numbering

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

Rename Read IDs

Function

Replaces original FASTQ read identifiers with new sequential IDs generated from a user-defined prefix while preserving the sequence and quality information.


Input Format

  • FASTQ files (.fastq, .fq)
  • Compressed FASTQ files (.fastq.gz, .fq.gz)
  • Custom prefix for read names.

Output Format

  • FASTQ file with renamed identifiers.
  • Sequence lines remain unchanged.
  • Quality scores remain unchanged.
  • IDs become sequential: @prefix_1, @prefix_2, etc.

Applications

  • Standardizing read names.
  • Sample-specific tagging.
  • Data anonymization.
  • Preventing duplicate IDs after merging.
  • Improving compatibility with downstream tools.

Example

Original

@NB551234:45:H7F2...
ATCGATCG
+
FFFFFFFF

↓

Prefix = sample_

@sample_1
ATCGATCG
+
FFFFFFFF

SeqKit Example

seqkit replace \
-p '.+' \
-r 'sample_{nr}' \
input.fastq.gz \
-o renamed.fastq.gz

AWK Example

awk '
BEGIN{i=1}
NR%4==1{
print "@sample_"i
i++
next
}
{print}
' input.fastq \
> renamed.fastq

Compressed FASTQ Example

zcat input.fastq.gz | \
awk '
BEGIN{i=1}
NR%4==1{
print "@sample_"i
i++
next
}
{print}
' | gzip \
> renamed.fastq.gz

Suggested Reading


Important Notes:
  • Original read IDs are replaced and cannot be recovered unless the original FASTQ file is retained.
  • Instrument, lane and barcode metadata stored in headers will be removed.
  • When working with paired-end data, ensure both R1 and R2 files use the same renaming strategy.
  • Read order must remain unchanged to preserve pair relationships.
  • Keep a backup copy of the original FASTQ files if header metadata may be needed later.