This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to check if all read names are paired properly in paired end fastq.gz files?

Hi all,

I was wondering if there is a command that can be used to check if all the sequence names in the R1 and R2 fastq.gz files are paired and identical?

I've got some files causing issues where the error during bwa-mem says there are mismatched names. Which is strange because I've used this files months ago without any problems using the same program (only change is I've downloaded them onto a new cluster).

I would like to check if all my files have this issue but I don't see any commands in samtools that can check for this problem. If there is another program that can do this, please advice.

samtools illumina paired-end

If they're not paired, seqkit pair could help to match up paired-end reads from two fastq files.

If they worked before and now, after moving them, they are not working, I would be concerned there's a deeper issue. Is the file corrupted/incomplete?

1 answer

Well `zcat $fq | awk 'NR %4 == 1' gives you the read names. So you could do something like:

mkfifo r1_names r2_names

zcat read1.fq.gz | awk 'NR % 4 == 1' > r1_names &
zcat read2.fq.gz | awk 'NR % 4 == 1' > r2_names &

paste r1_names r2_names | awk -F "\t" '$1 != $2'

which will dump all of the mismatching read names to the terminal.

which will dump all of the mismatching read names to the terminal.

Clever solution but if the data is badly mismatched tons of stuff would be sent to terminal :-)

That's what | head is for :p

Log in to answer this question.