<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.uni-konstanz.de/xds/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Olibclarke</id>
	<title>XDSwiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.uni-konstanz.de/xds/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Olibclarke"/>
	<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php/Special:Contributions/Olibclarke"/>
	<updated>2026-04-19T21:09:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2670</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2670"/>
		<updated>2012-10-20T14:23:39Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==Variant script (xds_generate_all)==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - values that may be useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Both these shell scripts can by installed system wide by transferring them to a directory in your path, for example the directory containing your XDS binaries.&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
# revision 0.27 Oliver Clarke 10/12 - xds_graph.sh will now run xdsstat, if available, and plot Rmeas and Rd per image.&lt;br /&gt;
# revision 0.28 Oliver Clarke 10/12 - xds_graph was not plotting h00, 0k0, 00l reflections when a reference dataset was present. Fixed.&lt;br /&gt;
REVISION=&amp;quot;0.28 (20-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
STARTING_ANGLE=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
  STARTING_ANGLE=`echo &amp;quot;scale=3; ($PHISTART/1000)&amp;quot; | bc -l` &lt;br /&gt;
                                                                                               &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      STARTING_ANGLE=`grep PHI tmp2 | sed s/PHI=//`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! Be warned that the starting spindle angles given by XPLAN are &lt;br /&gt;
! relative to the first image given - XDS assumes that the first image&lt;br /&gt;
! given has a phi of 0 unless explicitly told otherwise. If this is not &lt;br /&gt;
! the case (e.g. you are indexing from a snapshot taken at phi=90, &lt;br /&gt;
! you will need to add the actual phi (as reported in the image header) &lt;br /&gt;
! to the values given by XPLAN in order for these values to make sense. &lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
if command -v xdsstat &amp;gt;/dev/null; then&lt;br /&gt;
 echo \&amp;quot;\&amp;quot; | xdsstat &amp;gt; XDSSTAT.LP&lt;br /&gt;
 echo \&amp;quot;\&amp;quot; | xdsstat 100 6 &amp;gt; XDSSTAT.LP_low&lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rmeas vs image (to 6A):&lt;br /&gt;
 \\\$SCATTER:Rmeas vs image for low resolution reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RMEAS&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039; L\$&#039; XDSSTAT.LP_low | awk &#039;{print \$1,\$9}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rmeas vs image (all):&lt;br /&gt;
 \\\$SCATTER:Rmeas vs image (all reflections):A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RMEAS&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039; L$&#039; XDSSTAT.LP | awk &#039;{print \$1,\$9}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rd vs image (to 6A):&lt;br /&gt;
 \\\$SCATTER:Rd (from XDSSTAT) for low resolution reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RD&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039;DIFFERENCE&#039; XDSSTAT.LP_low | awk &#039;{print \$1,\$7}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rd vs image (all):&lt;br /&gt;
 \\\$SCATTER:Rd (from XDSSTAT) for all reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RD&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039;DIFFERENCE&#039; XDSSTAT.LP | awk &#039;{print \$1,\$7}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMP/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMP/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMP/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run.&lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     If XDSSTAT is present in your path, xds_graph will also plot some of the statistics it&lt;br /&gt;
     calculates - specifically the Rmeas and Rd per image, for all reflections and only&lt;br /&gt;
     low resolution reflections.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2669</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2669"/>
		<updated>2012-10-19T18:43:11Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: xds_graph.sh will now run xdsstat, if available, and display Rmeas and Rd per image.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==Variant script (xds_generate_all)==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - values that may be useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Both these shell scripts can by installed system wide by transferring them to a directory in your path, for example the directory containing your XDS binaries.&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
# revision 0.27 Oliver Clarke 10/12 - xds_graph.sh will now run xdsstat, if available, and plot Rmeas and Rd per image.&lt;br /&gt;
REVISION=&amp;quot;0.27 (19-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
STARTING_ANGLE=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
  STARTING_ANGLE=`echo &amp;quot;scale=3; ($PHISTART/1000)&amp;quot; | bc -l` &lt;br /&gt;
                                                                                               &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      STARTING_ANGLE=`grep PHI tmp2 | sed s/PHI=//`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! Be warned that the starting spindle angles given by XPLAN are &lt;br /&gt;
! relative to the first image given - XDS assumes that the first image&lt;br /&gt;
! given has a phi of 0 unless explicitly told otherwise. If this is not &lt;br /&gt;
! the case (e.g. you are indexing from a snapshot taken at phi=90, &lt;br /&gt;
! you will need to add the actual phi (as reported in the image header) &lt;br /&gt;
! to the values given by XPLAN in order for these values to make sense. &lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
if command -v xdsstat &amp;gt;/dev/null; then&lt;br /&gt;
 echo \&amp;quot;\&amp;quot; | xdsstat &amp;gt; XDSSTAT.LP&lt;br /&gt;
 echo \&amp;quot;\&amp;quot; | xdsstat 100 6 &amp;gt; XDSSTAT.LP_low&lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rmeas vs image (to 6A):&lt;br /&gt;
 \\\$SCATTER:Rmeas vs image for low resolution reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RMEAS&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039; L\$&#039; XDSSTAT.LP_low | awk &#039;{print \$1,\$9}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rmeas vs image (all):&lt;br /&gt;
 \\\$SCATTER:Rmeas vs image (all reflections):A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RMEAS&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039; L$&#039; XDSSTAT.LP | awk &#039;{print \$1,\$9}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rd vs image (to 6A):&lt;br /&gt;
 \\\$SCATTER:Rd (from XDSSTAT) for low resolution reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RD&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039;DIFFERENCE&#039; XDSSTAT.LP_low | awk &#039;{print \$1,\$7}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
 echo \&amp;quot;&lt;br /&gt;
 \\\$TABLE:Rd vs image (all):&lt;br /&gt;
 \\\$SCATTER:Rd (from XDSSTAT) for all reflections:A:1,2: \\$\\$&lt;br /&gt;
 IMAGE RD&lt;br /&gt;
 \\$\\$ \\$\\$&lt;br /&gt;
 \&amp;quot;&lt;br /&gt;
 grep &#039;DIFFERENCE&#039; XDSSTAT.LP | awk &#039;{print \$1,\$7}&#039;&lt;br /&gt;
 echo \&amp;quot; \\$\\$ \&amp;quot; &lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run.&lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     If XDSSTAT is present in your path, xds_graph will also plot some of the statistics it&lt;br /&gt;
     calculates - specifically the Rmeas and Rd per image, for all reflections and only&lt;br /&gt;
     low resolution reflections.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2668</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2668"/>
		<updated>2012-10-19T15:08:31Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==Variant script (xds_generate_all)==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - values that may be useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Both these shell scripts can by installed system wide by transferring them to a directory in your path, for example the directory containing your XDS binaries.&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
REVISION=&amp;quot;0.26 (18-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! Be warned that the starting spindle angles given by XPLAN are &lt;br /&gt;
! relative to the first image given - XDS assumes that the first image&lt;br /&gt;
! given has a phi of 0 unless explicitly told otherwise. If this is not &lt;br /&gt;
! the case (e.g. you are indexing from a snapshot taken at phi=90, &lt;br /&gt;
! you will need to add the actual phi (as reported in the image header) &lt;br /&gt;
! to the values given by XPLAN in order for these values to make sense. &lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run. &lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2667</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2667"/>
		<updated>2012-10-18T18:36:07Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==Variant script (xds_generate_all)==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
REVISION=&amp;quot;0.26 (18-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! Be warned that the starting spindle angles given by XPLAN are &lt;br /&gt;
! relative to the first image given - XDS assumes that the first image&lt;br /&gt;
! given has a phi of 0 unless explicitly told otherwise. If this is not &lt;br /&gt;
! the case (e.g. you are indexing from a snapshot taken at phi=90, &lt;br /&gt;
! you will need to add the actual phi (as reported in the image header) &lt;br /&gt;
! to the values given by XPLAN in order for these values to make sense. &lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run. &lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=DonelleMarshal174&amp;diff=2666</id>
		<title>DonelleMarshal174</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=DonelleMarshal174&amp;diff=2666"/>
		<updated>2012-10-18T17:05:35Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2665</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2665"/>
		<updated>2012-10-18T16:38:36Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: /* xds_generate_all: variant of Generate_XDS.INP including scripts for visualisation of statistics and conversion to MTZ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==Variant script (xds_generate_all)==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
REVISION=&amp;quot;0.26 (18-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run. &lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
	<entry>
		<id>https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2664</id>
		<title>Generate XDS.INP</title>
		<link rel="alternate" type="text/html" href="https://wiki.uni-konstanz.de/xds/index.php?title=Generate_XDS.INP&amp;diff=2664"/>
		<updated>2012-10-18T16:35:53Z</updated>

		<summary type="html">&lt;p&gt;Olibclarke: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC and Pilatus detectors; since this is just a bash script, extension to other detectors is very easy.&lt;br /&gt;
&lt;br /&gt;
On Mac OS X, installation of the &amp;quot;Command Line Tools&amp;quot; (from http://developer.apple.com/downloads; requires Apple ID) is required (I think). These are a part of the (larger, but also free) [http://developer.apple.com/tools/xcode Xcode] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Usage is just (don&#039;t forget the quotation marks!):&lt;br /&gt;
 generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
XDS [http://strucbio.biologie.uni-konstanz.de/~dikay/XDS_html_doc/html_doc/xds_parameters.html#NAME_TEMPLATE_OF_DATA_FRAMES= supports] bzip2-ed frames. Thus, when specifying the frame name parameter of the script, you should leave out any .bz2 extension.&lt;br /&gt;
&lt;br /&gt;
== The script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                   &lt;br /&gt;
# purpose: generate XDS.INP                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 . KD 7/2012 - Mac-compatibility: replace od flags --skip-bytes= and --read-bytes= with -j and -N (thanks to Oliver Clarke for working this out!)&lt;br /&gt;
REVISION=&amp;quot;0.26 (02-Jul-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this) &lt;br /&gt;
# - on Mac OS X, Xcode (from http://developer.apple.com/tools/xcode) might be needed - not sure about this                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: generate_XDS.INP \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX                                                                                                         &lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX                                                                                             &lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX                                                                                                           &lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be found in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then                                     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX                                               &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                        &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
&lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
&lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
! written by generate_XDS.INP version $REVISION&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv !&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                      &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing  &lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE                                                     &lt;br /&gt;
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! after CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step&lt;br /&gt;
! If the anom signal turns out to be, or is known to be, very low or absent,&lt;br /&gt;
! use FRIEDEL&#039;S_LAW=TRUE instead (or comment out the line); re-run CORRECT&lt;br /&gt;
&lt;br /&gt;
! remove the &amp;quot;!&amp;quot; in the following line:&lt;br /&gt;
! STRICT_ABSORPTION_CORRECTION=TRUE&lt;br /&gt;
! if the anomalous signal is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
! &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values are significantly&amp;gt; 1, e.g. 1.5&lt;br /&gt;
!&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
! UNTRUSTED_RECTANGLE= 1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
! UNTRUSTED_ELLIPSE= 2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
! UNTRUSTED_QUADRILATERAL= x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
!&lt;br /&gt;
! parameters with changes wrt default values:&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! partially use corners of detectors; 1.41421=full use&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! often 8000 is ok&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
! close spots: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3, e.g. to 4 and 2&lt;br /&gt;
! for bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line: &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
! parameters specifically for this detector and beamline:&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
ROTATION_AXIS=1 0 0  ! at e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
echo XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
echo Full documentation, including complete detector templates, is at&lt;br /&gt;
echo http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
echo After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
echo BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== System-wide or personal installation ==&lt;br /&gt;
&lt;br /&gt;
Ask your system adminstrator to cut-and-paste the script into e.g. /usr/local/bin/generate_XDS.INP, and to make it &amp;quot;executable&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
But you may also cut-and-paste the script from this webpage into a file in e.g. your home directory; the filename should be generate_XDS.INP. After creating the file, make it executable - e.g. if it&#039;s in your $HOME, use:&lt;br /&gt;
 chmod +x ~/generate_XDS.INP&lt;br /&gt;
After that, you can just run it in a similar way as if it were installed in your $PATH:&lt;br /&gt;
 ~/generate_XDS.INP &amp;quot;frms/mydata_1_???.img&amp;quot;&lt;br /&gt;
By using your own file, you can easily update to the latest revision, or even change the script, without having to bother the system administrator.&lt;br /&gt;
&lt;br /&gt;
== Generating generate_XDS.INP from this webpage ==&lt;br /&gt;
&lt;br /&gt;
Instead of cutting-and-pasting the lines of the script, you (or the system administrator) could just cut-and-paste the following four lines&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 wget http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP -O - | \&lt;br /&gt;
   sed -e s/\&amp;amp;nbsp\;/\ /g -e s/\&amp;amp;gt\;/\&amp;gt;/g -e s/\&amp;amp;lt\;/\&amp;lt;/g -e s/amp\;//g -e s/\&amp;amp;quot\;/\&amp;quot;/g -e s/\&amp;amp;\#\1\6\0\;/\ /g | \&lt;br /&gt;
   awk &#039;/^#/,/rm -f tmp1 tmp2/&#039; &amp;gt; generate_XDS.INP&lt;br /&gt;
 chmod +x generate_XDS.INP&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
to copy the script from this website into an executable file generate_XDS.INP in your current directory.&lt;br /&gt;
&lt;br /&gt;
==xds_generate_all: variant of Generate_XDS.INP including scripts for visualisation of statistics and conversion to MTZ==&lt;br /&gt;
This script includes some minor modifications of the Generate_XDS.INP script - for instance, it tells the user the energy, as well as the wavelength of the X-rays, and gives the user the beam center in mm as well as pixels - useful when switching between HKL2000, MOSFLM and XDS.&lt;br /&gt;
&lt;br /&gt;
It also generates two executable shell scripts in the same directory as XDS.INP.&lt;br /&gt;
&lt;br /&gt;
The first of these scripts, xds_graph.sh, extracts various statistics from INTEGRATE.LP and CORRECT.LP, pipes them out to a logfile, INTEGRATE_STATS.LP, and plots them using loggraph. This script does not have some of the more useful features of XDSSTAT, such as calculation of per frame Rmeas values, but it does give a quick overview of various data quality parameters by resolution and image number. This script will only work with recent versions of XDS (after calculation of CC(1/2) - not sure exactly which version).&lt;br /&gt;
&lt;br /&gt;
The second of these scripts, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate a CCP4-format MTZ file, containing anomalous data (as F(+)/F(-) and DANO/SigDANO) and a test set of 5% of reflections for calculation of the free R-factor. It will also generate an unmerged SHELX format HKL file, for input into SHELXC/D/E (e.g. via the HKL2MAP GUI).&lt;br /&gt;
&lt;br /&gt;
Here is the script:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash                                                                  &lt;br /&gt;
# purpose: xds_generate_all                                                   &lt;br /&gt;
#                                                                             &lt;br /&gt;
# tested with some datasets from ALS, SSRL, SLS, ESRF and BESSY; only MARCCD, ADSC/SMV, PILATUS detectors; &lt;br /&gt;
# for other detectors, values marked with XXX must be manually filled in.                                  &lt;br /&gt;
#                                                                                                          &lt;br /&gt;
# revision 0.03 . Kay Diederichs 2/2010                                                                    &lt;br /&gt;
# revision 0.04 . Kay Diederichs 4/2010 - include alternative ORGX, ORGY calculations for ADSC             &lt;br /&gt;
# revision 0.05 . Kay Diederichs 5/2010 - grep for &amp;quot;Corrected&amp;quot; in addition to &amp;quot;marccd&amp;quot;; needed for BESSY   &lt;br /&gt;
# revision 0.06 . KD 6/2010 - add UNTRUSTED_RECTANGLE and UNTRUSTED_ELLIPSE; use `whereis catmar` and so on &lt;br /&gt;
# revision 0.07 . KD 6/2010 - decide about ORGX/Y info in MAR header being pixels or mm; other fixes        &lt;br /&gt;
# revision 0.08 . KD 6/2010 - fixes for Pilatus 6M                                                          &lt;br /&gt;
# revision 0.09 . KD 6/2010 - get rid of requirement for mccd_xdsparams.pl and/or catmar; rather use &amp;quot;od&amp;quot;   &lt;br /&gt;
# revision 0.10 . Tim Gruene 7/2010 - set link &#039;images&#039; to image directory if path exceeds 72 characters    &lt;br /&gt;
# revision 0.11 . KD 7/2010 - for MarCCD: look for distance info at different byte position                 &lt;br /&gt;
# revision 0.12 . KD 7/2010 - fix for negative PHISTART                                                     &lt;br /&gt;
# revision 0.13 . KD 8/2010 - store correct NX NY QX QY in XDS.INP                                          &lt;br /&gt;
# revision 0.14 . KD 1/2011 - SENSOR_THICKNESS for Pilatus; MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3            &lt;br /&gt;
# revision 0.15 . KD 2/2011 - add comment for -ive sign of APS 19-ID and Australian Synchrotron rotation axis&lt;br /&gt;
# revision 0.16 . KD 3/2011 - SENSOR_THICKNESS=0.01 for ADSC and MarCCD. Add comment about SILICON=          &lt;br /&gt;
# revision 0.17 . KD 3/2011 - make it work for .bz2 frames; improve screen output                            &lt;br /&gt;
# revision 0.18 . KD 4/2011 - faster by doing &amp;quot;strings&amp;quot; only once; revert &amp;quot;images/${1##/*/}&amp;quot; &amp;quot;correction&amp;quot;    &lt;br /&gt;
# revision 0.19 . KD 6/2011 - bugfix for 0.18                                                                &lt;br /&gt;
# revision 0.20 . KD 7/2011 - redirect stderr of /bin/ls to /dev/null                                        &lt;br /&gt;
# revision 0.21 . KD 11/2011 - SEPMIN, CLUSTER_RADIUS hints; read NX NY from header (for Pilatus 2M)&lt;br /&gt;
# revision 0.22 . KD 12/2011 - Pilatus 2M UNTRUSTED_RECTANGLE lines, SENSOR_THICKNESS from header&lt;br /&gt;
# revision 0.23 . KD 1/2012 - add UNTRUSTED_QUADRILATERAL, remove MINIMUM_ZETA (0.05 is default now)&lt;br /&gt;
# revision 0.24 . KD 3/2012 - remove revision 0.10 since XDS now takes much longer paths&lt;br /&gt;
# revision 0.25 . KD 3/2012 - remove revision 0.22 for PSI Pilatus 2M; see http://www.globalphasing.com/autoproc/wiki/index.cgi?TroubleShootingKnownIssues&lt;br /&gt;
# revision 0.26 Oliver Clarke 10/12 - Added generation of shell scripts for conversion to MTZ and visualisation of statistics. Other minor alterations to XDS.INP.&lt;br /&gt;
REVISION=&amp;quot;0.26 (18-Oct-2012)&amp;quot;                                                                                &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# usage: e.g. xds_generate_all &amp;quot;frms/mydata_1_???.img&amp;quot;                                                       &lt;br /&gt;
# make sure to have the two quotation marks !                                                                &lt;br /&gt;
# the ? are wildcards for the frame numbers.                                                                 &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# limitations:                                                                                               &lt;br /&gt;
# - frame numbers are assumed to start with 1 and run consecutively                                          &lt;br /&gt;
#                                                                                                            &lt;br /&gt;
# known problems:                                                                                            &lt;br /&gt;
# - for ADSC detectors, there are at least three ways to obtain ORGX and ORGY values from the header (see below);&lt;br /&gt;
# - the same might be a problem for MAR headers, too (not sure about this)                                       &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# notes for debugging of the script:                                                                             &lt;br /&gt;
# - add the -v option to the first line, to see where an error occurs                                            &lt;br /&gt;
# - comment out the removal of tmp1 and tmp2 in the last line                                                    &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# ====== Start of script ======                                                                                  &lt;br /&gt;
echo generate_XDS.INP version $REVISION . Obtain the latest version from                                         &lt;br /&gt;
echo http://strucbio.biologie.uni-konstanz.de/xdswiki/index.php/generate_XDS.INP                                 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; == &amp;quot;help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-help&amp;quot; ] || [ &amp;quot;$1&amp;quot; == &amp;quot;-h&amp;quot; ]; then                                           &lt;br /&gt;
  echo usage: xds_generate_all \&amp;quot;frms/mydata_1_???.img\&amp;quot;   \(_with_ the quotation marks!\)                       &lt;br /&gt;
  echo if the frames are compressed with bzip2, leave out the .bz2 extension!                                    &lt;br /&gt;
  exit                                                                                                           &lt;br /&gt;
fi                                                                                                               &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
# defaults:                                                                                                      &lt;br /&gt;
#                                                                                                                &lt;br /&gt;
DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                                                        &lt;br /&gt;
ORGX=XXX                                                                                                         &lt;br /&gt;
ORGY=XXX&lt;br /&gt;
ORGXMM=XXX&lt;br /&gt;
ORGYMM=XXX&lt;br /&gt;
DETECTOR_DISTANCE=XXX                                                                                            &lt;br /&gt;
OSCILLATION_RANGE=XXX                                                                                            &lt;br /&gt;
X_RAY_WAVELENGTH=XXX &lt;br /&gt;
X_RAY_ENERGY=XXX&lt;br /&gt;
QX=XXX                                                                                                           &lt;br /&gt;
QY=XXX                                                                                                           &lt;br /&gt;
NX=XXX                                                                                                           &lt;br /&gt;
NY=XXX&lt;br /&gt;
NXMM=XXX&lt;br /&gt;
NYMM=XXX&lt;br /&gt;
SENSOR_THICKNESS=0                                                                                               &lt;br /&gt;
# see how we are called:                                                                                         &lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=&amp;quot;$1&amp;quot;&lt;br /&gt;
# list frames matching the wildcards in NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
# don&#039;t accept the &amp;quot;direct beam&amp;quot; shot at SLS/Pilatus PX-I and PX-II &lt;br /&gt;
/bin/ls -C1 $1 $1.bz2 2&amp;gt;/dev/null | egrep -v &amp;quot;_00000.cbf|_000.img&amp;quot; &amp;gt; tmp1 || exit 1&lt;br /&gt;
&lt;br /&gt;
# we can continue - the frames are found&lt;br /&gt;
&lt;br /&gt;
# set upper limit of DATA_RANGE to number of frames (see &amp;quot;limitations&amp;quot; above)&lt;br /&gt;
DATA_RANGE=`wc -l tmp1 | awk &#039;{print $1}&#039;`                                   &lt;br /&gt;
&lt;br /&gt;
# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1&lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;scale=0; $DATA_RANGE/2&amp;quot; | bc -l`                        &lt;br /&gt;
SPOT_RANGE=`echo &amp;quot;if ($SPOT_RANGE&amp;lt;1) 1;if ($SPOT_RANGE&amp;gt;1) $SPOT_RANGE&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
echo DATA_RANGE=1 $DATA_RANGE&lt;br /&gt;
&lt;br /&gt;
# find out detector type&lt;br /&gt;
DET=XXX                 &lt;br /&gt;
FIRSTFRAME=`head -1 tmp1`&lt;br /&gt;
echo $FIRSTFRAME | grep -q bz2 &amp;amp;&amp;amp; bzcat $FIRSTFRAME &amp;gt; tmp1 &amp;amp;&amp;amp; FIRSTFRAME=tmp1&lt;br /&gt;
strings $FIRSTFRAME &amp;gt; tmp2                                                   &lt;br /&gt;
egrep -q &#039;marccd|Corrected&#039; tmp2 &amp;amp;&amp;amp; DET=mccd                                 &lt;br /&gt;
grep -q PILATUS tmp2             &amp;amp;&amp;amp; DET=pilatus                              &lt;br /&gt;
grep -q BEAM_CENTER_X tmp2       &amp;amp;&amp;amp; DET=adsc                                 &lt;br /&gt;
# identify other detector types in the same way (MAR IP would be straightforward)&lt;br /&gt;
&lt;br /&gt;
# parse ASCII header of first frame&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;XXX&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;this is not a MAR, ADSC/SMV or PILATUS detector - fill in XXX values manually!&amp;quot;&lt;br /&gt;
  DETECTOR=&amp;quot;XXX MINIMUM_VALID_PIXEL_VALUE=XXX OVERLOAD=XXX&amp;quot;                            &lt;br /&gt;
&lt;br /&gt;
# find parameters of first frame&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;mccd&amp;quot; ]; then &lt;br /&gt;
  echo Data from a MarCCD detector&lt;br /&gt;
                                  &lt;br /&gt;
  DETECTOR=&amp;quot;CCDCHESS MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65500&amp;quot;&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                           &lt;br /&gt;
  # use first frame of dataset to obtain parameters               &lt;br /&gt;
&lt;br /&gt;
  # offsets are documented; values can be find in mccd_xdsparams.pl script&lt;br /&gt;
  let SKIP=1024+80                                                        &lt;br /&gt;
  NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=$SKIP+4                                                                         &lt;br /&gt;
  NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
&lt;br /&gt;
  let SKIP=1720&lt;br /&gt;
  DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  DETECTOR_DISTANCE=`echo &amp;quot;scale=3; $DETECTOR_DISTANCE/1000&amp;quot; | bc -l`                                     &lt;br /&gt;
                                                                                                          &lt;br /&gt;
  let SKIP=1024+256+128+256+4                                                                             &lt;br /&gt;
  ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGX=`echo &amp;quot;scale=2; $ORGX/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
  let SKIP=$SKIP+4                                                                                        &lt;br /&gt;
  ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)             &lt;br /&gt;
  ORGY=`echo &amp;quot;scale=2; $ORGY/1000&amp;quot; | bc -l `                                                              &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+44&lt;br /&gt;
  PHISTART=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  let SKIP=1024+256+128+256+76                                                                   &lt;br /&gt;
  PHIEND=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)  &lt;br /&gt;
  OSCILLATION_RANGE=`echo &amp;quot;scale=3; ($PHIEND-($PHISTART))/1000&amp;quot; | bc -l`                         &lt;br /&gt;
                                                                                                 &lt;br /&gt;
  let SKIP=1024+256+128+256+128+4                                                                &lt;br /&gt;
  QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QX=`echo &amp;quot;scale=10; $QX/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
  let SKIP=$SKIP+4                                                                               &lt;br /&gt;
  QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)      &lt;br /&gt;
  QY=`echo &amp;quot;scale=10; $QY/1000000&amp;quot; |bc -l `                                                      &lt;br /&gt;
&lt;br /&gt;
  let SKIP=1024+256+128+256+128+128+12&lt;br /&gt;
  X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk &#039;{print $2}&#039;)&lt;br /&gt;
  X_RAY_WAVELENGTH=`echo &amp;quot;scale=5; $X_RAY_WAVELENGTH/100000&amp;quot; | bc -l`                                    &lt;br /&gt;
  X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
# at most BLs, ORGX and ORGY are in pixels, but sometimes in mm ... guess:&lt;br /&gt;
  NXBYFOUR=`echo &amp;quot;scale=0; $NX/4&amp;quot; | bc -l `                               &lt;br /&gt;
  ORGXINT=`echo &amp;quot;scale=0; $ORGX/1&amp;quot; | bc -l `                              &lt;br /&gt;
  if [ $ORGXINT -lt $NXBYFOUR ]; then &lt;br /&gt;
     ORGXMM=$ORGX&lt;br /&gt;
     ORGYMM=$ORGY&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`     &lt;br /&gt;
     ORGX=`echo &amp;quot;scale=1; $ORGX/$QX&amp;quot; | bc -l`                             &lt;br /&gt;
     ORGY=`echo &amp;quot;scale=1; $ORGY/$QY&amp;quot; | bc -l`                             &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in mm ... converting to pixels&lt;br /&gt;
  else                                                                                &lt;br /&gt;
     ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
     NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`           &lt;br /&gt;
     echo MARCCD detector: header ORGX, ORGY seem to be in pixel units                &lt;br /&gt;
  fi                                                                                  &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;adsc&amp;quot; ]; then&lt;br /&gt;
&lt;br /&gt;
  DETECTOR=&amp;quot;ADSC MINIMUM_VALID_PIXEL_VALUE= 1 OVERLOAD= 65000&amp;quot;&lt;br /&gt;
  echo Data from ADSC detector. Obtaining ORGX, ORGY depends on beamline setup:&lt;br /&gt;
  SENSOR_THICKNESS=0.01                                                        &lt;br /&gt;
  sed s/\;// tmp2 &amp;gt; tmp1                                                       &lt;br /&gt;
  mv tmp1 tmp2                                                                 &lt;br /&gt;
&lt;br /&gt;
      # find X_RAY_WAVELENGTH:&lt;br /&gt;
      X_RAY_WAVELENGTH=`grep WAVELENGTH tmp2 | head -1 | sed s/WAVELENGTH=//`&lt;br /&gt;
&lt;br /&gt;
      # find NX, QX, ORGX and ORGY:&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NX=`grep SIZE1 tmp2 | tail -1 | sed s/SIZE1=//`&lt;br /&gt;
      QX=`grep PIXEL_SIZE tmp2 | sed s/PIXEL_SIZE=//`&lt;br /&gt;
# FIXME - next 2 lines should be done properly, from header&lt;br /&gt;
      NY=$NX                                               &lt;br /&gt;
      QY=$QX&lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      BEAM_CENTER_X=`grep BEAM_CENTER_X tmp2 | sed s/BEAM_CENTER_X=//`&lt;br /&gt;
      BEAM_CENTER_Y=`grep BEAM_CENTER_Y tmp2 | sed s/BEAM_CENTER_Y=//`&lt;br /&gt;
# fix 2010-04-26 - tell user about possible ORGX, ORGY alternatives -  &lt;br /&gt;
# at ESRF and ... (pls fill in!) the following should be used:         &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l`               &lt;br /&gt;
      echo - at ESRF BLs use: ORGX=$ORGX ORGY=$ORGY                    &lt;br /&gt;
# this 2nd alternative convention should be used at the following beamlines (pls complete the list): ALS 5.0.3, ...&lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                       &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $BEAM_CENTER_Y/$QX&amp;quot; | bc -l `                                                           &lt;br /&gt;
      echo - at e.g. ALS 5.0.3 use: ORGX=$ORGX ORGY=$ORGY                                                          &lt;br /&gt;
# this 3rd alternative convention should be used at the following beamlines (pls complete the list): ALS 8.2.2, ... &lt;br /&gt;
      ORGX=`echo &amp;quot;scale=1; $BEAM_CENTER_X/$QX&amp;quot; | bc -l `                                                            &lt;br /&gt;
      ORGY=`echo &amp;quot;scale=1; $NX-$BEAM_CENTER_Y/$QX&amp;quot; | bc -l ` &lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                                                       &lt;br /&gt;
      echo - at e.g. ALS 8.2.2 use: ORGX=$ORGX ORGY=$ORGY - this is written to XDS.INP                              &lt;br /&gt;
# the latter alternative is written into the generated XDS.INP ! You have to correct this manually in XDS.INP, or adjust this script.&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:                                                                                &lt;br /&gt;
      DETECTOR_DISTANCE=`grep DISTANCE tmp2 | sed s/DISTANCE=//`                                                                     &lt;br /&gt;
      OSCILLATION_RANGE=`grep OSC_RANGE tmp2 | sed s/OSC_RANGE=//`                                                                   &lt;br /&gt;
&lt;br /&gt;
elif [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  DETECTOR=&amp;quot;PILATUS MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= 1048576  !PILATUS&amp;quot;&lt;br /&gt;
  QX=0.172 QY=0.172                                                         &lt;br /&gt;
  echo Data from a Pilatus detector                                         &lt;br /&gt;
  sed s/#// tmp2 &amp;gt; tmp1                                                     &lt;br /&gt;
  mv tmp1 tmp2                                                              &lt;br /&gt;
&lt;br /&gt;
      # find SENSOR_THICKNESS:&lt;br /&gt;
      SENSOR_THICKNESS=`grep thickness tmp2 | sed -e s/&#039;Silicon sensor, thickness&#039;// | awk &#039;{print $1*1000}&#039;`&lt;br /&gt;
      # find X_RAY_WAVELENGTH:                                                                               &lt;br /&gt;
      X_RAY_WAVELENGTH=`grep Wavelength tmp2 | sed -e s/Wavelength// -e s/A// | awk &#039;{print $1}&#039;`            &lt;br /&gt;
&lt;br /&gt;
      X_RAY_ENERGY=`echo &amp;quot;12398.5/$X_RAY_WAVELENGTH&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%5.1f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find NX and NY; 2463/2527 is 6M, 1475/1679 is 2M&lt;br /&gt;
      NX=`grep X-Binary-Size-Fastest-Dimension tmp2 | awk &#039;{print $2}&#039;`&lt;br /&gt;
      NY=`grep X-Binary-Size-Second-Dimension tmp2 | awk &#039;{print $2}&#039;` &lt;br /&gt;
      NXMM=`echo &amp;quot;$NX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      NYMM=`echo &amp;quot;$NY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`                &lt;br /&gt;
      # find ORGX and ORGY:&lt;br /&gt;
      ORGX=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $2}&#039;`&lt;br /&gt;
      ORGY=`grep Beam_xy tmp2 | sed -e s/\(// -e s/\)// -e s/\,// | awk &#039;{print $3}&#039;`&lt;br /&gt;
      ORGXMM=`echo &amp;quot;$ORGX*$QX&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      ORGYMM=`echo &amp;quot;$ORGY*$QY&amp;quot; | bc -l | awk &#039;{printf &amp;quot;%3.2f&amp;quot;, $1}&#039;`&lt;br /&gt;
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:&lt;br /&gt;
      DETECTOR_DISTANCE=`awk &#039;/distance/{print $2}&#039; tmp2`&lt;br /&gt;
      DETECTOR_DISTANCE=`echo &amp;quot;$DETECTOR_DISTANCE*1000&amp;quot; | bc -l`&lt;br /&gt;
&lt;br /&gt;
      OSCILLATION_RANGE=`awk &#039;/Angle/{print $2}&#039; tmp2`&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
  echo should never come here&lt;br /&gt;
  exit 1                     &lt;br /&gt;
fi                           &lt;br /&gt;
&lt;br /&gt;
echo ORGX= $ORGX ORGY= $ORGY - check these values with adxv !&lt;br /&gt;
echo DETECTOR_DISTANCE= $DETECTOR_DISTANCE                   &lt;br /&gt;
echo OSCILLATION_RANGE= $OSCILLATION_RANGE                   &lt;br /&gt;
echo X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH                     &lt;br /&gt;
# now we know everything that is required to generate XDS.INP&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Written by generate_XDS.INP version $REVISION&lt;br /&gt;
!&lt;br /&gt;
! A few notes on usage and modification of this input file:&lt;br /&gt;
!&lt;br /&gt;
! If XDS fails after IDXREF with an error indicating that&lt;br /&gt;
! an insufficient percentage of reflections were indexed,&lt;br /&gt;
! but you are confident that the indexing solution is&lt;br /&gt;
! correct, rerun XDS with the JOB keyword changed to&lt;br /&gt;
! &amp;quot;DEFPIX INTEGRATE CORRECT&amp;quot;.&lt;br /&gt;
!&lt;br /&gt;
! After the first round of integration (in a triclinic cell)&lt;br /&gt;
! it is often helpful to reintegrate using the globally &lt;br /&gt;
! refined cell parameters and the correct space group.&lt;br /&gt;
! You can do this by renaming GXPARM.XDS to XPARM.XDS&lt;br /&gt;
! - e.g. by the command &amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot; -&lt;br /&gt;
! and rerunning DEFPIX, INTEGRATE and CORRECT.&lt;br /&gt;
!&lt;br /&gt;
! If you are trying to determine the optimal starting point for &lt;br /&gt;
! data collection starting from a single image, first complete&lt;br /&gt;
! a run of XDS using default parameters. Then, rerun XDS using&lt;br /&gt;
! the correct cell and spacegroup as described above &lt;br /&gt;
! (&amp;quot;cp GXPARM.XDS XPARM.XDS&amp;quot;), but on the second run of XDS, give&lt;br /&gt;
! the JOB keyword as &amp;quot;JOB=DEFPIX XPLAN&amp;quot;.&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!General parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
JOB= XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT&lt;br /&gt;
&lt;br /&gt;
ORGX= $ORGX ORGY= $ORGY  ! check these values with adxv!&lt;br /&gt;
!In mm, ORGX=$ORGXMM and ORGY=$ORGYMM&lt;br /&gt;
&lt;br /&gt;
DETECTOR_DISTANCE= $DETECTOR_DISTANCE                    &lt;br /&gt;
OSCILLATION_RANGE= $OSCILLATION_RANGE                    &lt;br /&gt;
&lt;br /&gt;
X-RAY_WAVELENGTH= $X_RAY_WAVELENGTH&lt;br /&gt;
!X-ray energy is $X_RAY_ENERGY eV (calculated from wavelength)                    &lt;br /&gt;
&lt;br /&gt;
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES&lt;br /&gt;
&lt;br /&gt;
!REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing.&lt;br /&gt;
!XDS will *only* use the reference dataset if the space group and cell&lt;br /&gt;
!parameters are specified below.  &lt;br /&gt;
&lt;br /&gt;
DATA_RANGE=1 $DATA_RANGE                                                     &lt;br /&gt;
SPOT_RANGE=1 $SPOT_RANGE&lt;br /&gt;
&lt;br /&gt;
!BACKGROUND_RANGE=1 10 !Default is first five degrees. &lt;br /&gt;
&lt;br /&gt;
SPACE_GROUP_NUMBER=0                   ! 0 if unknown&lt;br /&gt;
UNIT_CELL_CONSTANTS= 70 80 90 90 90 90 ! put correct values if known&lt;br /&gt;
&lt;br /&gt;
INCLUDE_RESOLUTION_RANGE=50 0  ! After CORRECT, insert high resol limit; re-run CORRECT&lt;br /&gt;
!                                Ice rings can be excluded from scaling with the keyword &lt;br /&gt;
!                                EXCLUDE_RESOLUTION_RANGE, e.g. EXCLUDE_RESOLUTION_RANGE=2.28 2.22&lt;br /&gt;
&lt;br /&gt;
!SECONDS=60 !Uncomment this line to tell XDS to wait 1min for the next image before aborting.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Parameters important for processing anomalous data:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE     ! This acts only on the CORRECT step. Even if the anomalous signal&lt;br /&gt;
!                         in your dataset is very small, it still may be useful for&lt;br /&gt;
!                         calculating an anomalous difference map.&lt;br /&gt;
&lt;br /&gt;
STRICT_ABSORPTION_CORRECTION=FALSE !Change this to TRUE if the anomalous signal &lt;br /&gt;
!                                   is strong: in that case, in CORRECT.LP the three&lt;br /&gt;
!                                   &amp;quot;CHI^2-VALUE OF FIT OF CORRECTION FACTORS&amp;quot; values &lt;br /&gt;
!                                   will be significantly&amp;gt; 1, e.g. 1.5.&lt;br /&gt;
&lt;br /&gt;
WFAC1=1.0 !This parameter controls rejection of misfits during scaling. Sometimes,&lt;br /&gt;
!          strong anomalous pairs may be rejected as misfits, in which case increasing&lt;br /&gt;
!          WFAC1 (e.g. to 1.5) may improve anomalous signal.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Regions of the detector to be excluded during indexing and integration:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! exclude (mask) untrusted areas of detector, e.g. beamstop shadow :&lt;br /&gt;
!UNTRUSTED_RECTANGLE= !1800 1950 2100 2150 ! x-min x-max y-min y-max ! repeat&lt;br /&gt;
!UNTRUSTED_ELLIPSE= !2034 2070 1850 2240 ! x-min x-max y-min y-max ! if needed&lt;br /&gt;
!UNTRUSTED_QUADRILATERAL= !x1 y1 x2 y2 x3 y3 x4 y4 ! see documentation&lt;br /&gt;
&lt;br /&gt;
TRUSTED_REGION=0.00 1.2  ! Partially use corners of detectors; 1.41421=full use, 1.0=edge&lt;br /&gt;
!                          It is important to note that TRUSTED_REGION is the only resolution &lt;br /&gt;
!                          cutoff obeyed during indexing and integration; &lt;br /&gt;
!                          Both INCLUDE_RESOLUTION_RANGE and EXCLUDE_RESOLUTION_RANGE are &lt;br /&gt;
!                          ignored during IDXREF and INTEGRATE. So this parameter can be &lt;br /&gt;
!                          important when indexing or integration steps fail.&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
!Other parameters:&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=7000. 30000. ! Often 8000 is ok.&lt;br /&gt;
STRONG_PIXEL=4           ! COLSPOT: only use strong reflections (default is 3; 6 may be better for strong data)&lt;br /&gt;
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high&lt;br /&gt;
MAXIMUM_ERROR_OF_SPOT_POSITION=3 ! Increasing may help for poor quality data&lt;br /&gt;
&lt;br /&gt;
MINPK=75 !Increase (e.g. MINPK=98) to improve data accuracy at the expense of completeness.&lt;br /&gt;
&lt;br /&gt;
DELPHI=5 !Size of integration wedge. Increasing to 10 or 20 may be helpful in some cases.&lt;br /&gt;
&lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA=13 ! Default is 9 - Increasing may improve data &lt;br /&gt;
NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA=13      ! accuracy, particularly if finely-sliced on phi, &lt;br /&gt;
!                                                   and does not seem to have any downsides. &lt;br /&gt;
&lt;br /&gt;
MINIMUM_ZETA=0.05 ! Controls how close to the blind region (about phi) reflections should be &lt;br /&gt;
!                   integrated. 0.05 is the default; increasing MINIMUM_ZETA to 0.15 *may* &lt;br /&gt;
!                   improve data quality by removing unreliable reflections near the phi &lt;br /&gt;
!                   axis, but will reduce completeness in low symmetry space groups.&lt;br /&gt;
&lt;br /&gt;
SEPMIN=6         ! Reduce if spots are close together (due to a long axis). Consider &lt;br /&gt;
CLUSTER_RADIUS=3 ! increasing if crystal is split and unit cell dimensions are relatively short.&lt;br /&gt;
&lt;br /&gt;
! For bad or low resolution data remove the &amp;quot;!&amp;quot; in the following line (default is ALL): &lt;br /&gt;
! REFINE(IDXREF)=CELL BEAM ORIENTATION AXIS ! DISTANCE&lt;br /&gt;
REFINE(INTEGRATE)=CELL BEAM ORIENTATION ! AXIS DISTANCE (If integration is unstable, comment out this line.&lt;br /&gt;
! REFINE(CORRECT)=CELL BEAM ORIENTATION AXIS DISTANCE ! Default is: refine everything&lt;br /&gt;
&lt;br /&gt;
ROTATION_AXIS=1 0 0  !At e.g. Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?) this needs to be -1 0 0&lt;br /&gt;
&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
! Parameters specifically for this detector and beamline (shouldn&#039;t need changing):&lt;br /&gt;
!****************************************************************************************&lt;br /&gt;
DETECTOR= $DETECTOR&lt;br /&gt;
SENSOR_THICKNESS= $SENSOR_THICKNESS&lt;br /&gt;
! attention CCD detectors: for very high resolution (better than 1A) make sure to specify SILICON&lt;br /&gt;
! as about 32* what CORRECT.LP suggests (absorption of phosphor is much higher than that of silicon)&lt;br /&gt;
&lt;br /&gt;
NX= $NX NY= $NY  QX= $QX  QY= $QY ! to make CORRECT happy if frames are unavailable&lt;br /&gt;
!In mm, NX=$NXMM and NY=$NYMM&lt;br /&gt;
&lt;br /&gt;
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0&lt;br /&gt;
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0&lt;br /&gt;
INCIDENT_BEAM_DIRECTION=0 0 1&lt;br /&gt;
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!&lt;br /&gt;
POLARIZATION_PLANE_NORMAL=0 1 0&lt;br /&gt;
eof&lt;br /&gt;
if [ &amp;quot;$DET&amp;quot; == &amp;quot;pilatus&amp;quot; ]; then&lt;br /&gt;
  if [ $NX == &amp;quot;1475&amp;quot; ]; then&lt;br /&gt;
    if ! grep -q FF_p2m0109_E12398_T6199_vrf_m0p20.tif tmp2 ; then&lt;br /&gt;
    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE= 486  496     0 1680&lt;br /&gt;
UNTRUSTED_RECTANGLE= 980  990     0 1680&lt;br /&gt;
!EXCLUSION OF HORIZONTAL DEAD AREAS OF THE PILATUS 2M DETECTOR&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   194  214&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   406  426&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   618  638&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476   830  850&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1042 1062&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1254 1274&lt;br /&gt;
UNTRUSTED_RECTANGLE=   0 1476  1466 1486&lt;br /&gt;
eof&lt;br /&gt;
    fi&lt;br /&gt;
#  elif [ $NX == &amp;quot;2463&amp;quot; ]; then&lt;br /&gt;
#    cat &amp;gt;&amp;gt; XDS.INP &amp;lt;&amp;lt; eof&lt;br /&gt;
#eof&lt;br /&gt;
  fi&lt;br /&gt;
fi&lt;br /&gt;
touch xds_to_ccp4.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Removes old log file if present&lt;br /&gt;
rm xds_to_ccp4.log&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch xds_to_ccp4.log&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 xds_to_ccp4.log &amp;amp;&lt;br /&gt;
exec &amp;gt; xds_to_ccp4.log 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If this message is all you see,&lt;br /&gt;
something has probably gone wrong.&lt;br /&gt;
Are you sure XDS_ASCII.HKL is present&lt;br /&gt;
in the current directory?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
#Make first MTZ file (with DANO/SIGDANO)&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp.hkl CCP4&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make second MTZ file (with F(+)/F(-))&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=temp2.hkl CCP4_F&lt;br /&gt;
MERGE=TRUE&lt;br /&gt;
GENERATE_FRACTION_OF_TEST_REFLECTIONS=0.05&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
f2mtz HKLOUT temp2.mtz&amp;lt;F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
#Make SHELX format unmerged hkl file&lt;br /&gt;
echo \&amp;quot;INPUT_FILE=XDS_ASCII.HKL&lt;br /&gt;
OUTPUT_FILE=xds_shelx.hkl SHELX&lt;br /&gt;
MERGE=FALSE&lt;br /&gt;
FRIEDEL&#039;S_LAW=FALSE\&amp;quot; &amp;gt; XDSCONV.INP&lt;br /&gt;
xdsconv&lt;br /&gt;
&lt;br /&gt;
#cad the two previously generated MTZ files together&lt;br /&gt;
cad HKLIN1 temp.mtz HKLIN2 temp2.mtz HKLOUT xds_ccp4_merged.mtz&amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABIN  FILE 1 E1=FP       E2=SIGFP       E3=DANO     E4=SIGDANO     E5=FreeRflag&lt;br /&gt;
 LABIN  FILE 2 E1=F(+)     E2=SIGF(+)     E3=F(-)     E4=SIGF(-)&lt;br /&gt;
 END&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
#Remove temporary files&lt;br /&gt;
rm temp.mtz&lt;br /&gt;
rm temp2.mtz&lt;br /&gt;
rm temp.hkl&lt;br /&gt;
rm temp2.hkl&lt;br /&gt;
rm F2MTZ.INP&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
********************************XDS_TO_CCP4**********************************&lt;br /&gt;
&lt;br /&gt;
This script takes XDS_ASCII.HKL and uses XDSCONV and F2MTZ to &lt;br /&gt;
generate a merged CCP4-format MTZ file named &lt;br /&gt;
\\\&amp;quot;xds_ccp4_merged.mtz\\\&amp;quot; with a test (free) set&lt;br /&gt;
labeled \\\&amp;quot;FreeRflag\\\&amp;quot; constituting 5% of reflections. &lt;br /&gt;
&lt;br /&gt;
The space group of the output MTZ file will be the same as&lt;br /&gt;
that present in XDS_ASCII.HKL. It is probably worth checking&lt;br /&gt;
that this is the correct space group - either manually inspect&lt;br /&gt;
the systematic absences in CORRECT.LP, or run XDS_ASCII.HKL&lt;br /&gt;
through the CCP4 program POINTLESS (\\\&amp;quot;pointless xdsin XDS_ASCII.HKL\\\&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Anomalous data is kept, if present, and output as both &lt;br /&gt;
DANO/SIGDANO and F(+)/F(-).&lt;br /&gt;
&lt;br /&gt;
This script also generates an unmerged SHELX hkl file,&lt;br /&gt;
suitable for input into SHELXC/D/E, named \\\&amp;quot;xds_shelx.hkl\\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A log of all processes is present in xds_to_ccp4.log.&lt;br /&gt;
&lt;br /&gt;
Parts of this script have been shamelessly copied from&lt;br /&gt;
the XDS Wiki, at http://www.strucbio.biologie.uni-konstanz.de/xdswiki/&lt;br /&gt;
&lt;br /&gt;
******************************************************************************&lt;br /&gt;
\&amp;quot;&amp;quot; &amp;gt; xds_to_ccp4.sh&lt;br /&gt;
touch xds_graph.sh&lt;br /&gt;
echo &amp;quot;#!/bin/bash&lt;br /&gt;
#Makes new log file&lt;br /&gt;
touch INTEGRATE_STATS.LP&lt;br /&gt;
#Pipe stdout and stderr to both logfile and tty&lt;br /&gt;
tail -f -n1 INTEGRATE_STATS.LP &amp;amp;&lt;br /&gt;
exec &amp;gt; INTEGRATE_STATS.LP 2&amp;gt;&amp;amp;1&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Integration Statistics :&lt;br /&gt;
\\\$SCATTER:Scale factors by image:A:1,3: :Number of overloads by image:A:1,5: :Number of strong reflections by image:A:1,7: :Number of rejects by image:A:1,8: :Mosaicity by image:A:1,10: \\$\\$&lt;br /&gt;
IMAGE IER SCALE NBKG NOVL NEWALD NSTRONG NREJ SIGMAB SIGMAR&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;[0-9]\.[0-9][0-9][0-9][0-9]  [0-9]\.[0-9][0-9][0-9][0-9]\&amp;quot; INTEGRATE.LP&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: XDS Scaling Statistics by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Chi-Squared by resolution:A:2,4: :Observed and expected R-factors by resolution (as %):A:2,5,6: :Rejects by resolution:A:2,9: :Rejects by resolution as a percentage of total reflections:A:2,10: \\$\\$&lt;br /&gt;
LOW_RES Resolution(Angstroems)  I/Sigma  Chi^2  R-FACTOR(OBSERVED)  R-FACTOR(EXPECTED)  NUMBER_OF_REFLECTIONS ACCEPTED REJECTS REJECT_PERCENT&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/RESOLUTION RANGE  I\/Sigma  Chi\^2  R\-FACTOR  R\-FACTOR  NUMBER ACCEPTED REJECTED/, /\-\-\-\-\-\-\-\-\-/&#039; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z,] | \-\-|\-99\.9\&amp;quot; | egrep \&amp;quot;[0-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$5,\$6,\$7,\$8,\$9,(\$9/(\$8+\$9))*100}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$\&amp;quot;&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: Overall data quality by Resolution (X-axis is resolution in Angstroems) :&lt;br /&gt;
\\\$GRAPHS:Completeness vs resolution :A:1,6: :Redundancy vs resolution :A:1,4: :I/Sigma by resolution:A:1,10: :Rmeas by resolution:A:1,11: :Anomalous correlation by resolution:A:1,13: :Significance of the anomalous signal by resolution:A:1,14:  \\$\\$&lt;br /&gt;
Resolution(Angstroems) OBSERVED_REFLECTIONS UNIQUE_REFLECTIONS REDUNDANCY POSSIBLE_REFLECTIONS COMPLETENESS R-FACTOR(OBSERVED) R-FACTOR(EXPECTED) COMPARED I/SIGMA R-meas CC(1/2) Anomalous_Correlation SigAno Nano&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep -B25 \&amp;quot; WILSON STATISTICS \&amp;quot; CORRECT.LP | egrep -v \&amp;quot;[a-z,A-Z]|\*\*\*\&amp;quot; | egrep \&amp;quot;  \&amp;quot; | awk &#039;{ gsub(/[%*]/,\&amp;quot; \&amp;quot;); print }&#039; | awk &#039;{print \$1,\$2,\$3,\$2/\$3,\$4,\$5,\$6,\$7,\$8,\$9,\$10,\$11,\$12,\$13,\$14}&#039;&lt;br /&gt;
echo \&amp;quot; \\$\\$ \&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of h00 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs h :A:1,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$1 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 0k0 reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs k :A:2,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$2 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE: I/Sigma of 00l reflections (for identification of systematic absences):&lt;br /&gt;
\\\$GRAPHS:I/Sigma vs l :A:3,5: \\$\\$&lt;br /&gt;
h k l RES I/SIGMA NUMBER&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
awk &#039;/REFLECTIONS OF TYPE H/,/COMPLETENESS AND QUALITY/&#039; CORRECT.LP | egrep \&amp;quot;[1-9]\&amp;quot; | awk &#039;{print \$1,\$2,\$3,\$4,\$7,\$8}&#039; | awk &#039;(\$3 &amp;gt; 0)&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Beam center (ORGX/ORGY) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:ORGX and ORGY vs batch (DELPHI) :A:1,2,3: \\$\\$&lt;br /&gt;
N ORGX ORGY&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR ORIGIN\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Unit cell parameters plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Unit cell lengths a, b and c plotted vs wedge:A:1,2,3,4: :Unit cell angles alpha, beta and gamma plotted vs wedge:A:1,5,6,7: \\$\\$&lt;br /&gt;
N a b c ALPHA BETA GAMMA&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;UNIT CELL PARAMETERS\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Standard deviation of spot position (pixels) plotted vs wedge:&lt;br /&gt;
\\\$GRAPHS:Standard deviation of spot position plotted vs wedge:A:1,2: \\$\\$&lt;br /&gt;
N SD&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;SPOT    POSITION\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;&lt;br /&gt;
\\\$TABLE:Detector distance (mm) plotted vs wedge (DELPHI):&lt;br /&gt;
\\\$GRAPHS:Detector distance plotted vs batch:A:1,2: \\$\\$&lt;br /&gt;
N DIST&lt;br /&gt;
\\$\\$ \\$\\$&lt;br /&gt;
\&amp;quot;&lt;br /&gt;
egrep \&amp;quot;DETECTOR DISTANCE \\(mm\\)\&amp;quot; INTEGRATE.LP | grep -n \&amp;quot;\&amp;quot; | awk &#039;{ gsub(/[a-z,A-Z,),(,:]/,\&amp;quot;\&amp;quot;); print }&#039;&lt;br /&gt;
&lt;br /&gt;
echo \&amp;quot;\\$\\$\&amp;quot;&lt;br /&gt;
&lt;br /&gt;
loggraph INTEGRATE_STATS.LP&amp;quot;&amp;gt;xds_graph.sh&lt;br /&gt;
chmod +x xds_to_ccp4.sh&lt;br /&gt;
chmod +x xds_graph.sh&lt;br /&gt;
echo &amp;quot;XDS.INP is ready for use. The file has only the most important keywords.&lt;br /&gt;
     Full documentation, including complete detector templates, is at&lt;br /&gt;
     http://www.mpimf-heidelberg.mpg.de/~kabsch/xds . More documentation in XDSwiki&lt;br /&gt;
     After running xds, inspect, using XDS-Viewer, at least the beamstop mask in&lt;br /&gt;
     BKGPIX.cbf, and the agreement of predicted and observed spots in FRAME.cbf!&lt;br /&gt;
&lt;br /&gt;
     Two shell scripts have been generated that may be of use. &lt;br /&gt;
&lt;br /&gt;
     The first, xds_graph.sh, will plot various statistics after an XDS run. &lt;br /&gt;
     After both INTEGRATE and CORRECT have finished, run it by typing \&amp;quot;./xds_graph.sh\&amp;quot; &lt;br /&gt;
     without the quotation marks. This script uses loggraph to plot data, so you will&lt;br /&gt;
     need CCP4 to see the graphical output. All the raw data is piped out to a log file,&lt;br /&gt;
     INTEGRATE_STATS.LP.&lt;br /&gt;
&lt;br /&gt;
     The second script, xds_to_ccp4.sh, will take XDS_ASCII.HKL and generate both a CCP4&lt;br /&gt;
     format MTZ file with anomalous data retained (as F(+)/F(-) and DANO/SigDANO)&lt;br /&gt;
     and an unmerged SHELX format hkl file for input to SHELXC/D/E. Run it after CORRECT&lt;br /&gt;
     by typing \&amp;quot;./xds_to_ccp4.sh\&amp;quot; at the prompt.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
rm -f tmp1 tmp2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use this script in the same manner as Generate_XDS.INP. The two shell scripts created should be executable; If they are not, then make them so (chmod +x ./xxx.sh).&lt;/div&gt;</summary>
		<author><name>Olibclarke</name></author>
	</entry>
</feed>