Commit da077b04 authored by samuel hanot's avatar samuel hanot

use getopts to parse input

parent 2b27f061
......@@ -16,25 +16,22 @@ gnuplot (www.gnuplot.info/)
## usage:
```
${SRC_DIR}/recursive_gmconvert.sh MAP_NAME THRESHOLD n N i0 SERIAL
${SRC_DIR}/recursive_gmconvert.sh -f map_filename -t threshold -n num_gaussians -N num_iterations [-i first_iteration] [-s]
```
`MAP_NAME`: the file name of the input EM map
`THRESHOLD`: the density threshold
`n`: number of gaussians per sub-process. 2 or 4 is a good guess.
`N`: number recursion levels.
`i0`: initial recursion level (default: 1)
`SERIAL`: if set to 1, uses the serial implementation (default: 0)
Required arguments:
`-f map_filename`: the file name of the input EM map
`-t threshold`: the density threshold
`-n num_gaussians`: number of gaussians per sub-process
`-N num_iterations`: number of recursion levels
Optional arguments:
`-i first_iteration`: initial recursion level (defaults to 1)
`-s`: enable serial mode
`-h`: display this message
The script creates a sub-directory (called `i`) for each recursion level `i`, and the output files are called `i/i.gmm` and `i_imp.gmm`.
`i/i.gmm` contains the gmm in `gmconvert` format, and `i_imp.gmm` contains the gmm in `IMP` format (the conversion is handeld by `gmconvert2imp.sh`), which can be read in IMP using `IMP.isd.gmm_tools.decorate_gmm_from_text` function.
Unless you set SERIAL to 1, all the scripts assume that you are running a cluster with the `slurm` queuing system.
Unless you enable serial mode (`-s` flag), all the scripts assume that you are running a cluster with the `slurm` queuing system.
## References
......@@ -54,4 +51,4 @@ http://www.cell.com/biophysj/fulltext/S0006-3495%2808%2978604-1
G. Tang, L. Peng, P.R. Baldwin, D.S. Mann, W. Jiang, I. Rees & S.J. Ludtke.
(2007) J Struct Biol. 157, 38-46. PMID: 16859925
\ No newline at end of file
(2007) J Struct Biol. 157, 38-46. PMID: 16859925
#!/bin/zsh
profile_cmd="time"
map_name=$1
threshold=$2
n_gaussians=$3
N=$4
MaxArraySize=100000
get_max_jobs(){
echo ${MaxArraySize}
usage() {
echo >&2 \
"usage: recursive_gmconvert.sh -f map_filename -t threshold -n num_gaussians -N num_iterations [-i first_iteration] [-s]
Required arguments:
-f map_filename: the file name of the input EM map
-t threshold: the density threshold
-n num_gaussians: number of gaussians per sub-process
-N num_iterations: number of recursion levels
Optional arguments:
-i first_iteration: initial recursion level (defaults to 1)
-s: enable serial mode
-h: display this message"
}
#defaults
map_name=
threshold=
n_gaussians=
N=
i0=1
if [ -n "$5" ]
then
i0=$5
fi
serial=0
echo $i0
while getopts f:t:n:N:i:sh opt
do
case "$opt" in
f) map_name="$OPTARG";;
t) threshold="$OPTARG";;
n) n_gaussians="$OPTARG";;
N) N="$OPTARG";;
i) i0="$OPTARG";;
s) serial=1;;
h) usage
exit ;;
\?) # unknown flag
echo >&2 \
usage
exit 1;;
esac
done
serial=0
if [ -n "$6" ]
then
serial=$6
#check that necessary options were set
if [[ ! -e "$map_name" ]] || [[ -z "$threshold" ]] || [[ -z "$n_gaussians" ]] || [[ -z "$N" ]]
then
usage
exit 1
fi
MaxArraySize=100000
get_max_jobs(){
echo ${MaxArraySize}
}
profile_cmd="time"
bindir=${0:h}
impdir=~/imp-fast/
gmconvert=${bindir}/gmconvert/gmconvert
......@@ -40,7 +67,10 @@ do
n_jobs=1
if ((i==1))
then
${gmconvert} -imap ${map_name} -zth ${threshold} -oimap threshold.map -ogmm /dev/null -ng 0
if [[ ! -e threshold.map ]]
then
${gmconvert} -imap ${map_name} -zth ${threshold} -oimap threshold.map -ogmm /dev/null -ng 0
fi
echo ${profile_cmd} ${gmconvert} -imap ${map_name} -ogmm $n/${n}_0.gmm -ng ${n_gaussians} -zth ${threshold}
echo ${gmconvert} -igmm $n/${n}_0.gmm -imap ${map_name} -omap /dev/null
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment