This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Finding length of multiple fastq.gz files

Hi,

I need to determine the length of each of my fastq files in a directory which I know you can do by using find . | xargs wc -l. However I need them to be decompressed before the length can be determined. I know you use the zcat command to do this. What I am struggling with is how to combine the two together to get the length of each file in my directory after decompression in one line of code.

zcat fastq

For total number of lines for each fastq.gz:

$ find . -type f -name "*.gz" -exec zgrep -c "$" {} \;

Since it is fastq, you may want to print number of reads, instead of lines.

$ find . -type f -name "*.gz" -exec zgrep -c "^@" {} \;

assuming that first letter of the quality line in any of the read in the file is not @

1 answer

Done in parallel because I don't know xargs but I think it works the same.

find . | parallel -I{} "zcat {} | wc -l"

That’s worked great, thank you!

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
upvote_bookmark_accept

Log in to answer this question.