This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filtering reads on the basis of percentage of ambiguous(N's) characters

Hi,

I want to filter my fastq reads based on ambiguous characters, basically N's. So if I have a read sequence having N's greater than 5%, I want to discard that read, if lower than 5%, I want to keep it. It would be really helpful if someone know about any tool which already does that.

Thanks

fastq rna-seq filter

1 answer

using paste + awk:

gunzip -c input.fq.gz |\
 paste - - - - |\
awk -F '\t' '{S=$2;L=1.0*length(S);gsub(/[^ATGCatgc]/,"",S);L2=length(S); if(L2/L > 0.05) print $0;}' |\
tr "\t" "\n"

Log in to answer this question.