Generate XDS.INP: Difference between revisions

no edit summary
(bugfix)
No edit summary
Line 1: Line 1:
This script should be in your $PATH as "generate_XDS.INP" . As the name suggests, it generates XDS.INP based on a list of frame names supplied on the commandline.
This script should be in your $PATH as "generate_XDS.INP" . As the name suggests, it generates XDS.INP based on a list of frame names supplied on the commandline.
Currently works for MarCCD, ADSC and Pilatus 6M detectors.
Currently works for MarCCD, ADSC and Pilatus 6M detectors. Also supports bzip2-ed frames (leave out the .bz2 extension, as [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= documented] for XDS!).


<pre>
<pre>
Line 23: Line 23:
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=
REVISION=0.16
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output
REVISION=0.17
#
#
# usage: e.g. generate_XDS.INP "frms/mydata_1_???.img"
# usage: e.g. generate_XDS.INP "frms/mydata_1_???.img"
Line 41: Line 42:
#
#
# ====== Start of script ======
# ====== Start of script ======
echo generate_XDS.INP version $REVISION . Latest version at http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP
echo generate_XDS.INP version $REVISION . Obtain the latest version from
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP
if [ "$1" == "help" ] || [ "$1" == "-help" ] || [ "$1" == "-h" ]; then
if [ "$1" == "help" ] || [ "$1" == "-help" ] || [ "$1" == "-h" ]; then
   echo usage: generate_XDS.INP \"frms/mydata_1_???.img\"  \(_with_ the quotation marks!\)
   echo usage: generate_XDS.INP \"frms/mydata_1_???.img\"  \(_with_ the quotation marks!\)
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!
   exit
   exit
fi
fi
Line 66: Line 69:
# and set a link if necessary
# and set a link if necessary
if [ ${#1} -gt 72 ]; then
if [ ${#1} -gt 72 ]; then
     TMP_PATH=$(/bin/ls -C1 $1 | head -1)
     TMP_PATH=$(/bin/ls -C1 $1 $1.bz2 | head -1)
     TMP_FILENAME=$(basename ${TMP_PATH})
     TMP_FILENAME=$(basename ${TMP_PATH})
     if [ ${#TMP_FILENAME} -gt 65 ]; then
     if [ ${#TMP_FILENAME} -gt 65 ]; then
Line 85: Line 88:
    ln -s ${TMP_DIRNAME} images
    ln -s ${TMP_DIRNAME} images
fi
fi
NAME_TEMPLATE_OF_DATA_FRAMES="images/${1##/*/}"
# NAME_TEMPLATE_OF_DATA_FRAMES="images/${1##/*/}"
# KD 30.3.11 previous line changed to:
      NAME_TEMPLATE_OF_DATA_FRAMES="images/${TMP_FILENAME}"  
echo "              Using template filename \"${NAME_TEMPLATE_OF_DATA_FRAMES}\""
echo "              Using template filename \"${NAME_TEMPLATE_OF_DATA_FRAMES}\""
     fi
     fi
Line 92: Line 97:
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES
# don't accept the "direct beam" shot at SLS/Pilatus PX-I and PX-II
# don't accept the "direct beam" shot at SLS/Pilatus PX-I and PX-II
/bin/ls -C1 $1 | egrep -v "_00000.cbf|_000.img" > tmp1 || exit 1
/bin/ls -C1 $1 $1.bz2 | egrep -v "_00000.cbf|_000.img" > tmp1 || exit 1


# we can continue - the frames are found
# we can continue - the frames are found
echo Full documentation, including complete detector templates and XDS binaries, can be found at
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation: see XDSwiki


# set upper limit of DATA_RANGE to number of frames (see "limitations" above)
# set upper limit of DATA_RANGE to number of frames (see "limitations" above)
Line 109: Line 112:
# find out detector type
# find out detector type
DET=XXX
DET=XXX
strings `head -1 tmp1` | egrep -q 'marccd|Corrected' && DET=mccd
FIRSTFRAME=`head -1 tmp1`
strings `head -1 tmp1` | grep -q PILATUS            && DET=pilatus
echo $FIRSTFRAME | grep -q bz2 && bzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
strings `head -1 tmp1` | grep -q BEAM_CENTER_X      && DET=adsc
strings $FIRSTFRAME | egrep -q 'marccd|Corrected' && DET=mccd
strings $FIRSTFRAME | grep -q PILATUS            && DET=pilatus
strings $FIRSTFRAME | grep -q BEAM_CENTER_X      && DET=adsc
# identify other detector types in the same way (MAR IP would be straightforward)
# identify other detector types in the same way (MAR IP would be straightforward)


Line 122: Line 127:
# find parameters of first frame
# find parameters of first frame
elif [ "$DET" == "mccd" ]; then
elif [ "$DET" == "mccd" ]; then
 
  echo Data from a MarCCD detector
 
   DETECTOR="CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500"
   DETECTOR="CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500"
   SENSOR_THICKNESS=0.01
   SENSOR_THICKNESS=0.01
   # use first frame of dataset to obtain parameters
   # use first frame of dataset to obtain parameters
  MARFRAME=`head -1 tmp1`


   # offsets are documented; values can be find in mccd_xdsparams.pl script
   # offsets are documented; values can be find in mccd_xdsparams.pl script
   let SKIP=1024+80
   let SKIP=1024+80
   NX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   NX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   let SKIP=$SKIP+4
   let SKIP=$SKIP+4
   NY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   NY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')


   let SKIP=1720
   let SKIP=1720
   DETECTOR_DISTANCE=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   DETECTOR_DISTANCE=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   DETECTOR_DISTANCE=`echo "scale=3; $DETECTOR_DISTANCE/1000" | bc -l`
   DETECTOR_DISTANCE=`echo "scale=3; $DETECTOR_DISTANCE/1000" | bc -l`
      
      
   let SKIP=1024+256+128+256+4
   let SKIP=1024+256+128+256+4
   ORGX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   ORGX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   ORGX=`echo "scale=2; $ORGX/1000" | bc -l `
   ORGX=`echo "scale=2; $ORGX/1000" | bc -l `
   let SKIP=$SKIP+4
   let SKIP=$SKIP+4
   ORGY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   ORGY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   ORGY=`echo "scale=2; $ORGY/1000" | bc -l `
   ORGY=`echo "scale=2; $ORGY/1000" | bc -l `


   let SKIP=1024+256+128+256+44
   let SKIP=1024+256+128+256+44
   PHISTART=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   PHISTART=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   let SKIP=1024+256+128+256+76
   let SKIP=1024+256+128+256+76
   PHIEND=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   PHIEND=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   OSCILLATION_RANGE=`echo "scale=3; ($PHIEND-($PHISTART))/1000" | bc -l`
   OSCILLATION_RANGE=`echo "scale=3; ($PHIEND-($PHISTART))/1000" | bc -l`
    
    
   let SKIP=1024+256+128+256+128+4
   let SKIP=1024+256+128+256+128+4
   QX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   QX=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   QX=`echo "scale=10; $QX/1000000" |bc -l `
   QX=`echo "scale=10; $QX/1000000" |bc -l `
   let SKIP=$SKIP+4
   let SKIP=$SKIP+4
   QY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   QY=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   QY=`echo "scale=10; $QY/1000000" |bc -l `
   QY=`echo "scale=10; $QY/1000000" |bc -l `


   let SKIP=1024+256+128+256+128+128+12
   let SKIP=1024+256+128+256+128+128+12
   X_RAY_WAVELENGTH=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $MARFRAME | head -1 | awk '{print $2}')
   X_RAY_WAVELENGTH=$(od -t dI --skip-bytes=$SKIP --read-bytes=4 $FIRSTFRAME | head -1 | awk '{print $2}')
   X_RAY_WAVELENGTH=`echo "scale=5; $X_RAY_WAVELENGTH/100000" | bc -l`
   X_RAY_WAVELENGTH=`echo "scale=5; $X_RAY_WAVELENGTH/100000" | bc -l`


Line 176: Line 181:


   DETECTOR="ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000"
   DETECTOR="ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000"
   echo this is an ADSC detector. Obtaining ORGX, ORGY from the header depends on beamline setup.
   echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:
   SENSOR_THICKNESS=0.01
   SENSOR_THICKNESS=0.01
   strings `head -1 tmp1` | sed s/\;// > tmp2
   strings $FIRSTFRAME | sed s/\;// > tmp2


       # find X_RAY_WAVELENGTH:
       # find X_RAY_WAVELENGTH:
Line 195: Line 200:
       ORGX=`echo "scale=1; $BEAM_CENTER_Y/$QX" | bc -l `
       ORGX=`echo "scale=1; $BEAM_CENTER_Y/$QX" | bc -l `
       ORGY=`echo "scale=1; $BEAM_CENTER_X/$QX" | bc -l `
       ORGY=`echo "scale=1; $BEAM_CENTER_X/$QX" | bc -l `
       echo ATTENTION: at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY  
       echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY  
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...
       ORGX=`echo "scale=1; $NX-$BEAM_CENTER_X/$QX" | bc -l `
       ORGX=`echo "scale=1; $NX-$BEAM_CENTER_X/$QX" | bc -l `
       ORGY=`echo "scale=1; $BEAM_CENTER_Y/$QX" | bc -l `
       ORGY=`echo "scale=1; $BEAM_CENTER_Y/$QX" | bc -l `
       echo ATTENTION: at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY  
       echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY  
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ...  
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ...  
       ORGX=`echo "scale=1; $BEAM_CENTER_X/$QX" | bc -l `
       ORGX=`echo "scale=1; $BEAM_CENTER_X/$QX" | bc -l `
       ORGY=`echo "scale=1; $NX-$BEAM_CENTER_Y/$QX" | bc -l `
       ORGY=`echo "scale=1; $NX-$BEAM_CENTER_Y/$QX" | bc -l `
       echo ATTENTION: at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is now written to XDS.INP
       echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.
       # find DETECTOR_DISTANCE and OSCILLATION_RANGE:
       # find DETECTOR_DISTANCE and OSCILLATION_RANGE:
Line 213: Line 218:
   SENSOR_THICKNESS=0.32
   SENSOR_THICKNESS=0.32
   NX=2463 NY=2527 QX=0.172 QY=0.172
   NX=2463 NY=2527 QX=0.172 QY=0.172
   echo this is a Pilatus detector
   echo Data from a Pilatus detector
   head -50 `head -1 tmp1` | sed s/#//> tmp2
   head -50 $FIRSTFRAME | sed s/#//> tmp2


       # find X_RAY_WAVELENGTH:
       # find X_RAY_WAVELENGTH:
Line 256: Line 261:
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT


FRIEDEL'S_LAW=FALSE    ! This acts only on the CORRECT step
FRIEDEL'S_LAW=FALSE    ! This acts only on the CORRECT step
Line 293: Line 297:
eof
eof
echo XDS.INP is ready for use. The file has only the most important keywords.
echo XDS.INP is ready for use. The file has only the most important keywords.
echo After running xds, inspect at least BKGPIX.cbf and FRAME.cbf with XDS-Viewer!
echo Full documentation, including complete detector templates, is at
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!
rm -f tmp1 tmp2  
rm -f tmp1 tmp2  
</pre>
</pre>
2,652

edits