bamtools filter specific motif sequence
1
0
Entering edit mode
7.1 years ago

I am trying to use bamtools filter to keep output a new bam file with a specific sequence. This is what I am using...

bamtools filter -in Aligned.bam -queryBases AAACCTG >Aligned_1.bam

This does not return any matches. The question I am asking, is it possible to filter sequencing reads from a BAM file that has specific sequence of interest? If so, how? Are there any other tools that might be able to do this?

Thanks in advance for any guidance provided.

bamtools filter motif • 2.7k views
ADD COMMENT
2
Entering edit mode
7.1 years ago
samtools  view -h input.bam | awk -F '\t' '($1 ~ /^@/ || $10 ~/AAACCTG/ )' | samtools view -Sb -o out.bam -

using samjs

java -jar dist/samjs.jar -e 'record.getReadString().contains("AAACCTG")' input.bam
ADD COMMENT
0
Entering edit mode

Thanks a lot! I was able to make it work with the following:

samtools view -h input.bam | awk -F '\t' '($1 ~ /^@/ || $10 ~/AAACCTG/ )' >filter.sam ; samtools view filter.sam -Sb -o filter.bam

ADD REPLY
0
Entering edit mode

ah yes, I forgot to write the last hyphen on my command line. You should be able to write filter the bam without writing this 'filter.sam'.

Please check the green mark on the left to flag this question as answered.

ADD REPLY

Login before adding your answer.

Traffic: 1925 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6