This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract and cut sequence from a given region from a BAM file

Hi,

I have an aligned BAM file and I want to extract sequence from a given region and just that, not what's come after or before the specific region.

I try samtools with:

samtools view -b alignment_sort_JX888104.bam "JX888104.1:569-895" > filt_aln_grp1_JX888104.bam

but it give me all the read that comes in this interval even if it's one base.

After that I try bedtools:

bedtools intersect -wa -a alignment_sort_JX888104.bam -b grp1.bed > test_intersect_grp1.bam

with

grp1.bed -> JX888104.1 569 895

but it give me an error that my bed is not recognize.

Do you have another idea?

Thanks in advance

alignment

but it give me an error that my bed is not recognize.

what is the output of

file  grp1.bed
tr "\t" "#" < grp1.bed

?

ASCII text

JX888140.1 569 895

you're not using a tab as the column separator but spaces.

Output should have been

ASCII text
JX888140.1#569#895

you're right, I thought that with atom tab was imply but apparently not, thanks. I fix that and I don't have the bedtools error anymore but when I look the data on IGV, I still have all my reads.

am I doing something wrong with my bedtools command ?

Cheers

0 answers

No answers yet.

Log in to answer this question.