I have a command I need to run for multiple combinations of files. The command looks like this:
myscript.pl -output_directory /path/output_"$TARGET_SAMPLE"_vs_"$NORMAL_SAMPLE" -target_sample /path/$TARGET_SAMPLE.bam -normal_sample /path/$NORMAL_SAMPLE.bam
I want to run this for multiple sets of samples without having to manually change the paths each time. Right now I set the samples before running it mannually like this:
export TARGET_SAMPLE="sample_1"
export NORMAL_SAMPLE="sample_2"
How do I run this to make sure the TARGET_SAMPLE and NORMAL_SAMPLE are always correctly matched? For each NORMAL_SAMPLE I need to run the script twice with two different TARGET_SAMPLE files. I think using an array could work but I don't know how to correctly feed that into a for loop.
Here are a few examples of the pairings I need to run:
export TARGET_SAMPLE="sample_1"
export NORMAL_SAMPLE="sample_2"
export TARGET_SAMPLE="sample_3"
export NORMAL_SAMPLE="sample_2"
export TARGET_SAMPLE="sample_4"
export NORMAL_SAMPLE="sample_5"
export TARGET_SAMPLE="sample_6"
export NORMAL_SAMPLE="sample_5"
So the first example outputs from this list of combinations would be to submit these commands in the shell:
myscript.pl -output_directory /path/output_sample_1_vs_sample_2 -target_sample /path/sample_1.bam -normal_sample /path/sample_2.bam
and the second would be:
myscript.pl -output_directory /path/output_sample_3_vs_sample_2 -target_sample /path/sample_3.bam -normal_sample /path/sample_2.bam
Thanks for your help.
normal=(n1 n3 n3)andtarget=(t2 t3 t4). Both arrays have three elements. As long as you keep the ordering you are interested into, you can loop with a variablenfrom 0 to length(normal) and using${normal[n]}and${target[n]}as your parameters.