#! /bin/csh -f # # Phaser Elves: Automatic DM Solvent flattening script # # #################################################################### set mtzfile = "mtz/mlphare.mtz" set outfile = "dmed.mtz" set tempfile = "./dm_temp" defaults: set SCHEME = "AUTO" set method = "PERT" set steps = "auto" set Solvent = "50%" # these are all reset from the command line set F = "FP" set SIGF = "SIGFP" set PHI = PHIB set FOM = FOM set HL = "HLA=HLA HLB=HLB HLC=HLC HLD=HLD" # different systems have different nawks alias nawk /usr/bin/nawk nawk 'BEGIN{print}' >& /dev/null if($status) alias nawk awk if("$1" == "") goto Help goto Setup # scan the command line Help: cat << EOF usage: $0 [mlphare.mtz] [50%] [Flo] where: mlphare.mtz - output MTZ from MLPHARE 50% - solvent content (must end with %) Flo - F you want to flatten with (default to best F in mtz) EOF exit 9 ReturnFromSetup: if(("$F" == "")||(! -e $mtzfile)) goto Help # make solvent content fractional set Solvent = `echo $Solvent | nawk '{print $1/100}' ` #################################################################### dm \ HKLIN $mtzfile \ HKLOUT $outfile \ << eof-dm TITLE Phase improvement from mlphare phases. # do flattening, histogram matching, and "multi-resolution" modification MODE SOLV HIST MULT # method of detecting bias in the flattened map COMBINE $method # number of flattening cycles to execute NCYCLE $steps # change last two values for buffer between solvent and protein #SOLC 0.628 MASK 0.60 0.37 SOLC $Solvent # "SCHEME ALL" is all spots at once (could also be AUTO, RES, FOM, MAG, etc.) SCHEME $SCHEME # print out realspace residuals REALFREE # defaults =-1.0 =2 =0.32 =2.0 e/A^3 #WANG -1.0 2 LIMITS 0.32 2.0 LABI FP=$F SIGFP=$SIGF PHIO=$PHI FOMO=$FOM $HL LABO PHIDM=PHIDM FOMDM=FOMDM HLADM=HLADM HLBDM=HLBDM HLCDM=HLCDM HLDDM=HLDDM END eof-dm if(! $status) then echo "$outfile is ready." else exit 2 endif exit #################################################################### Setup: #################################################################### # scan the command line foreach arg ( $* ) if( "$arg" =~ *.mtz ) set mtzfile = "$arg" if( "$arg" =~ *% ) set Solvent = "$arg" if(( "$arg" =~ *[0-9] )&&( "$arg" =~ [1-9]* )) set steps = "$arg" if( "$arg" == omit ) set method = "OMIT" end #let DM choose scheme for known # of steps #if("$steps" != "auto") set SCHEME = AUTO #get variables from mtz file echo "go" | mtzdump hklin $mtzfile |\ nawk '/OVERALL FILE STATISTICS/,/No. of reflections used/' |\ nawk 'NF>10 && $(NF-1) ~ /[FQPWADI]/' |\ cat >! ${tempfile}mtzdmp # use completeness, or F/sigF to pick default F cat ${tempfile}mtzdmp |\ nawk '$(NF-1) == "F"{F=$NF; meanF=$8; reso=$(NF-2); comp=substr($0,32)+0; \ getline; S=$NF; if($8) meanF /= $8; print F, S, reso, comp, meanF;}' |\ sort +2n -3 +3nr -4 +4nr >! ${tempfile}F # and extract all dataset types/labels cat ${tempfile}mtzdmp |\ nawk 'NF>2{print $(NF-1), $NF, " "}' |\ cat >! ${tempfile}cards #clean up rm -f ${tempfile}mtzdmp # pick F with best resolution, or F/sigma set F = `head -1 ${tempfile}F` if($#F > 2) then set SIGF = $F[2] set F = $F[1] endif # pick most recent phase/FOM grep "P $PHI " ${tempfile}cards >& /dev/null if($status) then set temp = `nawk '/^P/{print $2}' ${tempfile}cards | tail -1` if("$temp" != "") set PHI = "$temp" endif grep "W $FOM " ${tempfile}cards >& /dev/null if($status) then set temp = `nawk '/^W/{print $2}' ${tempfile}cards | tail -1` if("$temp" != "") set FOM = "$temp" endif # pick most recent HL coefficients cat ${tempfile}cards |\ nawk '$1=="A"{++n;HL[n]=$NF} END{for(i=1;i<=n;i+=4) \ print "HLA="HL[i],"HLB="HL[i+1],"HLC="HL[i+2],"HLD="HL[i+3]}' |\ cat >! ${tempfile}HL set HL = `tail -1 ${tempfile}HL` # see if user specified an F, Phase, FOM, or HL set foreach arg ( $* ) set temp = `grep " $arg " ${tempfile}cards` if("$temp" =~ F*) then set F = "${arg}" set temp = `nawk -v arg="$arg" '$1==arg{print $2}' ${tempfile}F` if($#temp == 1) set SIGF = "$temp" continue endif if("$temp" =~ P*) set PHI = "${arg}" if("$temp" =~ W*) set FOM = "${arg}" if("$temp" =~ A*) set HL = `grep "=${arg} " ${tempfile}HL | tail -1` end rm -f ${tempfile}cards ${tempfile}F ${tempfile}HL >& /dev/null goto ReturnFromSetup