I would like to employ the Bourne shell background ampersand as part of ONE bsub execution command.
Note that I don't want to use a .bash file but rather one bsub command line for executing the entire procedure.
Note that I also don't want to split my bsub content into a few bsub commands that wait upon one another, but rather to wrap into a single bsub command line a few internal unix commands that wait upon one another using the Bourne shell background ampersand.
the following attempt only produced the output of the first internal command (the liftOver command), but neither sort nor mv were executed.
bsub -q medium -J $i "liftOver $i mm10ToMm9.over.chain.gz ${i/.bed/.mm9.bed} ${i/.bed/.unlifted_to_mm9.bed} & sort -k1,1 -k2,2n ${i/.bed/.mm9.bed} > ${i/.bed/.mm9.bed}.srt & mv ${i/.bed/.mm9.bed}.srt ${i/.bed/.mm9.bed}"
Outside of the bsub this procedure could be written as follows:
liftOver $i mm10ToMm9.over.chain.gz ${i/.bed/.mm9.bed} ${i/.bed/.unlifted_to_mm9.bed} &
sort -k1,1 -k2,2n ${i/.bed/.mm9.bed} > ${i/.bed/.mm9.bed}.srt &
mv ${i/.bed/.mm9.bed}.srt ${i/.bed/.mm9.bed}
I don't know bsub
but I could maybe give you a trick I use with batch
, ssh
and some other differed shells:
bsub -q medium -J $i <<<"liftOver $i mm10ToMm9.over.chain.gz ${i/.be/.mm9.bed} ${i/.bed/.unlifted_to_mm9.bed} &&
sort -k1,1 -k2,2n ${i/.bed/.mm9.bed} > ${i/.bed/.mm9.bed}.srt &&
mv ${i/.bed/.mm9.bed}.srt ${i/.bed/.mm9.bed}"
Maybe you have to change double quotes ("
) for quotes ('
) if $i
have to be developped by bsub
(again, I don't know this product)
or
bsub -q medium -J $i <<-eocmd
liftOver $i mm10ToMm9.over.chain.gz ${i/.be/.mm9.bed} \
${i/.bed/.unlifted_to_mm9.bed} &&
sort -k1,1 -k2,2n ${i/.bed/.mm9.bed} > ${i/.bed/.mm9.bed}.srt &&
mv ${i/.bed/.mm9.bed}.srt ${i/.bed/.mm9.bed}
eocmd
(warn: only a tabulation $'\t'
could be placed before word eocmd
)
Again, you may have to escape $
sign if $i
have to be developped by bsub
.
For working around $TERM
environment not set, I use sometime:
bsub -q medium -J $i /bin/bash <<-eocmd
...
eocmd
In the hope this could do the job.