SEQanswers

SEQanswers (http://seqanswers.com/forums/index.php)
-   Bioinformatics (http://seqanswers.com/forums/forumdisplay.php?f=18)
-   -   samtools -view region (overlap?) question (http://seqanswers.com/forums/showthread.php?t=29538)

dietmar13 04-21-2013 12:28 AM

samtools -view region (overlap?) question
 
hello,

does somebody know how overlap is definded for the
Quote:

samtools view region
function.

given the defined region # and four reads a-d:
Code:

                    ##############################
                aaaaaaaaaaaaaaaaa
                    bbbbbbbbbbbbbbbb
                              ccccccccccccccccccc
                                        ddddddddddddddd

which one is extracted: b and c or a-d?


thank you,

dietmar

syfo 04-22-2013 05:31 AM

No idea, but it should not be difficult to test by browsing a real bal file with the "samtools tview" option and selecting the first region with a couple of overlapping reads. I bet on a-d :)

maubp 04-22-2013 07:30 AM

I think it should give you all of them - any reads within or overlapping the region requested.

dietmar13 04-22-2013 09:20 AM

further question
 
Quote:

I think it should give you all of them - any reads within or overlapping the region requested.
this seems true, all overlapping were extracted.

does somebody know a script to fetch only those which start AND end inside a given range (###).

Code:

                    #################################
                aaaaaaaaaaaaaaaaa
                    bbbbbbbbbbbbbbbb
                              ccccccccccccccccccc
                                        ddddddddddddddd
eeee----splice------eeeeeeeeeee

here only: b and c

swbarnes2 04-22-2013 09:48 AM

You might consider using BEDTools instead of samtools view. BEDTools can be given a .bed file of intervals, and a .bam file, and you could limit the reads to only those which completely overlap the intervals.

dietmar13 04-22-2013 10:44 AM

@swbarnes
 
thank you, works great, but too slow with big bam files:

therefore preselection with samtools...

Code:

samtools view -b xxx.bam chr1:1000-2000 | bedtools intersect -f 1.0 -b region.bed -abam - | samtools view - > yyy.sam


All times are GMT -8. The time now is 09:36 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.