Commit da077b04 authored by samuel hanot's avatar samuel hanot
Browse files

use getopts to parse input

parent 2b27f061
...@@ -16,25 +16,22 @@ gnuplot (www.gnuplot.info/) ...@@ -16,25 +16,22 @@ gnuplot (www.gnuplot.info/)
## usage: ## 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]
``` ```
Required arguments:
`MAP_NAME`: the file name of the input EM map `-f map_filename`: the file name of the input EM map
`-t threshold`: the density threshold
`THRESHOLD`: the density threshold `-n num_gaussians`: number of gaussians per sub-process
`-N num_iterations`: number of recursion levels
`n`: number of gaussians per sub-process. 2 or 4 is a good guess. Optional arguments:
`-i first_iteration`: initial recursion level (defaults to 1)
`N`: number recursion levels. `-s`: enable serial mode
`-h`: display this message
`i0`: initial recursion level (default: 1)
`SERIAL`: if set to 1, uses the serial implementation (default: 0)
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`. 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. `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 ## References
......
#!/bin/zsh #!/bin/zsh
profile_cmd="time" usage() {
echo >&2 \
map_name=$1 "usage: recursive_gmconvert.sh -f map_filename -t threshold -n num_gaussians -N num_iterations [-i first_iteration] [-s]
threshold=$2 Required arguments:
n_gaussians=$3 -f map_filename: the file name of the input EM map
N=$4 -t threshold: the density threshold
MaxArraySize=100000 -n num_gaussians: number of gaussians per sub-process
-N num_iterations: number of recursion levels
get_max_jobs(){ Optional arguments:
echo ${MaxArraySize} -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 i0=1
if [ -n "$5" ] serial=0
then
i0=$5
fi
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 #check that necessary options were set
if [ -n "$6" ] if [[ ! -e "$map_name" ]] || [[ -z "$threshold" ]] || [[ -z "$n_gaussians" ]] || [[ -z "$N" ]]
then then
serial=$6 usage
exit 1
fi fi
MaxArraySize=100000
get_max_jobs(){
echo ${MaxArraySize}
}
profile_cmd="time"
bindir=${0:h} bindir=${0:h}
impdir=~/imp-fast/ impdir=~/imp-fast/
gmconvert=${bindir}/gmconvert/gmconvert gmconvert=${bindir}/gmconvert/gmconvert
...@@ -39,8 +66,11 @@ do ...@@ -39,8 +66,11 @@ do
n_jobs=1 n_jobs=1
if ((i==1)) if ((i==1))
then
if [[ ! -e threshold.map ]]
then then
${gmconvert} -imap ${map_name} -zth ${threshold} -oimap threshold.map -ogmm /dev/null -ng 0 ${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 ${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 echo ${gmconvert} -igmm $n/${n}_0.gmm -imap ${map_name} -omap /dev/null
else 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