You can add the read group directly in bowtie2:

bowtie2 -x bowtie2_index_hg38 --rg-id sample1 --rg SM:sample1 ... | samtools view -Su - | samtools sort - output

Picard's BuildBamIndex tool might be able to take input from a pipe (I'm pretty sure this doesn't work with samtools at the moment), in which case:

... | picard SortSam INPUT=/dev/stdin OUTPUT=/dev/stdout | tee output.bam | picard BuildBamIndex INPUT=/dev/stdin OUTPUT=output.bam.bai

Or something along those regards. I really can't recommend doing this, though. Getting the index in an additional step is going to be a minuscule time savings.

Devon

On 11/20/2015 08:21 PM, Yaseen Ladak wrote:
Hi All,

I need some help I want to pipe the output from samtools to picard readgrous commands but I am failing:

*bowtie2 -x bowtie2_index_hg38 -1 R1.fq.gz -2 R2.fq.gz | samtools view -Shb - | samtools sort - output*

What I want to achieve is the following is to also add the read groups the output.bam file from above command and also index the output bam file with reads groups. I am failing with the following command and I dont know how to also index the output bam file that has the read group.

*bowtie2 -x bowtie2_index_hg38 -1 mrg_sample_1_R1_val_1.fq -2 mrg_sample_1_R2_val_2.fq | samtools view -Shb - | samtools sort - - | picard AddOrReplaceReadGroups I= output.bam O=rg_output.bam RGID=sample_1 RGLB=sample_1 RGPL=illumina_hi-seq RGPU=sample_1 RGSM=sample_1*

Can someone please help me?
Thanks,
Yaseen



------------------------------------------------------------------------------


_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to