SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hisat2: no command found in bash SamH2017 RNA Sequencing 2 09-27-2017 05:08 PM
How can I write a bash command to blast local nt database? hyates Bioinformatics 5 03-05-2015 09:30 AM
pipe two inputs to a command (coverageBed) hari_iyer16 Bioinformatics 3 04-16-2013 01:51 AM
blast-2.2.26+, problem with tbastn command tamarbsor Bioinformatics 6 10-17-2012 04:03 AM

Reply
 
Thread Tools
Old 10-06-2019, 06:00 AM   #1
Marius
8armed
 
Location: Germany

Join Date: Dec 2010
Posts: 28
Default Problem using BASH to pipe Piccard command

I'm new to Bash, but would like to use it.
I would like to pipe two Picard (GATK pipeline) commands using Bash. Each of these commands works fine when they are run as individual Bash scripts (see below). However, when I try to combine them within a single bash script, it no longer works. I really cannot find the bug though. Help is much appreciated.


BASH Script 1
#!/bin/bash

# Set paths
picardtools='PATH/picard.jar'
bams="PATH/BAM"
outSorted='PATH/outSorted'

for i in BamFile1 BamFile2
do
java -jar $picardtools SortSam INPUT=$bams/"$i" OUTPUT=$outSorted/"$i" SORT_ORDER=coordinate CREATE_INDEX=TRUE VALIDATION_STRINGENCY=LENIENT
done


BASH Script 2
#!/bin/bash

# Set paths
picardtools='PATH/picard.jar'
outSorted='PATH/outSorted'
outSorted2='PATH/outSorted2'

for i in BamFile1 BamFile2
do
java -jar $picardtools AddOrReplaceReadGroups INPUT=$outSorted/$i OUTPUT=$outSorted2/"$i" SORT_ORDER=coordinate RGID="$i" RGLB="$i" RGPL=illumina RGPU="$i" RGSM="$i" CREATE_INDEX=True
done


######################

Here my attempts to pipe the two Scripts into one. But neither of these attempts worked. Can you help me find out why?

Attempt 1
#!/bin/bash

# Set paths
picardtools='PATH/picard.jar'
bams="PATH/BAM"
outSorted='PATH/outSorted'
outSorted2='PATH/outSorted2'

for i in BamFile1 BamFile2
do
java -jar $picardtools SortSam INPUT=$bams/"$i" OUTPUT=$outSorted/"$i" SORT_ORDER=coordinate CREATE_INDEX=TRUE VALIDATION_STRINGENCY=LENIENT
java -jar $picardtools AddOrReplaceReadGroups INPUT=$outSorted/$i OUTPUT=$outSorted2/"$i" SORT_ORDER=coordinate RGID="$i" RGLB="$i" RGPL=illumina RGPU="$i" RGSM="$i" CREATE_INDEX=True
done


Attempt 2
#!/bin/bash

# Set paths
picardtools='PATH/picard.jar'
bams="PATH/BAM"
outSorted2='PATH/outSorted2'

for i in BamFile1 BamFile2
do
java -jar $picardtools SortSam INPUT=$bams/"$i" OUTPUT=/dev/stdout SORT_ORDER=coordinate CREATE_INDEX=TRUE VALIDATION_STRINGENCY=LENIENT | \
java -jar $picardtools AddOrReplaceReadGroups INPUT=/dev/stdin OUTPUT=$outSorted2/"$i" SORT_ORDER=coordinate RGID="$i" RGLB="$i" RGPL=illumina RGPU="$i" RGSM="$i" CREATE_INDEX=True
done
Marius is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 01:12 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO