Piping mpileup output into 2 functions without calling mpileup twice
1
0
Entering edit mode
2.4 years ago
Wilford203 ▴ 10

Hi, so I am trying to create a pipeline right now which calls the mpileup command and then pipes the output into the tool iVar which I am using to both call the variants (snps/indels) and consensus sequence from the data. To do so you must first run the mpileup command and then pipe it's output into either ivar consensus or ivar variants.

Being that mpileup is a fairly intensive and time consuming process to run and the parameters I am using on the mpileup are identical each time I am trying to find a way to see if I can pipe the outputs of the mpileup to both the ivar consensus and ivar variants without having to run mpileup twice. My current attempt to do this was to try the && option with:

samtools mpileup -Q 20 -B -aa -d 25000 -f  + ref_Seq + bam_file |  ivar consensus -p out_fasta  -q 20 -t 0.1 -n N && ivar variants -q 20 -t 0.1 out_tsv  ref_Seq

But this only leads to the 'ivar consensus' command having the mpileup piped into it, does anyone have any ideas or solutions to achieve this?

Thanks!

ivar mpileup unix samtools • 603 views
ADD COMMENT
0
Entering edit mode
2.4 years ago

use a Process substitution with tee >()

(not tested)

samtools mpileup -Q 20 -B -aa -d 25000 -f  + ref_Seq + bam_file | \
    tee >( ivar consensus -p out_fasta  -q 20 -t 0.1 -n N ) | \
    ivar variants -q 20 -t 0.1 out_tsv  ref_Seq 
ADD COMMENT

Login before adding your answer.

Traffic: 2661 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6