Skip to content

Instantly share code, notes, and snippets.

@dentearl
Last active May 8, 2020 17:53
Show Gist options
  • Save dentearl/3278446 to your computer and use it in GitHub Desktop.
Save dentearl/3278446 to your computer and use it in GitHub Desktop.
bash loop to run tons of jobs but limit the background to a certain smaller number at a time. change the -gt 0 to be -gt _n_ to limit the number of background jobs to _n_
# primate version
for f in ../packagePrimates/analysis/comparatorWrapper-primates.*/; do
for c in A B C D; do
##########
# This block holds the background process count in check
while [ $(jobs | wc -l) -gt 0 ]; do
sleep 2;
done;
##########
for partner in simChimp simGorilla simOrang; do
for m in prec recall fscore; do
b=$(basename $f); mkdir -p precRecallWiggles/primates/$b/; ./comparatorPlot.py --xml $f/comparatorMRCA.xml --mode $m --out precRecallWiggles/primates/$b/$b.simHuman.$c.$partner.$m.pdf --ref simHuman.chr$c --partner $partner &
done;
done;
done;
done;
# mammal version
for f in ../packageMammals/analysis/comparatorWrapper-mammals.*/; do for c in D F H I J K; do while [ $(jobs | wc -l) -gt 0 ]; do sleep 2; done; for partner in simCow simDog simMouse simRat; do for m in prec recall fscore; do b=$(basename $f); mkdir -p precRecallWiggles/mammals/$b/; ./comparatorPlot.py --xml $f/comparatorMRCA.xml --mode $m --out precRecallWiggles/mammals/$b/$b.simHuman.$c.$partner.$m.pdf --ref simHuman.chr$c --partner $partner & done; done; done; done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment