Thank you. Now it makes sense why it works with the -L option.

On 09/05/16 10:11, John Marshall wrote:
> 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 Babraham Institute, Babraham Research Campus, Cambridge CB22 3AT Registered 
Charity No. 1053902.
The information transmitted in this email is directed only to the addressee. If 
you received this in error, please contact the sender and delete this email 
from your system. The contents of this e-mail are the views of the sender and 
do not necessarily represent the views of the Babraham Institute. Full 
conditions at: www.babraham.ac.uk<http://www.babraham.ac.uk/terms>

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