Dear all,
I have a fastq formatted file and I want to remove reads that DO NOT have a specific sequence in them. The experiment is designed in a way that only reads that have an adapter in them are meaningful for us and the rest of the reads are trash and I have to find a way to get rid of them. Another layer of complication is that I have paired-end reads. I would be grateful if someone can make a suggestion about how to handle this.
Best regards
2 answers
Using cutadapt using the flag --discard-untrimmed, works with paired-end
This answer shows you how to keep reads that have the adapter. Untested but please try and let us know. bbduk.sh from BBMap suite used like this: bbduk.sh in1=file_R1.fq.gz in2=file_R2.fq.gz outm=matching_R1.fq.gz outm2=matching_R2.fq.gz literal=your_adapter_sequence_goes_here k=a_number_equal_to_length_of_your_adapter mm=f
Note: Replace real adapter sequence and a number equal to the length of the adapter in two places above.
Log in to answer this question.
You can look into tools that splits the fastq file based on barcode and check if you can adapt them.
For example, quiime or stacks
If you know the exact sequence, you can do it with fastq-grep but it does not allow mismatches.
And more easy way given below as an answer.
Grep out the forward and reverse adapter sequence you are looking for and one line above and two lines below. Then append the two files together
grep -A 1 -B 2 "adapter sequence" original.fastq > wanted_adapters.fastq grep -A 1 -B 2 "reverse_adapter sequence" original.fastq >> wanted_adapters.fastq
using seqkit:
v = inverse match, i=ignore case, s=sequence, p=pattern, d=degenerate