Question: Samtools view pipe and position
0
gravatar for Alexander Vowinkel
3.4 years ago by
Alexander Vowinkel0 wrote:

Hi,

following gives the error

> [main_samview] random alignment retrieval only works for indexed BAM or CRAM files.

samtools merge -u -b all_files.list - | samtools view -u -q 20 -F 0x704 - '1:1-10000' > /dev/null

Without the position it works.
So I guess, samtools takes the position as input.
Is this a bug?

Version: 1.2 (using htslib 1.2.1)

Thanks,
Alexander

pipe samtools • 1.6k views
ADD COMMENTlink modified 3.4 years ago by matted7.0k • written 3.4 years ago by Alexander Vowinkel0
0
gravatar for thackl
3.4 years ago by
thackl2.6k
MIT
thackl2.6k wrote:

This is not a bug. As the error suggests, you can only access regions from a file, not a piped stream. You will need to merge into file, which you than index to be able to access its regions.

ADD COMMENTlink written 3.4 years ago by thackl2.6k
0
gravatar for matted
3.4 years ago by
matted7.0k
Boston, United States
matted7.0k wrote:

You could view the subregions you want first, then merge them.  Depending on what you're trying to do, this would be more or less efficient than simply merging to one file (and indexing it) first.

This terrible one-liner should work:

cat <(samtools view -H first_bam.bam) <(cat all_files.list | xargs -n 1 -I {} samtools view -u -q 20 -F 0x704 {} 1:1-10000) | samtools view -bS - | samtools sort -o - - > /dev/null

 

ADD COMMENTlink modified 3.4 years ago • written 3.4 years ago by matted7.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 712 users visited in the last hour