On Mon, Oct 26, 2015 at 03:14:04PM -0400, [email protected] wrote:
> I am trying to get the aligned reads from a bam file for regions specified in 
> a bed file like this:
> 
> samtools view -h -b -o SJDE001-1-tumor_region1.bam -L region_1.bed 
> /seq/picard_aggregation/G14865/SJDES001-1/v2/SJDES001-1.bam
> 
> It runs for a long time and it doesn't produce the output at the end. Is 
> there a better way to do this?

I don't know why you're not getting any output, but I may be able to
explain why it takes a long time.

I found it rather confusing, but note there is a huge difference in
how bed file regions and the single index region work.

"samtools view foo.bam X:10000-20000" extracts data aligned between
10-20k of ref X, using the foo.bam.bai index.

"samtools view -L X.bed foo.bam" will stream the entire foo.bam past
the locations listed in X.bed and emit those that are in the region
list.  It does not use the index.

You can use both together though.  If you use ""samtools view -L X.bed
foo.bam X:10000-20000" then it initially uses the index to skip to
X:10000 and then streams all the data up to X:20000, using the BED
regions to filter.

James

-- 
James Bonfield ([email protected]) | Hora aderat briligi. Nunc et Slythia Tova
                                  | Plurima gyrabant gymbolitare vabo;
  A Staden Package developer:     | Et Borogovorum mimzebant undique formae,
https://sf.net/projects/staden/   | Momiferique omnes exgrabure Rathi. 


-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 

------------------------------------------------------------------------------
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to