In the below bash
the two variables $bname
and $sample
are extracted correctly however when I pass them to the java
command $bname
is set to file:///home/cmccabe/NA12878.bam
and an exception is thrown in the picard
command. I can only guess that $sample
is set to ///home/cmccabe/NA12878
. I am not sure what I am doing wrong, can a bash
variable not be used in java
or is there something else? Thank you :)
input
/home/cmccabe/Desktop/fastq/NA12878.bam
result of echo
The bam is NA12878.bam --- this is $bname
The matching sample is NA12878 --- this is $sample
bash
for file in /home/cmccabe/Desktop/fastq/*.bam
do
bname=`basename $file`
echo "The bam file is:" $bname
sample=$(basename $file .bam | cut -d- -f1)
echo "The matching sample is:"$sample
java -XX:ParallelGCThreads=16 -jar /home/cmccabe/Desktop/fastq/picard/build/libs/picard.jar MarkDuplicates \
I=$bname \
O=${sample}_marked_duplicates.bam \
M=${sample}_marked_dup_metrics.txt
done
Can you paste the error thrown by Picard?
Sorry, I highlighted the variables and error. Thank you :).
Word to the wise, you should quote your variables too:
"${var}"
To stop nasty unexpected parameter expansions.
try replacing
$bname
with$file
or${file}
@ cmccabe