#!/bin/tcsh -f # # # Non-interactive Mosflm (6.11) script # # # Save the command-line arguments # # set cmdarguments = set num = 1 while (${num} <= ${#argv}) set cmdarguments = (${cmdarguments} 1) @ num = ${num} + 1 end set num = 1 while (${num} <= ${#argv}) set cmdarguments[${num}] = "${argv[${num}]}" @ num = ${num} + 1 end # # start: # # if (${0:h} == ${0}) then set cmd = "" else set cmd = "${0:h}/" endif # # source ${cmd}makesymbols # # source symbols # # # Unset the first image number so it will be inferred from the image name # # set firstimagenumber = # # # Define the usage specific to mosflm # # if (${?input} == 0 || ${?help} == 0) then # # set input = 'imagename' # # set help = (title \ directory \ ident \ extension \ phi \ beamcenter \ backstopcenter \ backstopradius \ mosaic \ outputroot \ space \ highres \ lowres \ addinteg \ twotheta \ nullpix \ overload \ wavelength \ gain \ polarization \ divergence \ dispersion \ raster \ separation) endif # # source ${cmd}cmdargs # # # Interpret the unmatched arguments # # if (${#argv} >= 1) then # # # Has the imagename changed? # # if (${?imagename}) then if (${1:t} != ${imagename}) then if (${imagename} != "") then echo "" echo " WARNING: THE FIRST IMAGE HAS CHANGED - THE SAVED SYMBOLS MAY BE INCORRECT" echo "" echo -n " Would you like to delete the saved symbols? (y/n) " if ($< =~ [yY]*) then rm -f symbols # # # Restore the command-line arguments # # set argv = set num = 1 while (${num} <= ${#cmdarguments}) set argv = (${argv} 1) @ num = ${num} + 1 end set num = 1 while (${num} <= ${#cmdarguments}) set argv[${num}] = "${cmdarguments[${num}]}" @ num = ${num} + 1 end goto start endif endif endif endif set imagename = ${1:t} if (${1:h} != ${1}) then set directory = ${1:h} else if (${?directory}) then if (-e ${imagename}) then unset directory endif endif endif endif # # # Save the symbols # # source ${cmd}savesymbols # # # Do any symbols have defaults? # # source ${cmd}defaults # # # Interrupt action # # onintr interrupt # # # Check for required input # # if (${?imagename} == 0) then echo " " echo " ERROR: image name not specified, program exit. " echo " " echo " Usage:" ${0} " imagename [...] " echo " " kill -9 $$ endif # # # Make the mosflm input file # # echo > ${tmpfile}.mosflm # # if (${?title}) then echo "TITLE ${title}" >> ${tmpfile}.mosflm endif # # echo "GENFILE ${outputroot}.gen" >> ${tmpfile}.mosflm # # if (${?space}) then if (-e ${outputroot}.mat) then echo "SYMM ${space}" >> ${tmpfile}.mosflm echo "MATRIX ${outputroot}.mat" >> ${tmpfile}.mosflm endif endif echo "NEWMAT ${outputroot}.mat" >> ${tmpfile}.mosflm # # if (${?mosaic}) then echo "MOSAIC ${mosaic}" >> ${tmpfile}.mosflm else echo "MOSAIC 0.5" >> ${tmpfile}.mosflm endif # # # CCD detector? # # if (${extension} == img) then if (${scanner[1]} == QUANTUM4) then echo "SITE SSRL ADSC" >> ${tmpfile}.mosflm echo "ADCOFFSET 20" >> ${tmpfile}.mosflm echo "FINDSPOTS YOFFSET 3.5" >> ${tmpfile}.mosflm endif # # if (${scanner[1]} == QUANTUM315) then echo "SCANNER ADSC" >> ${tmpfile}.mosflm echo "ADCOFFSET 40" >> ${tmpfile}.mosflm echo "LIMITS XMIN 0 XMAX 315 YMIN 0 YMAX 315 XSCAN 157.5 YSCAN 157.5" >> ${tmpfile}.mosflm endif endif # # if (${?beamcenter}) then if (${?twotheta}) then echo "BEAM SWUNG_OUT ${beamcenter}" >> ${tmpfile}.mosflm else echo "BEAM ${beamcenter}" >> ${tmpfile}.mosflm endif endif # # if (${?twotheta}) then echo "TWOTHETA ${twotheta}" >> ${tmpfile}.mosflm endif # # if (${?backstopcenter}) then echo "BACKSTOP CENTRE ${backstopcenter}" >> ${tmpfile}.mosflm endif if (${?backstopradius}) then echo "BACKSTOP RADIUS ${backstopradius}" >> ${tmpfile}.mosflm endif # # if (${?gain}) then echo "GAIN ${gain}" >> ${tmpfile}.mosflm endif # # if (${?distance}) then echo "DISTANCE ${distance}" >> ${tmpfile}.mosflm endif # # # Image and Processing parameters # # if (${?directory}) then echo "DIRECTORY ${directory}" >> ${tmpfile}.mosflm endif # # if (${?raster}) then if (${#raster} == 5) then echo "RASTER ${raster}" >> ${tmpfile}.mosflm endif endif # # if (${?separation}) then if (${#separation} == 2 || ${#separation} == 3) then echo "SEPARATION ${separation}" >> ${tmpfile}.mosflm endif endif # # # Limits # # if (${?nullpix}) then echo "NULLPIX ${nullpix}" >> ${tmpfile}.mosflm endif # # if (${?overload}) then echo "OVERLOAD CUTOFF ${overload}" >> ${tmpfile}.mosflm echo "PROFILE CUTOFF ${overload}" >> ${tmpfile}.mosflm endif # # if (${?highres}) then if (${?lowres}) then echo "RESOLUTION ${lowres} ${highres}" >> ${tmpfile}.mosflm else echo "RESOLUTION ${highres}" >> ${tmpfile}.mosflm endif endif # # # Beam Line parameters # # if (${?polarization}) then echo "SYNCHROTRON POLARIZATION ${polarization}" >> ${tmpfile}.mosflm endif # # if (${?divergence}) then if (${#divergence} == 1) then echo "DIVERGENCE ${divergence}" >> ${tmpfile}.mosflm else echo "DIVERGENCE ${divergence[1]} ${divergence[2]}" >> ${tmpfile}.mosflm endif endif # # if (${?dispersion}) then echo "DISPERSION ${dispersion}" >> ${tmpfile}.mosflm endif # # if (${?wavelength}) then echo "WAVELENGTH ${wavelength}" >> ${tmpfile}.mosflm endif # # echo "REFINEMENT CYCLES 8" >> ${tmpfile}.mosflm # # set num = 1 if (${?addinteg}) then while (${num} <= ${#addinteg}) if ("${addinteg[${num}]}" !~ [Pp][Rr][Oo][Cc]*) then if ("${addinteg[${num}]}" !~ [Ee][Xx][Tt][Ee]*) then if ("${addinteg[${num}]}" !~ [Ii][Dd][Ee][Nn]*) then if ("${addinteg[${num}]}" !~ [Rr][Uu][Nn]*) then if ("${addinteg[${num}]}" !~ [Ee][Nn][Dd]*) then echo "${addinteg[${num}]}" >> ${tmpfile}.mosflm endif endif endif endif endif @ num = ${num} + 1 end endif # # if (${?phi}) then echo "IMAGE ${imagename} PHI ${phi[1]} TO ${phi[2]}" >> ${tmpfile}.mosflm else echo "IMAGE ${imagename}" >> ${tmpfile}.mosflm endif # # echo "TIMEOUT 1" >> ${tmpfile}.mosflm cat $NIMOSFLM_COMMAND_FILE >> ${tmpfile}.mosflm echo "GO" >> ${tmpfile}.mosflm echo "END" >> ${tmpfile}.mosflm # echo '' echo '************* MOSFLM INPUT FILE ****************' cat ${tmpfile}.mosflm echo '********** END OF MOSFLM INPUT FILE ************' echo '' # # # Run mosflm # # which ipmosflm ipmosflm HKLOUT ${outputroot}.mtz \ SPOTOD ${outputroot}.spt \ SUMMARY ${outputroot}.mosflm_sum \ COORDS ${outputroot}.coords < ${tmpfile}.mosflm | tee /dev/null # # if (-e mosflm.lp) then # # # Get the current version number # # set logfiles = `ls ${outputroot}.mosflm_log*` set version = 0 set num = 1 while (${num} <= ${#logfiles}) echo -n "set tmp = " > ${tmpfile} echo "(${logfiles[${num}]:e})" | sed "s/[a-z_]/ /g" >> ${tmpfile} source ${tmpfile} rm -f ${tmpfile} if (${tmp} > ${version}) then @ version = ${tmp} endif @ num = ${num} + 1 end @ version = ${version} + 1 # # # Rename the log file # # mv mosflm.lp ${outputroot}.mosflm_log${version} # # if (-e ${outputroot}.mosflm_log) then if (-l ${outputroot}.mosflm_log) then rm -f ${outputroot}.mosflm_log ln -s ${outputroot}.mosflm_log${version} ${outputroot}.mosflm_log endif else ln -s ${outputroot}.mosflm_log${version} ${outputroot}.mosflm_log endif # # endif # # # Read BEAM # BACKSTOP # SYMMETRY # MOSAIC # WAVELENGTH # DISTANCE # RESOLUTION # RASTER and # SEPARATION from the .sav file # # if (-e ${outputroot}.sav) then # # # BEAM # # set tmp = `grep -i "^BEAM" ${outputroot}.sav` if (${#tmp} >= 3) then set beamcenter = ( ${tmp[2]} ${tmp[3]} ) endif # # # BACKSTOP # # set tmp = `grep "^BACKSTOP" ${outputroot}.sav` set num = 1 while (${#tmp} >= 2) if (${#tmp} >= 3) then if (${tmp[1]} =~ [Cc][Ee][Nn][Tt]*) then set backstopcenter = (${tmp[2]} ${tmp[3]}) endif endif if (${tmp[1]} =~ [Rr][Aa][Dd][Ii]*) then set backstopradius = ${tmp[2]} endif shift tmp end # # # SYMMETRY # # if (${?space} == 0) then set space = 0 endif if (${space} == "0") then set tmp = `grep -i "^SYMMETRY" ${outputroot}.sav` if (${#tmp} >= 2) then set space = ${tmp[2]} endif endif # # # MOSAIC # # set tmp = `grep -i "^MOSAIC" ${outputroot}.sav` if (${#tmp} >= 2) then if (${tmp[2]} != "0.50") then set mosaic = ${tmp[2]} endif endif # # # WAVELENGTH # # set tmp = `grep -i "^WAVELENGTH" ${outputroot}.sav` if (${#tmp} >= 2) then if (${tmp[2]} != "0.50") then set wavelength = ${tmp[2]} endif endif # # # DISTANCE # # set tmp = `grep -i "^DISTANCE" ${outputroot}.sav` if (${#tmp} >= 2) then set distance = ${tmp[2]} endif # # # RESOLUTION # # set tmp = `grep -i "^RESOLUTION" ${outputroot}.sav` if (${#tmp} >= 2) then if (${#tmp} >= 3) then echo ${tmp[2]} " " ${tmp[3]} > ${tmpfile}.limits set highres = `awk '{ if ($1 < $2) print $1; else print $2 }' ${tmpfile}.limits` set lowres = `awk '{ if ($1 > $2) print $1; else print $2 }' ${tmpfile}.limits` else set highres = ${tmp[2]} endif endif # # # RASTER # # set tmp = `grep -i "^RASTER" ${outputroot}.sav` set raster = if (${#tmp} >= 6) then if (${tmp[2]} > 0 && ${tmp[3]} > 0 && ${tmp[4]} > 0 && ${tmp[5]} > 0 && ${tmp[6]} > 0) then set raster = (${tmp[2]} ${tmp[3]} ${tmp[4]} ${tmp[5]} ${tmp[6]}) endif endif # # # SEPARATION # # set tmp = `grep -i "^SEPARATION" ${outputroot}.sav` set separation = if (${#tmp} >= 3) then if (${tmp[2]} != '0.00' && ${tmp[3]} != '0.00') then if (${#tmp} >= 4) then set separation = (${tmp[2]} ${tmp[3]} ${tmp[4]}) else set separation = (${tmp[2]} ${tmp[3]}) endif endif endif # # # Save BEAM # BACKSTOP # SYMMETRY # MOSAIC # WAVELENGTH # DISTANCE # RASTER and # SEPARATION # # set symbols = (beamcenter 2 \ backstopcenter 2 \ backstopradius 1 \ space 1 \ mosaic 1 \ wavelength 1 \ distance 1 \ lowres 1 \ highres 1 \ raster 3 \ separation 3) # # source ${cmd}savesymbols # # endif # # interrupt: # # # Delete the GEN, SPT, COORDS, MOSFLM and .46 files # # rm -f ${outputroot}.gen rm -f ${outputroot}.spt rm -f ${outputroot}.coords rm -f ${tmpfile}.mosflm rm -f ${tmpfile}.limits rm -f fort.4*