Reputation: 518
I have a python script which I normally execute from BASH shell like this:
pychimera $(which dockprep.py) -rec receptor1.pdb -lig ligand1.mol -cmethod gas -neut
As you see some of the arguments need an input (e.g. -rec) while others don't (e.g. -neut). I must execute this script 154 times with different inputs. How is it possible to run 8 threads in parallel using GNU parallel script?
pychimera $(which dockprep.py) -rec receptor1.pdb -lig ligand1.mol -cmethod gas -neut
pychimera $(which dockprep.py) -rec receptor2.pdb -lig ligand2.mol -cmethod gas -neut
pychimera $(which dockprep.py) -rec receptor3.pdb -lig ligand3.mol -cmethod gas -neut
...
Upvotes: 2
Views: 286
Reputation: 207425
I think you want this:
parallel 'pychimera $(which dockprep.py) -rec receptor{}.pdb -lig ligand{}.mol -cmethod gas -neut' ::: {1..154}
If you have other than 8 CPU cores, and specifically want 8 processes at a time, use:
parallel -j8 ...
If you want to see the commands that would be run without actually running anything, use:
parallel --dry-run ...
Upvotes: 3
Reputation:
Example commands.txt
generator script:
#!/usr/bin/env bash
if [ "$#" -ne 1 ]; then
echo "missing parameter: n"
exit 1
fi
rm commands.txt 2> /dev/null
dockp=$(which dockprep.py)
for((i=1;i<=$1;i++)); do
echo "pychimera $dockp -rec receptor$i.pdb -lig ligand$i.mol -cmethod gas -neut" >> commands.txt
done
If you save above bash script as cmdgen.sh
you can run it as:
bash cmdgen.sh 100
if you need n
to be 100.
To run commands in parallel:
$ module load parallel
$ parallel < commands.txt
Upvotes: 1