On 8 May 2016, at 17:27, Peter Chovanec <peter.chova...@babraham.ac.uk> wrote:
> Why doesn't this work:
> 
> samtools view sample.bam 2:33050509-33154206 -U without-region.sam
> 
> or
> 
> samtools view -b sample.bam 2:33050509-33154206 -o other_stuff.bam -U 
> without-region.bam

You don't say what you were expecting to have happen, but presumably, like the 
biostars poster, you were hoping to get the reads outside the 
2:33050509-33154206 region (i.e., elsewhere on chromosome 2 and anywhere on any 
other chromosome under the sun).

If you think about how specifying a region like 2:33050509-33154206 works, you 
will see why this didn't do what you hoped for.  Samtools view uses the index 
to jump straight to this region and never looks at the reads outwith, so such 
reads are not scanned or added to the output.

If you used some filtering options with this:

        samtools view -b -f 0x10 -o reverse.bam -U forward.bam sample.bam 
2:33050509-33154206

then you would get reads in both output files.  This writes 
mapped-to-reverse-strand reads in 2:33050509-33154206 to one file and 
forward-mapped reads in that region to the other file.

This is described in the man page as

-U FILE
Write alignments that are not selected by the various filter options to FILE. 
When this option is used, all alignments (or all alignments intersecting the 
regions specified) are written to either the output file or this file, but 
never both.

Note the part in parentheses.  Probably this needs to spell out what it means 
by "filter options" more clearly -- region arguments aren't part of them! --, 
but see also the introduction to samtools view in the man page.  Perhaps it 
would also help if samtools view emitted a message if both -U and a region are 
given.

    John

-- 
 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. 

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Samtools-help mailing list
Samtools-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to