Question: how to run STRUCTURE command n times for each K value?
1
gravatar for Ana
2.1 years ago by
Ana170
Ana170 wrote:

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

bash structure • 1.5k views
ADD COMMENTlink modified 2.1 years ago by Zev.Kronenberg11k • written 2.1 years ago by Ana170

It seems to me you are overwriting the output at each loop iteration.

ADD REPLYlink written 2.1 years ago by h.mon27k
1
gravatar for Alex Reynolds
2.1 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

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.

ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by Alex Reynolds28k
1
gravatar for Zev.Kronenberg
2.1 years ago by
United States
Zev.Kronenberg11k wrote:

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
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by Zev.Kronenberg11k

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.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Alex Reynolds28k

Alex Reynolds No problem, see edited answer. I love how fast and sleazy perl is.

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Zev.Kronenberg11k
0
gravatar for ole.tange
2.1 years ago by
ole.tange3.5k
Denmark
ole.tange3.5k wrote:
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}
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by ole.tange3.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 608 users visited in the last hour