I think, but am not certain, that the question is asking how to run 15 trials on each of ten values, not necessarily how to run ten jobs in parallel.
how to run STRUCTURE command n times for each K value?
I am running some STRUCTURE analysis and set k = {1..10} by using this command (only 1 run for each K):
for k in seq10
do
python /home/ubuntu/bin/fastStructure/structure.py -K $k --input=../file.snps --output=snpl525D --format=str
done
Instead of 1 run for each K, now I want to get 15 runs for each K, could you please help me to modify the code above to do this job! thanks
• 5,181 views
•
link
3 answers
Nest a per-k for loop inside a parent for loop:
$ for k in `seq 1 10`; do for eachK in `seq 1 15`; do echo "$k : $eachK"; done; done
1 : 1
1 : 2
1 : 3
1 : 4
1 : 5
...
10 : 13
10 : 14
10 : 15
As a comment notes, you may be overwriting output on each iteration. You can use the values of k and eachK to uniquely name the result.
• 0 views
•
link
Since perl is still cool. Here's the gist,
perl -e 'print join "\n", (0..10)' | xargs -I {} -P 10 admixture -K {} -o {}.something
Edited:
perl -e 'print join "\n", ((0..10) x 15)' | xargs -I {} -P 10 admixture -K {} -o {}.something
• 0 views
•
link
• 0 views
•
link
Alex Reynolds No problem, see edited answer. I love how fast and sleazy perl is.
• 0 views
•
link
doit() {
k="$1"
n="$2"
python /home/ubuntu/bin/fastStructure/structure.py -K "$k" --input=../file.snps --output=snpl525D-"$k"-"$n" --format=str
}
export -f doit
parallel doit ::: {1..10} ::: {1..15}
• 0 views
•
link
Log in to answer this question.
It seems to me you are overwriting the output at each loop iteration.