-1
$\begingroup$

In the below bash loop for strelka2, 3 bam files are being stored in a variable. The two questions are:

Is this proper way to loop through multi bam and wait for workflow to be created for strelka2 processing, and can you create a workflow in a directory without the bam in it. Thank you :).

contents of dir

s1.bam
s2.bam
s3.bam

bash

dir=/path/to/bam
data=/path/to/processed/data

cd $dir
	for bam in ${dir}/*.bam; do sample_basename=$(basename "${bam}"); done # loop through dir and get bam

${path_to_strelka}/bin/configureStrelkaGermlineWorkflow.py \
  --bam ${dir}/${sample_basename} \
  --referenceFasta <fasta> \
  --runDir ${data}
  wait  # wait until workflow in data is created before executing below  in data
${data}/runWorkflow.py -m local -j 20
$\endgroup$
1
$\begingroup$

The loop you're using does not work, as it overwrites the value of sample_basename each time. Plus, given that you're passing in the full path to the bam (using $dir/$sample_basename) anyway, I don't see the reason to use the sample_basename variable at all.

Just this:

dir=/path/to/bam
data=/path/to/processed/data
ref_fa=/path/to/ref/fasta

cd $dir

for bam_file in *.bam
do
  ${path_to_strelka}/bin/configureStrelkaGermlineWorkflow.py \
    --bam ${bam_file} \
    --referenceFasta ${ref_fa} \
    --runDir ${data}
  ${data}/runWorkflow.py -m local -j 20 #I'm assuming this goes inside the loop. If not, move it outside the loop. You don't need a `wait` in a shell script that's working line-by-line already.
done
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you very much :). $\endgroup$ – justaguy Dec 17 '19 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.