Filtering fastq file
I have a fastq files and I found many reads with only N. I want to filter only those reads which contains N. Any one liner for that?
• 4,265 views
•
link
2 answers
To separate reads with Ns using BBMap:
bbduk.sh in=reads.fq out=readsWithoutNs.fq outm=readsWithNs.fq maxns=0
If you have, say, 100bp reads and only want to separate reads containing all 100 Ns, change that to "maxns=99".
• 0 views
•
link
gunzip -c input.fastq.gz | paste - - - - | awk -F '\t' '!($2 ~ /N/)' | tr "\t" "\n" > noN.fq
remove the '!' to get the 'N' only
• 0 views
•
link
Log in to answer this question.
You can use
bbduk.shorreformat.shfrom BBMap suite withqtrim=rl trimq=1. That will only trim trailing and leading bases with Q-score below 1, which means Q0, which means N (in either fasta or fastq format). If the entire read is N then it will be taken out.It didnt work they way you said. I want all the reads with N in separate file.
Use
outm=to grab filtered reads is a separate file. If you have a paired-end data set then you can useoutm1=andoutm2=to grab both reads.bbduk.sh in=file.fq qtrim=rl trimq=1 out=clean.fq outm=capture.fq minlength=read_length. This will capture any read that has at least one N in theoutmfile (replace read_length = number of cycles in your reads).Note: This will trim the N's out though. Which is not what you seem to want. So use @Pierre's solution for now until I (or Brian Bushnell ) can help figure out a BBMap way.
Hello ####!
We believe that this post does not fit the main topic of this site.
solved
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
#### : Closing a post is an action generally use by moderators during moderation.
If your question has been solved then accept one (or more) of the answers below (green check mark) to provide closure to the thread.