#!/bin/csh -f # #===================================================================== # Submit charge flipping phasing procedure # ----------------------------------------- # # Charge Flipping for ab initio small-molecule structure determination # A van der Lee, C.Dumas & L. Palatinus (version june 10th, 2009) # # prepares input file for SUPERFLIP and EDMA program (L. Palatinus) # # #-------------------------------------------------------------------- # # Input files: #------------- # Shelx type INS file with cell info and scattering factor types # (space group symmetry is NOT read) # IMPORTANT: the cell parameters should be constrained to their lattice symmetry # Shelx type HKL file with the same generic name as the INS file # # output file: #-------------- # Shelx-type INS-file with atomic coordinates and symmetry information # #================================================================== # default parameters #-------------------- #set superflip exe name #set exeSF = "superflip100609" set exeSF = "superflip" set exeEDMA = "EDMA" # input ins file for extracting cell parameters set insin = "" set cifin = "" # set the weak parameter (% of weak reflexions) set weak = "0.20" set biso = "2.5" # set maxcycles and addcycles per trial set maxcycl = "10000" # one uninterrupted run or some intermediate stops set comments = "yes" # continue analysis if convergence is detected or not set edmacontinue = "no" # merge according to lattice symmetry set merge = "yes" # use symmetry from ins-file set forcesymmetry = "no" # normalize locally or not set normalize = "no" # set number of trials set repeat = "1" # set Space Group number (CCP4 convention) set SG = "" # help if ( {$#} < 1 || $1 == "-h" ) then cat << EOF usage: $0 data.ins or $0 data.ins maxcycles=30000 where: data.ins is input shelx-file with only cell info and scattering type info, optionally space group info optional: name=flip ...... generic name for output files (default data) trial=5 ...... number of repeated trials (default 1) normalize=yes ...... locally normalize the data (default no) maxcycl=30000 ...... maximum number of cycles per trial (default 10000) forcesymmetry=yes...... use symmetry from Shelx-file, that should obviously be present (default no) weak=0.1 ...... fraction of reflections considered to be weak (default 0.2) edmacontinue=no ...... continue if convergence is not detected (default no) comments=yes ...... have intermediate stops to check results (default=yes) EOF exit 9 endif # check superflip and EDMA, executable path $exeSF -V >& /dev/null if ( 0 != $status ) then echo " *** Problem with superflip program" echo "Check if $exeSF is in the PATH" exit endif $exeEDMA -V >& /dev/null if ( 0 != $status ) then echo " *** Problem with EDMA program" echo "Check if $exeEDMA is in the PATH" exit endif echo " " echo " ============================================================================ " echo " ! Ab initio Charge Flipping procedure ! " echo " ! for small-molecule structures ! " echo " ! ! " echo " ! script written by: A. van der Lee, C. Dumas & L. Palatinus ! " echo " ! CF and map interpretation calculations by : L. Palatinus & G. Chapuis ! " echo " ! Palatinus, L. & Chapuis, G.(2007): J. Appl. Cryst. 40, 786-790 ! " echo " ! http://superspace.epfl.ch/superflip ! " echo " ! ! " echo " ! script-version 100609 ! " echo " ============================================================================ " echo " " # loop for arguments #------------------- foreach arg ( $* ) # check input ins or cif file if ( "$arg" =~ *.ins ) then if (-e "$arg") then if ("$insin" == "") set insin = $arg else echo "ERROR: $arg does not exist" exit 9 endif endif if ( "$arg" =~ *.cif ) then if (-e "$arg") then if ("$cifin" == "") set cifin = $arg else echo "ERROR: $arg does not exist" exit 9 endif endif # maximum Cycles per trial if( "$arg" =~ maxcycl=* ) then set test = `echo $arg | awk -F "[=]" '$2+0>0{print $2+0}'` if("$test" != "") set maxcycl = $test endif # one run or ssome stops in between if( "$arg" =~ comments=* ) then set test = `echo $arg | awk -F "[=]" '{print $NF}'` if("$test" != "") set comments = $test endif # continue analysis if convergence is detected or not if( "$arg" =~ edmacontinue=* ) then set test = `echo $arg | awk -F "[=]" '{print $NF}'` if("$test" != "") set edmacontinue = $test endif # merge according to implied crystal system symmetry or not if( "$arg" =~ merge=* ) then set test = `echo $arg | awk -F "[=]" '{print $NF}'` if("$test" != "") set merge = $test endif # merge according to implied crystal system symmetry or not if( "$arg" =~ forcesymmetry=* ) then set test = `echo $arg | awk -F "[=]" '{print $NF}'` if("$test" != "") set forcesymmetry = $test endif if ( "$forcesymmetry" == "no" ) then set derivesymmetry = "use" else set derivesymmetry = "yes" endif # normalize locally or not if( "$arg" =~ normalize=* ) then set test = `echo $arg | awk -F "[=]" '{print $NF}'` if("$test" != "") set normalize = $test if ( "$normalize" == "local" ) then set biso = "0.0" endif endif # number of trials and map if( "$arg" =~ trial=* ) then set test = `echo $arg | awk -F "[=]" '$2+0>0{print $2+0}'` if("$test" != "") then set repeat = $test endif endif # check threshold parameter for weak reflextions if( "$arg" =~ weak=* ) then set test = `echo $arg | awk -F "[=]" '$2+0>0{print $2+0}'` if("$test" != "") set weak = $test endif end if ( "$normalize" =~ yes ) then set biso = "0" set normalize = "local" endif #.... Prepare input file and script for SUPERFLIP ........ #-------------------------------------------------------- # get cell dimensions and space group number and lattice info, first from ins file if ( "$insin" != "" ) then set generic = `echo $insin | sed 's/.ins//'` set hklin = `echo $insin | sed 's/ins/hkl/'` if !(-e "$hklin") then echo "ERROR: $hklin does not exist" exit 9 endif set cell = `grep CELL $insin | awk '{for (i=3; i<=NF; i++) printf("%10s",$i); }'` set wavelength = `grep CELL $insin | awk '{print $2}'` set LATT = `grep LATT $insin | awk '{printf("%5d", $2)}'` # look in shelx-file for symmetry information if ( "$forcesymmetry" == "yes" ) then set echec = `grep SYMM $insin` if ( "$echec" == "" ) then echo " There is no symmetry information in the .ins file, so forcesymmetry=yes cannot be used " echo " The calculation continues, but with forcesymmetry set to no " echo "" echo -n "Press ENTER to continue" echo "" set forcesymmetry = "no" set derivesymmetry = "use" set a = $< else cat <<+ > symcards.tmp symmetry X Y Z + grep SYMM $insin > tmp.ins grep LATT $insin >> tmp.ins if ( $LATT > 0 ) then cat <<+ >> symcards.tmp -X -Y -Z + endif set nsym = `grep -c "SYMM" tmp.ins` set licel = `grep -n "SYMM" tmp.ins | awk -F: '{print $1}'` set licel = `echo $licel | awk '{print $1}'` set n = "0" while ( $n != $nsym) set newsymop = "" set cev = `head -$licel tmp.ins | tail -1 | awk '{ for (i=2; i<=NF; i++) printf("%4s",$i);}' | sed 's/ //g'` # echo $cev set temp1 = `echo $cev | awk -F "," '{ for (i=1; i<=NF; i++) print $i;}'` cat <<+ >> symcards.tmp $temp1 + if ( $LATT > 0 ) then foreach i ( $temp1 ) set temp2 = `echo $i | awk '{ if ( match($1, "+") == 1 || match($1, "-") == 1 ) print $1; else\ print "+"$1 }'` set temp3 = `echo $temp2 | awk '{ for ( j = 1; j <= length($i); j++ ) \ if ( substr($i, j, 1) == "+" ) {str = substr($i, j, 1); sub("+","-",str); print str} else\ if ( substr($i, j, 1) == "-" ) {str = substr($i, j, 1); sub("-","+",str); print str} else\ {str = substr($i, j, 1); print str}}'` set temp4 = `echo $temp3 | sed 's/ //g'` set newsymop = ( $newsymop $temp4 ) end cat <<+ >> symcards.tmp $newsymop + endif @ n = $n + 1 @ licel = $licel + 1 end cat <<+ >> symcards.tmp endsymmetry + rm tmp.ins endif endif # there can be two types of shelx-files displaying SFAC info, either on one line or on more than one line set snfac = `grep -c SFAC $insin` if ( $snfac == "1" ) then # the second character of a two-character scattering type needs to be lower-case! set sfac = `grep SFAC $insin | awk '{ for (i=2; i<=NF; i++) if (length($i) > 1) print " " substr($i,1,1) tolower(substr($i,2,1)) ; else printf("%4s",$i);}'` else # see while loops below for searching un unknown number of symops HERE BELOW set licel = `grep -n "SFAC" $insin | awk -F: '{print $1}'` set licel = `echo $licel | awk '{print $1}'` set sfac = "" set n = "0" while ( $n != $snfac) set cev = `head -$licel $insin | tail -1` set temp = `echo $cev | grep "SFAC"` if ( "$temp" != "" ) then set cev = `echo $cev | awk '{printf("%4s",$2)}'` @ n = $n + 1 set sfac = ($sfac $cev) endif @ licel = $licel + 1 end set sfac = `echo $sfac | awk '{ for (i=1; i<=NF; i++) if (length($i) > 1) print " " substr($i,1,1) tolower(substr($i,2,1)) ; else printf("%4s",$i);}'` endif set dataformat = "shelx" endif if ( "$cifin" != "" ) then dos2unix $cifin >& /dev/null set generic = `echo $cifin | sed 's/.cif//'` set hklin = `echo $cifin | sed 's/cif/hkl/'` if ( "$forcesymmetry" == "yes" ) then echo "" echo " Forcesymmetry=yes is not compatible with input from a cif-file, continue with forcesymmetry= no echo "" set forcesymmetry = "no" echo -n "Press ENTER to continue the structure solution by charge flipping" set a = $< endif set a = `grep "_cell_length_a" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set b = `grep "_cell_length_b" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set c = `grep "_cell_length_c" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set alpha = `grep "_cell_angle_alpha" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set beta = `grep "_cell_angle_beta" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set gamma = `grep "_cell_angle_gamma" $cifin | awk '{ where = match($2,"\\(") - 1; if (where > 0) print substr($2,1,where) ; else print $2;}'` set cell = ( $a $b $c $alpha $beta $gamma ) set wavelengthtype = `grep "_diffrn_radiation_type" $cifin | awk '{ for (i=2; i <=NF; i++) print $i }' | sed "s/'//g"` if ( "$wavelengthtype" == "Mo K-alpha" ) then set wavelength = "0.71073" endif if ( "$wavelengthtype" == "Cu K-alpha" ) then set wavelength = "1.5405" endif set sfac = `grep "_chemical_formula_sum" $cifin | awk '{ for (i=2; i <=NF; i++) print $i }' | sed "s/'//g"` set spgrcifcent = `grep "_symmetry_space_group_name_H-M" $cifin | awk '{ for (i=2; i <=NF; i++) print $i }' | sed "s/'//g" | sed "s/ //g" | awk '{ print substr($1,1,1)}'` if ( "$spgrcifcent" == "P" ) set LATT = "1" if ( "$spgrcifcent" == "I" ) set LATT = "2" if ( "$spgrcifcent" == "R" ) set LATT = "3" if ( "$spgrcifcent" == "F" ) set LATT = "4" if ( "$spgrcifcent" == "A" ) set LATT = "5" if ( "$spgrcifcent" == "B" ) set LATT = "6" if ( "$spgrcifcent" == "C" ) set LATT = "7" # # process reflections set lice = ` grep -c "_refln_" $cifin ` if ( "$lice" == "" && !(-e "$hklin") ) then echo "ERROR: no reflection-file $hklin and no reflections in cif-file, exit" exit 9 endif if ( "$lice" == "" && (-e "$hklin") ) then # go to shelxmode set dataformat = "shelx" else if (-e "$hklin") then set dataformat = "shelx" else set licel = `grep -n "_refln_index_h" $cifin | awk -F: '{print $1}'` set lice2 = `wc -l $cifin | awk '{print $1}'` @ licel = $licel + $lice if ( $lice > 5 ) then echo "Complicated cif-structure: this will take time. Please be patient - a HKLF4 file will be created" echo -n "Press ENTER to continue the building of the HKLF4 file" set a = $< touch $hklin # now process line for line up until we have lice items set counter = $licel set refline = "" set reflitems = ( 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) grep "_refln_" $cifin > temp.tmp set nlines = `wc -l temp.tmp | awk '{print $1+1}'` set n = 1 while ( $n != $nlines ) set reflitems[$n] = `head -$n temp.tmp | tail -1` @ n = $n + 1 end rm temp.tmp set reflitemnumber = ( 0 0 0 0 0) set nc = 1 foreach i ( $reflitems ) if ( "$reflitems[$nc]" == "_refln_index_h" ) set reflitemnumber[1] = $nc if ( "$reflitems[$nc]" == "_refln_index_k" ) set reflitemnumber[2] = $nc if ( "$reflitems[$nc]" == "_refln_index_l" ) set reflitemnumber[3] = $nc if ( "$reflitems[$nc]" == "_refln_F_squared_meas" ) set reflitemnumber[4] = $nc if ( "$reflitems[$nc]" == "_refln_F_squared_sigma" ) set reflitemnumber[5] = $nc @ nc = $nc + 1 end while ( $counter != $lice2 ) set refline = ( $refline `sed -n "$counter,$counter p" $cifin` ) if ( $#refline == $lice ) then set refloutput = "" foreach i ( $reflitemnumber ) set refloutput = ( $refloutput $refline[$i] ) end echo $refloutput | awk '{ printf "%4d%4d%4d%8.2f%8.2f\n", $1, $2, $3, $4, $5}' >> $hklin echo $refloutput set refline = "" endif @ counter = $counter + 1 end set dataformat = "shelx" else # simple cif structure # grab reflections and put them in a temporary file sed -n "$licel,$lice2 p" $cifin > temp.hkl set dataformat = "intensity" set hklin = "from cif-file" endif endif endif endif set crsyst = `echo $cell |\ awk '{\ if ( $4 == 90 && $6 == 90 && $5 == 90 && $1 == $2 && $1 == $3 && $2 == $3 )\ print "cubi"; else\ if ( $4 != 90 && $6 != 90 && $5 != 90 && $1 != $2 && $1 != $3 && $2 != $3 )\ print "tric"; else\ if ( $4 == 90 && $6 == 90 && $5 != 90 && $1 != $2 && $1 != $3 && $2 != $3 )\ print "mono"; else\ if ( $4 == 90 && $6 == 90 && $5 == 90 && $1 != $2 && $1 != $3 && $2 != $3 )\ print "orth"; else\ if ( $4 == 90 && $6 == 90 && $5 == 90 && $1 == $2 && $1 != $3 && $2 != $3 )\ print "tetr"; else\ if ( $6 == 120 && $4 == 90 && $5 == 90 && $1 == $2 && $1 != $3 && $2 != $3 )\ print "trig"; else\ print "tric"}'` if ( "$forcesymmetry" == "no" ) then cat <<+ > symcards.tmp symmetry x y z + if ( "$crsyst" == "tric" ) then set SG = "2" cat <<+ >> symcards.tmp -x -y -z + endif if ( "$crsyst" == "mono" ) then set SG = "3" cat <<+ >> symcards.tmp -x y -z + endif if ( "$crsyst" == "orth" ) then set SG = "16" cat <<+ >> symcards.tmp -x -y z -x y -z x -y -z + endif if ( "$crsyst" == "tetr" ) then set SG = "75" cat <<+ >> symcards.tmp -x -y z -y x z y -x z + endif if ( "$crsyst" == "trig" ) then set SG = "143" cat <<+ >> symcards.tmp -y x-y z -x+y -x z + endif if ( "$crsyst" == "cubi" ) then set SG = "195" cat <<+ >> symcards.tmp -x -y z -x y -z x -y -z z x y z -x -y -z -x y -z x -y y z x -y z -x y -z -x -y -z x + endif if( "$merge" =~ no ) then set SG = "2" cat <<+ >> symcards.tmp -x -y -z + endif cat <<+ >> symcards.tmp endsymmetry + else set SG = "as in import file" endif # with the new "missing" keyword as default option it is important to get the centring information # from the ins of cif-file and to insert it in the .inflip file cat <<+ > lattcards.tmp centers 0.000 0.000 0.000 + if ( "$LATT" == "" ) then set missing = "zero" else if ( "$normalize" == "no" ) then set missing = "float 0.4" else set missing = "bound 0.4 4" endif # define the centering vectors if ( "$LATT" == "1" || "$LATT" == "-1" ) then cat <<+ >> lattcards.tmp + endif if ( $LATT == 2 || $LATT == -2 ) then cat <<+ >> lattcards.tmp 0.500 0.500 0.500 + endif if ( $LATT == 3 || $LATT == -3 ) then cat <<+ >> lattcards.tmp 0.66666667 0.33333333 0.33333333 0.33333333 0.66666667 0.66666667 + endif if ( $LATT == 4 || $LATT == -4 ) then cat <<+ >> lattcards.tmp 0.500 0.500 0.000 0.500 0.000 0.500 0.000 0.500 0.500 + endif if ( $LATT == 5 || $LATT == -5 ) then cat <<+ >> lattcards.tmp 0.000 0.500 0.500 + endif if ( $LATT == 6 || $LATT == -6 ) then cat <<+ >> lattcards.tmp 0.500 0.000 0.500 + endif if ( $LATT == 7 || $LATT == -7 ) then cat <<+ >> lattcards.tmp 0.500 0.500 0.000 + endif cat <<+ >> lattcards.tmp endcenters + endif if ( "$insin" != "" ) set import = $insin if ( "$cifin" != "" ) set import = $cifin cat << EOF ------------------- Crystal data -------------------- import file ....... $import hkl-file ....... $hklin generic name ....... $generic unit cell parameters ....... $cell crystal system ....... $crsyst merging space group ....... $SG ---------------- CF parameters used ----------------- weak threshold ....... $weak Biso ...... $biso maximum cycles / trial ...... $maxcycl normalize ...... $normalize number of trials ...... $repeat ---------------------------------------------------- EOF if ( "$comments" == "yes" ) then echo -n "Press ENTER to continue the structure solution by charge flipping" set a = $< endif # generate charge flipping input file: #------------------------------------- cat <<+ > $generic.inflip #============================================= # Ab initio phasing by Charge Flipping # # SUPERFLIP # #============================================= title ab initio Phasing by Charge Flipping # Basic crystallographic information cell $cell + cat < symcards.tmp >> $generic.inflip cat < lattcards.tmp >> $generic.inflip cat <<+ >> $generic.inflip voxel AUTO # Keywords influencing the CF algorithm weakratio $weak biso $biso normalize $normalize missing $missing maxcycles $maxcycl repeatmode $repeat # Output density map searchsymmetry average derivesymmetry $derivesymmetry outputfile $generic.m81 # Input reflections dataformat $dataformat + if ( "$dataformat" == "shelx" ) then cat <<+ >> $generic.inflip fbegin $generic.hkl endf + endif if ( "$dataformat" == "intensity" ) then cat <<+ >> $generic.inflip fbegin + cat < temp.hkl >> $generic.inflip cat <<+ >> $generic.inflip endf + rm temp.hkl endif # time $exeSF $generic.inflip >> $logfile & /usr/bin/time -p $exeSF $generic.inflip if ( $repeat > 1 ) then set ccount = `grep -c "5 cycles of noise suppression follow" $generic.sflog` set licel = `grep -n "5 cycles of noise suppression follow" $generic.sflog | awk -F: '{print $1}'` @ ccount = $ccount + 1 set n = "1" set rfac = "" while ( $n != $ccount) @ m = $licel[$n] + 1 set cev = `head -$m $generic.sflog | tail -1 | awk '{printf("%6s",$3)}'` set rfac = ( $rfac $cev ) @ n = $n + 1 end # echo $rfac set bestrnr = `echo $rfac | awk 'BEGIN {min=100.0}\ { for (i=1; i<=NF; i++) if ($i < min) {j = i; min = $i}} \ END { printf(" %3d", j) }'` @ ccount = $ccount - 1 if ( $bestrnr != $ccount ) then set line1 = `grep -n "Run number" $generic.sflog | awk -F: -v pat=" $bestrnr. Still" '$0 ~ pat {print $1}'` else set line1 = `awk 'END{print NR}' $generic.sflog` endif #echo $line1 @ bestrnr = $bestrnr - 1 if ( $bestrnr == 0 ) then set line0 = 1 else set line0 = `grep -n "Run number" $generic.sflog | awk -F: -v pat=" $bestrnr. Still" '$0 ~ pat {print $1}'` endif #echo $line0 @ nlines = $line1 - $line0 head -$line1 $generic.sflog | tail -$nlines > runfile.log set uselog = "runfile.log" else set uselog = "$generic.sflog" endif set success = `grep " No convergence was detected after" $uselog` set PhiS = `grep "Overall agreement factor:" $uselog` set PhiSym = `grep "Overall agreement factor:" $uselog | awk '{print $NF}'` if ( "$PhiS" == "" ) set PhiS = "100.0" set trivialsym = `grep "No symmetry operations with agreement factor below" $uselog` set SpGr = `grep "HM symbol" $uselog | awk '{print $NF}'` # in order to assure backward compatibility if ( "$SpGr" == "" ) then set SpGr = `grep "Tentative space group symbol" $uselog | awk '{print $NF}'` endif set threshold = ( $PhiSym 25.0 ) set PhiSymLow = `echo $threshold | awk '{ if ( $1 < $2 ) print "yes"}'` echo "" echo "" echo "" echo " =====================================================" echo " ANALYSIS OF THE RESULTS " echo " =====================================================" echo "" echo "" if ( $repeat > 1 ) then set successrate = `grep "Success rate" $generic.sflog | awk '{print $NF}'` echo " Success rate: ""$successrate""% ($repeat trials)" endif if ("$success" != "" && "$PhiSymLow" == "" ) then echo "" echo " *** No convergence detected ***" echo "" if ( "$edmacontinue" == "no" ) then echo " * you can try another time" echo "" exit else echo " * continue anyhow" echo "" endif endif if ("$success" != "" && "$PhiSymLow" == "yes" && "$trivialsym" == "") then echo "" echo " *** No Convergence detected but low PhiSym ***" echo " *** Structure is probably solved ***" echo "" echo " PhiSym = " $PhiS"%" echo "" echo " *** Spacegroup proposed: $SpGr ****" endif if ("$success" == "" && "$PhiSymLow" == "" && "$trivialsym" != "" ) then echo "" echo " *** Convergence detected ***" echo " *** Structure is probably solved ***" echo "" echo "" echo " *** Spacegroup proposed: $SpGr ****" endif if ("$success" == "" && "$PhiSymLow" == "yes" && "$trivialsym" == "" ) then echo "" echo " *** Convergence detected and low PhiSym ***" echo " *** Structure is most probably solved ***" echo "" echo " PhiSym = " $PhiS"%" echo "" echo " *** Spacegroup proposed: $SpGr ****" if ( "$forcesymmetry" == "yes" ) then echo " *** Check carefully if this is the same as in the ins-file ****" echo " *** The map interpretation will be done using the symmetry in the ins-file ****" endif endif if ("$success" == "" && "$PhiSymLow" == "" && "$trivialsym" == "" ) then echo "" echo " *** Convergence detected but high PhiSym *****" echo " *** Structure is most probably solved ****" echo " *** but the space group is probably wrong ****" echo " PhiSym = " $PhiS"%" if ( "$forcesymmetry" == "yes" ) then echo "" echo " You may consider to use forcesymmetry=no or " echo " to use in your input (ins)file the space group " echo " proposed by Superflip " echo " Note that the resulting structure is possibly wrong " echo "" endif echo "" echo " *** Spacegroup proposed: $SpGr **** " endif echo " " echo " *********** SUPERFLIP procedure finished **********" echo " " echo " Input file for SUPERFLIP ....................... "$generic".inflip" echo " Input hkl-amplitude file for SUPERFLIP .......... "$generic".hkl " echo " SUPERFLIP logfile in ............................ "$generic".sflog " echo " " if ( "$comments" == "yes" ) then echo -n "Press ENTER to continue the map interpretation" set a = $< endif set edmain = $generic"_edma.inflip" set edmaout = $generic"_structure.ins" # Create new superflip-file for use with EDMA # Pick up symmetry operators of newly proposed space group # Are there centering vectors? if ( "$forcesymmetry" == "yes" ) set SpGr = "space group from ins-file" cat <<+ > $edmain #============================================= # Map interpretation # # EDMA # #============================================= title CF solution in $SpGr # Basic crystallographic information cell $cell + if ( "$forcesymmetry" == "no" ) then set NCent = `grep "Centering vectors" $uselog` if ( "$NCent" != "" ) then cat <<+ >> $edmain centers + set licel = `grep -n "Space group derived from the symmetry operations" $uselog | awk -F: '{print $1+3}'` set n = "1" while ( $n != "0") set cev = `head -$licel $uselog | tail -1` if ( "$cev" != "" ) then #echo $cev foreach i ( 1 2 3 ) if ( "$cev[$i]" == "0.667" ) then set cev[$i] = "0.66666667" else if ( "$cev[$i]" == "0.333" ) then set cev[$i] = "0.33333333" endif endif end cat <<+ >> $edmain $cev + else set n = 0 endif @ licel = $licel + 1 end cat <<+ >> $edmain endcenters + else cat <<+ >> $edmain centers 0.0000000000 0.0000000000 0.0000000000 endcenters + endif set licel = `grep -n "Space group derived from the symmetry operations" $uselog | awk -F: '{print $1+3}'` # search for first occurrence of "symmetry operations:" after this point set n = "1" while ( $n != "0") set cev = `head -$licel $uselog | tail -1` if ( "$cev" == "Symmetry operations:" ) then set n = 0 endif @ licel = $licel + 1 end #now pick up all symmetry operations until the blank line cat <<+ >> $edmain symmetry + set n = "1" while ( $n != "0") set csym = `head -$licel $uselog | tail -1| awk '{for (i=2; i<=NF; i++) printf("%10s",$i); }'` if ( "$csym" != "" ) then cat <<+ >> $edmain $csym + else set n = 0 endif @ licel = $licel + 1 end cat <<+ >> $edmain endsymmetry + # forcesymmetry = yes else cat < symcards.tmp >> $edmain cat < lattcards.tmp >> $edmain endif #EDMA specific keywords # EDMA-specific keywords cat <<+ >> $edmain # EDMA-specific keywords inputfile $generic.m81 outputbase $generic export $edmaout numberofatoms 0 composition $sfac maxima all fullcell no scale fractional plimit 1.5 sigma centerofcharge yes chlimit 0.2500 + /usr/bin/time -p $exeEDMA $edmain #correct wavelength in output .ins file awk '{ if ( $1 == "CELL") $2 = '$wavelength'; print}' $edmaout > temp.ins rm $edmaout mv temp.ins $edmaout echo "" echo " *** map interpretation done ***" echo "" echo " Output structure in $edmaout" echo "" echo "" echo "" rm fort.10 sed "/FVAR 1/i\\ L.S. 4\\ WGHT 0.1\\ FMAP 2\\ PLAN 25\\ BOND" $edmaout > tmp.tmp mv tmp.tmp $edmaout sed "/END/i\\ HKLF 4" $edmaout > tmp.tmp mv tmp.tmp $edmaout if !(-e "$generic""_structure.hkl") then ln -s $hklin "$generic""_structure.hkl" endif if ( $repeat > 1 ) then rm $uselog endif rm lattcards.tmp rm symcards.tmp exit