First, lets look at what the script actually does:
The outer loop:
for t in `echo A B` ; do
(removed for clarity)
done
This set the variable $t to A, executes the rest of the commands on the loop and then repeats it with $t set to B. It also does it in a weird way with executing a subshell to echo A and B. A simple for t in A B ; do
would have done the same.
Next, the inner loop.
seq 1 22 ; echo X
seq creates a sequence of numbers from 1 to 22. Then X is added. You would write it in a longer form as for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 X
Finally, the commands:
Add this to the inner code and you get these commands:
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=1 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=2 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=3 < ~/bin/skat.R" ;
...
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=19 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=20 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=A chr=X < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=1 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=2 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=3 < ~/bin/skat.R" ;
...
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=19 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=20 < ~/bin/skat.R" ;
qth "export R_LIBS=~/lib/ ;
R --vanilla --args phenotype=B chr=X < ~/bin/skat.R" ;
Now that we know what it does you can either run this by hand, write a batchfile or a powershell script. :-)
It would probably contain like something like this:
C:\program files\SkatMeta\R.exe --vanilla --args phenotype=A chr=1 < %%HOMEPATH%%\bin\skat.R"
C:\program files\SkatMeta\R.exe --vanilla --args phenotype=A chr=2 < %%HOMEPATH%%\bin\skat.R"
C:\program files\SkatMeta\R.exe --vanilla --args phenotype=A chr=3 < %%HOMEPATH%%\bin\skat.R"
Etc etc with chr is 4 5 6 7 8 ... 21 22 X
And then the same for B
Where the first line it the full path to the R binary (default on windows is C:\program files\name_of_the_manufacturer\program_name.exe) and where the unix shortcut for home (~
) has been replaced by %HOMEPATH%. The last probably expands to C:/users/your_username and I encapsulated it in double % signs which is needed for a batch file.
I will leave that part to an other poster, since windows scripting is very much not my forte.