2. Use Make to manage jobs submitted to a computer cluster
In the following example, files align/*.jobid depends on db_pass25m1/*.jobid, we use "-W depend" in qsub to make sure the align job is hold until its preresquisite job is done successfully. After Make submitted the alignment job to cluster, it would try to load the alignment result into database immediately, But the first command "while qstat `cat $<` 2> /dev/null; do sleep 60; done" makes sure that it would wait until the alignment job is done.
table/raw_align_% : align/%.jobid
while qstat `cat $<` 2> /dev/null; do sleep 60; done
echo -e "drop table $(@F);\ncreate table $(@F) (chip varchar2(60), x number(4), y number(4), chr varchar2(20), loc number(10), strand varchar2(1), mis_loc number(2), mis_on_chip varchar2(1), mis_on_chr varchar2(1));" | sqlplus -s $(TNS)
echo -e "load data append into table $(@F) fields terminated by '\t'trailing nullcols (strand, chip, x, y, chr, loc, mis_loc, mis_on_chip, mis_on_chr)" > $@.ctl
sqlldr $(TNS) silent=header,feedback,errors,discards,partitions direct=y errors=0 control=$@ data=$@.dat
touch $@
align/%.jobid : db_pass25m1/%.jobid
echo "pass align genome.pass $(@<)/$*.pass > $(@D)/$*.dat" | $(QSUB) -W depend=afterok:`cat $<` > $@