This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract reads mapped within chosen intronic region from BAM file (no junctions)

Hi everyone, here's my question:

I have some BAM files resulting from mapping RNA-seq reads. I would like to know whether there is a way to extract the reads mapping within defined intronic regions.

When simply doing "samtools view file.bam chr1:Start-End > result.bam", I get reads in the output file even if there are no actual reads mapped within the intronic region of interest, this is a result of the fact that samtools outputs also read fragments spanning from one exon to another, and not mapping inside the intron; while I would like to know which reads map within a given intronic region.

Does anyone know how I may do this?

Thank you in advance.

bedtools rna-seq samtools

1 answer

I quickly wrote something: http://lindenb.github.io/jvarkit/Biostar9469733.html

this tool looks at the cigar string and check if there any block has an overlap with the bed file.

 java -jar dist/biostar9469733.jar --regions input.bed input.bam

Log in to answer this question.