Reads extraction from a .bam file
1
1
Entering edit mode
3.6 years ago
kaleb.gatto ▴ 10

Hi all

I am newbie in bioinformatics and I am having some difficult to extract a subset of reads in a .bam file. I have a set of reads (Illumina HiSeq4000, majority of the reads with length=125 bp) that I generated from laser captured chromosomes and I am performing an read filtering step to remove reads that could be contaminants from bacterial genomes. First I think to use samtools to extract the unmapped reads first such as:

samtools view -b -f 4 mapping.bam > unmapped_reads.bam

However, in preliminary read mapping against few bacterial genomes I have some segments with <=30 bp of alignment. Is there a way to extract both together: (a) unmapped reads + (b) reads with alignment size <= 30 bp?

Thanks in advance guys, and sorry if it is a too basic question, but I searched in the forum and I did not found an answer.

Best Regards Kaleb Gatto

samtools • 833 views
ADD COMMENT
3
Entering edit mode
3.6 years ago

with a recent version of samtools:

 samtools view -O BAM -o out.bam -e 'flag.unmap || rlen<=30' input.bam
ADD COMMENT
0
Entering edit mode

Hi Pierre Thank you for your reply. I will try this command.

Best Regards Kaleb

ADD REPLY

Login before adding your answer.

Traffic: 1253 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