This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Viewing Multiple Regions In Samtools

Hi all

I'm wondering if there is a way to exclude regions in samtools view.

Now I awk and sed lines away in post processing via piping.

Wouldn't it save time and space to just pileup more than one region at once into a file?

Maybe this is a dumb question but I don't have the software now while I'm wondering so I can't experiment.

For example:

samtools view chrY:2709520-3709520, chrY:17443438-27443438 ǀ samtools mpileup...
samtools view chrY:2709520-3709520 AND chrY:17443438-27443438 ǀ samtools mpileup.
samtools view chrY:2709520-3709520: chrY:17443438-27443438 ǀ samtools mpileup...

...

samtools

1 answer

samtools view takes an argument to only output the alignments overlapping the regions of a BED file:

-L FILE  output alignments overlapping the input BED FILE [null]

update 2021: use option -M to go faster with an indexed bam.

Log in to answer this question.