-
Notifications
You must be signed in to change notification settings - Fork 1
MlAlign2DCshScript
Adrian Quintana edited this page Dec 11, 2017
·
1 revision
#!/usr/bin/csh
#
# Parallel maximum likelihood multi-reference refinement
# You need one disk (NFS-mount) for all processors
#
# Names of the processors where to run the calculations
set procs='ribera ribera ribeiro ribeiro rueda rueda'
# Output rootname
set MLroot="MLout"
# Start at iteration number iter (usually 0; restart at higher)
set iter = 0
# End at iteration number (convergence check does not work!)
set Niter = 100
# Input selfile containing all experimental images
set imgselfile="experimental.sel"
# Selfile containing all initial references (ignored if iter>0)
set inirefsel="my7refs.sel"
# Docfile with the initial model (&mirror) fractions (ignored if iter>0)
# if inifrac="" a docfile with an even distribution will be generated automatically
set inifrac=""
# Initial estimate for the standard deviation in the noise (ignored if iter>0)
set noise="1"
# Initial estimate for the standard deviation in the origin offsets (ignored if iter>0)
set offset="3"
# Additional parameters ( -mirror, -output_assignments, -psi_step 10, etc.)
set add_params=" -mirror"
#
################################################################
# Usually you don't need to change anything below this line #
################################################################
#
set logfile=`echo $MLroot".log"`
set tmpfile=`echo $MLroot".tmp"`
#
# Count number of processors:
#
set np = 0
foreach proc ($procs)
echo "Will use processor: " $proc
@ np = $np + 1
end
echo "Which makes a total of " $np " processors."
echo "Maximum Likelihood optimization using "$np" processors in parallel">$logfile
echo "Started on: "`date`
#
# Split selfile with experimental images in np random parts:
#
echo $imgselfile > $tmpfile
set imgselroot=`awk -F".sel" '{print $1}'<$tmpfile`
rm -f $tmpfile
xmipp_split_selfile -sel $imgselfile -n $np
#
# Initialize
#
set MLitroot=`echo $MLroot"_it"$iter`
set refselfile=`echo $MLitroot".sel"`
set reffracfile=`echo $MLitroot".log"`
if ($iter == 0) then
cp $inirefsel $refselfile
if ($inifrac == "") then
# Make even distribution docfile
set nref=`wc -l $inirefsel| awk '{print $1}'`
awk -v n=$nref 'BEGIN{i=0} {i++; print i,3,1/n,0.5,0 }'<$inirefsel >$reffracfile
else
cp $inifrac $reffracfile
endif
else
sed 's/ / /' $reffracfile >$tmpfile ; mv -f $tmpfile $reffracfile
set noise=`grep noise $reffracfile | head -1 | awk '{print $3}'`
set offset=`grep noise $reffracfile | head -1 | awk '{print $5}'`
endif
#
# Loop over iterations
#
while ($iter < $Niter)
#
@ iter = $iter + 1
#
# Set variable names
#
if ($iter <10) then
set MLitroot=`echo $MLroot"_it00"$iter`
else if ($iter <100) then
set MLitroot=`echo $MLroot"_it0"$iter`
else
set MLitroot=`echo $MLroot"_it"$iter`
endif
#
# Split in parallel parts to calculate all probabilities:
#
set ip = 0
set verb = 1
foreach proc ($procs)
@ ip = $ip + 1
set MLitprocroot=`echo $MLitroot"_pr"$ip`
set imgprocsel=`echo $imgselroot"_"$ip".sel"`
(rsh $proc "cd $currdir; xmipp_MLalign2D -i $imgprocsel -verb $verb -ref $refselfile -noise $noise -offset $offset -o $MLitprocroot -frac $reffracfile -iter 1 -dont_output_intermediate" $add_params) &
set verb = 0
end
wait
#
# update noise, offsets, fractions and reference images:
#
xmipp_do_selfile "$MLitroot*_pr*.log" >all.logsel
xmipp_MLalign2D_combine -i all.logsel -o $MLitroot
set reffracfile=`echo $MLitroot".log"`
set refselfile=`echo $MLitroot".sel"`
# Following line is neccesary on jumilla because grep, awk etc. seem buggy, or the file is strange...
sed 's/ / /' $reffracfile >$tmpfile ; mv -f $tmpfile $reffracfile
set noise=`grep noise $reffracfile | head -1 | awk '{print $3}'`
set offset=`grep noise $reffracfile | head -1 | awk '{print $5}'`
set LL=`grep LL $reffracfile | awk '{print $10}'`
echo " iter= "$iter" LL = " $LL" noise= "$noise" offset= "$offset" fractions in: "$reffracfile>>$logfile
echo " was finsihed on: "`date` >>$logfile
#
# Clean up
#
rm -f $MLitroot*_pr*.*
#
end
-- Main.SjorsScheres - 09 Jun 2008