Entering edit mode
20 months ago
brandnewatthis
•
0
Hi there,
I am trying to create a loop to run multiple sorted bam files through picard to mark duplicates. My bash script is not working, and I'm at a loss.
#! /bin/bash
picard=/home/picard/picard.jar
sbam=/data/B_bam
for bamfile in *_sorted.bam
do
java -jar "$picard" MarkDuplicates INPUT="$sbam"/"$bamfile" OUTPUT="$sbam"/"${bamfile%_sorted.bam}"_md.bam METRICS_FILE="$sbam"/"${sbam%_sorted.bam}"_metrix
samtools index "$sbam"/"${bamfile%_sorted.bam}"_md.bam
done
Error Message:
Cannot read non-existent file: /data/B_bam/*_sorted.bam
People need to start somewhere. Loops -> xargs/parallel -> snakemake/nextflow is the logical progression in learning automation IMO.
I find it weird that OP uses a mix of
${}
and"..."/"...."
(multiple quoted strings interleaved with multiple unquoted strings). Why not simply"${sbam}/${bamfile%_sorted.bam}_metrix"
?Sorry, I am very new at this and am just learning my way around these symbols! Thanks for the help :)
For someone new at shell scripts, you're doing really well at using shell variables and parameter expansion. Good going!