Example #1
0
    def run(self):
      '''Run integrate.'''

      #image_header = self.get_header()

      ## crank through the header dictionary and replace incorrect
      ## information with updated values through the indexer
      ## interface if available...

      ## need to add distance, wavelength - that should be enough...

      #if self.get_distance():
        #image_header['distance'] = self.get_distance()

      #if self.get_wavelength():
        #image_header['wavelength'] = self.get_wavelength()

      #if self.get_two_theta():
        #image_header['two_theta'] = self.get_two_theta()

      header = imageset_to_xds(self.get_imageset())

      xds_inp = open(os.path.join(self.get_working_directory(),
                                  'XDS.INP'), 'w')

      # what are we doing?
      xds_inp.write('JOB=INTEGRATE\n')
      xds_inp.write('MAXIMUM_NUMBER_OF_PROCESSORS=%d\n' % \
                    self._parallel)

      from xia2.Handlers.Phil import PhilIndex
      xds_params = PhilIndex.params.xds
      if xds_params.profile_grid_size:
        ab, c = xds_params.profile_grid_size
        assert(ab > 0 and ab < 22 and (ab % 2) == 1)
        assert(c > 0 and c < 22 and (c % 2) == 1)
        xds_inp.write(
            'NUMBER_OF_PROFILE_GRID_POINTS_ALONG_ALPHA/BETA= %d\n' % ab)
        xds_inp.write(
            'NUMBER_OF_PROFILE_GRID_POINTS_ALONG_GAMMA= %d\n' % c)

      from libtbx import Auto
      mp_params = PhilIndex.params.xia2.settings.multiprocessing
      if mp_params.mode == 'serial' and mp_params.njob > 1:
        xds_inp.write('MAXIMUM_NUMBER_OF_JOBS=%d\n' %mp_params.njob)

      elif mp_params.mode == 'serial' and mp_params.njob == Auto:
        chunk_width = 30.0
        phi_width = self.get_phi_width()
        nchunks = int(
            (self._data_range[1] - self._data_range[0] + 1) * \
            phi_width / chunk_width)

        Debug.write('Xparallel: -1 using %d chunks' % nchunks)

        xds_inp.write('MAXIMUM_NUMBER_OF_JOBS=%d\n' % nchunks)

      profile_fitting = PhilIndex.params.xia2.settings.integration.profile_fitting
      if not profile_fitting:
        xds_inp.write('PROFILE_FITTING=FALSE\n')

      # write out lots of output
      xds_inp.write('TEST=2\n')

      if self._params.delphi:
        xds_inp.write('DELPHI=%.1f\n' % self._params.delphi)
      elif PhilIndex.params.xia2.settings.small_molecule == True:
        xds_inp.write('DELPHI=%.1f\n' % \
                      xds_params.delphi_small)
      else:
        xds_inp.write('DELPHI=%.1f\n' % \
                      xds_params.delphi)

      if self._refined_xparm:
        xds_inp.write('REFINE(INTEGRATE)=%s\n' %
                      ' '.join(self._params.refine_final))
      else:
        xds_inp.write('REFINE(INTEGRATE)=%s\n' %
                      ' '.join(self._params.refine))

      if self._params.fix_scale:
        if _running_xds_version() >= 20130330:
          xds_inp.write('DATA_RANGE_FIXED_SCALE_FACTOR= %d %d 1\n' %
                        self._data_range)
        else:
          xds_inp.write('FIXED_SCALE_FACTOR=TRUE\n')

      # check for updated input parameters or ones from phil

      if 'BEAM_DIVERGENCE' in self._updates and \
             'BEAM_DIVERGENCE_E.S.D.' in self._updates:
        xds_inp.write(
            'BEAM_DIVERGENCE=%f BEAM_DIVERGENCE_E.S.D.=%f\n' % \
            (self._updates['BEAM_DIVERGENCE'],
             self._updates['BEAM_DIVERGENCE_E.S.D.']))
      elif self._params.beam_divergence and self._params.beam_divergence_esd:
        xds_inp.write(
            'BEAM_DIVERGENCE=%f BEAM_DIVERGENCE_E.S.D.=%f\n' % \
            (self._params.beam_divergence,
             self._params.beam_divergence_esd))

      if 'REFLECTING_RANGE' in self._updates and \
             'REFLECTING_RANGE_E.S.D.' in self._updates:
        xds_inp.write(
            'REFLECTING_RANGE=%f REFLECTING_RANGE_E.S.D.=%f\n' % \
            (self._updates['REFLECTING_RANGE'],
             self._updates['REFLECTING_RANGE_E.S.D.']))
      elif self._params.reflecting_range and self._params.reflecting_range_esd:
        xds_inp.write(
            'REFLECTING_RANGE=%f REFLECTING_RANGE_E.S.D.=%f\n' % \
            (self._params.reflecting_range,
             self._params.reflecting_range_esd))

      for record in header:
        xds_inp.write('%s\n' % record)

      name_template = template_to_xds(
        os.path.join(self.get_directory(), self.get_template()))

      record = 'NAME_TEMPLATE_OF_DATA_FRAMES=%s\n' % \
               name_template

      xds_inp.write(record)

      xds_inp.write('DATA_RANGE=%d %d\n' % self._data_range)
      # xds_inp.write('MINIMUM_ZETA=0.1\n')

      xds_inp.close()

      # copy the input file...
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'XDS.INP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_INTEGRATE.INP' % self.get_xpid()))

      # write the input data files...

      for file_name in self._input_data_files_list:
        src = self._input_data_files[file_name]
        dst = os.path.join(
            self.get_working_directory(), file_name)
        if src != dst:
          shutil.copyfile(src, dst)

      self.start()
      self.close_wait()

      xds_check_version_supported(self.get_all_output())
      xds_check_error(self.get_all_output())

      # look for errors
      # like this perhaps - what the hell does this mean?
      #   !!! ERROR !!! "STRONGHKL": ASSERT VIOLATION

      # copy the LP file
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'INTEGRATE.LP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_INTEGRATE.LP' % self.get_xpid()))

      # gather the output files

      for file in self._output_data_files_list:
        self._output_data_files[file] = os.path.join(
          self.get_working_directory(), file)

      self._integrate_hkl = os.path.join(self.get_working_directory(),
                                         'INTEGRATE.HKL')

      # look through integrate.lp for some useful information
      # to help with the analysis

      space_group_number = 0

      mosaics = []

      for o in open(os.path.join(
          self.get_working_directory(),
          'INTEGRATE.LP')).readlines():
        if 'SPACE_GROUP_NUMBER' in o:
          space_group_number = int(o.split()[-1])
        if 'CRYSTAL MOSAICITY (DEGREES)' in o:
          mosaic = float(o.split()[-1])
          mosaics.append(mosaic)

      assert len(mosaics) > 0, "XDS refinement failed (no mosaic spread range reported)"
      self._min_mosaic = min(mosaics)
      self._max_mosaic = max(mosaics)
      self._mean_mosaic = sum(mosaics) / len(mosaics)

      Debug.write(
          'Mosaic spread range: %.3f %.3f %.3f' % \
          (self._min_mosaic, self._mean_mosaic, self._max_mosaic))

      stats = _parse_integrate_lp(os.path.join(
          self.get_working_directory(),
          'INTEGRATE.LP'))

      self._per_image_statistics = stats

      self._updates = _parse_integrate_lp_updates(os.path.join(
          self.get_working_directory(),
          'INTEGRATE.LP'))

      return
Example #2
0
    def run(self, ignore_errors = False):
      '''Run idxref.'''

      #image_header = self.get_header()

      ## crank through the header dictionary and replace incorrect
      ## information with updated values through the indexer
      ## interface if available...

      ## need to add distance, wavelength - that should be enough...

      #if self.get_distance():
        #image_header['distance'] = self.get_distance()

      #if self.get_wavelength():
        #image_header['wavelength'] = self.get_wavelength()

      #if self.get_two_theta():
        #image_header['two_theta'] = self.get_two_theta()

      header = imageset_to_xds(
        self.get_imageset(),
        refined_beam_vector=self._refined_beam_vector,
        refined_rotation_axis=self._refined_rotation_axis,
        refined_distance=self._refined_distance)

      xds_inp = open(os.path.join(self.get_working_directory(),
                                  'XDS.INP'), 'w')

      # what are we doing?
      xds_inp.write('JOB=IDXREF\n')
      xds_inp.write('MAXIMUM_NUMBER_OF_PROCESSORS=%d\n' % \
                    self._parallel)

      # FIXME this needs to be calculated from the beam centre...

      if self._refined_origin:
        xds_inp.write('ORGX=%f ORGY=%f\n' % \
                      tuple(self._refined_origin))
      else:
        xds_inp.write('ORGX=%f ORGY=%f\n' % \
                      tuple(self._org))

      # FIXME in here make sure sweep is wider than 5 degrees
      # before specifying AXIS: if <= 5 degrees replace AXIS with
      # nothing - base this on the maximum possible angular separation

      min_frame = self._spot_range[0][0]
      max_frame = self._spot_range[-1][1]

      refine_params = [p for p in self._params.refine]

      phi_width = self.get_phi_width()
      if ('AXIS' in refine_params
          and (max_frame - min_frame) * phi_width < 5.0):
        refine_params.remove('AXIS')

      xds_inp.write('REFINE(IDXREF)=%s\n' %
                    ' '.join(refine_params))

      if self._starting_frame and self._starting_angle:
        xds_inp.write('STARTING_FRAME=%d\n' % \
                      self._starting_frame)
        xds_inp.write('STARTING_ANGLE=%f\n' % \
                      self._starting_angle)

      # FIXME this looks like a potential bug - what will
      # happen if the input lattice has not been set??
      if self._indxr_input_cell:
        self._cell = self._indxr_input_cell
      if self._indxr_input_lattice:
        self._symm = lattice_to_spacegroup_number(
            self._indxr_input_lattice)

      if self._cell:
        xds_inp.write('SPACE_GROUP_NUMBER=%d\n' % self._symm)
        cell_format = '%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f'
        xds_inp.write('UNIT_CELL_CONSTANTS=%s\n' % \
                      cell_format % self._cell)


      if self._a_axis:
        xds_inp.write('UNIT_CELL_A-AXIS=%.2f %.2f %.2f\n' %
                      tuple(self._a_axis))

      if self._b_axis:
        xds_inp.write('UNIT_CELL_B-AXIS=%.2f %.2f %.2f\n' %
                      tuple(self._b_axis))

      if self._c_axis:
        xds_inp.write('UNIT_CELL_C-AXIS=%.2f %.2f %.2f\n' %
                      tuple(self._c_axis))

      for record in header:
        xds_inp.write('%s\n' % record)

      name_template = template_to_xds(
        os.path.join(self.get_directory(), self.get_template()))

      record = 'NAME_TEMPLATE_OF_DATA_FRAMES=%s\n' % \
               name_template

      xds_inp.write(record)

      xds_inp.write('DATA_RANGE=%d %d\n' % self._data_range)
      for spot_range in self._spot_range:
        xds_inp.write('SPOT_RANGE=%d %d\n' % spot_range)
      xds_inp.write('BACKGROUND_RANGE=%d %d\n' % \
                    self._background_range)

      xds_inp.close()

      # copy the input file...
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'XDS.INP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_IDXREF.INP' % self.get_xpid()))

      # write the input data files...
      for file_name in self._input_data_files_list:
        src = self._input_data_files[file_name]
        dst = os.path.join(
            self.get_working_directory(), file_name)
        if src != dst:
          shutil.copyfile(src, dst)

      self.start()
      self.close_wait()

      xds_check_version_supported(self.get_all_output())
      if not ignore_errors:
        xds_check_error(self.get_all_output())

      # If xds_check_error detects any errors it will raise an exception
      # The caller can then continue using the run_continue_from_error()
      # function. If XDS does not throw any errors we just plow on.

      return self.continue_from_error()
Example #3
0
    def run(self):
      '''Run defpix.'''

      #image_header = self.get_header()

      ## crank through the header dictionary and replace incorrect
      ## information with updated values through the indexer
      ## interface if available...

      ## need to add distance, wavelength - that should be enough...

      #if self.get_distance():
        #image_header['distance'] = self.get_distance()

      #if self.get_wavelength():
        #image_header['wavelength'] = self.get_wavelength()

      #if self.get_two_theta():
        #image_header['two_theta'] = self.get_two_theta()

      header = imageset_to_xds(self.get_imageset())

      xds_inp = open(os.path.join(self.get_working_directory(),
                                  'XDS.INP'), 'w')

      # what are we doing?
      xds_inp.write('JOB=DEFPIX\n')

      for record in header:
        xds_inp.write('%s\n' % record)

      name_template = template_to_xds(
        os.path.join(self.get_directory(), self.get_template()))

      record = 'NAME_TEMPLATE_OF_DATA_FRAMES=%s\n' % \
               name_template

      xds_inp.write(record)

      xds_inp.write('DATA_RANGE=%d %d\n' % self._data_range)

      # include the resolution range, perhaps
      if self._resolution_high > 0.0 or self._resolution_low > 0.0:
        xds_inp.write('INCLUDE_RESOLUTION_RANGE=%.2f %.2f\n' % \
                      (self._resolution_low, self._resolution_high))

      if self._value_range_for_trusted_detector_pixels is not None:
        xds_inp.write('VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=%i %i'
                      %self._value_range_for_trusted_detector_pixels)

      xds_inp.close()


      # copy the input file...
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'XDS.INP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_DEFPIX.INP' % self.get_xpid()))

      # write the input data files...

      for file_name in self._input_data_files_list:
        src = self._input_data_files[file_name]
        dst = os.path.join(
            self.get_working_directory(), file_name)
        if src != dst:
          shutil.copyfile(src, dst)

      self.start()
      self.close_wait()

      xds_check_version_supported(self.get_all_output())

      # copy the LP file
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'DEFPIX.LP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_DEFPIX.LP' % self.get_xpid()))

      # check the resolution asked for is achievable (if set)
      for record in open(os.path.join(self.get_working_directory(),
                                      'DEFPIX.LP')):
        if 'RESOLUTION RANGE RECORDED BY DETECTOR' in record:
          real_high = float(record.split()[-1])
          if self._resolution_high:
            if real_high > self._resolution_high + 0.01:
              Chatter.write(
                  'Warning: resolution limited to %.2f' % \
                  real_high)


      # gather the output files

      for file in self._output_data_files_list:
        self._output_data_files[file] = os.path.join(
          self.get_working_directory(), file)

      return
Example #4
0
File: XDSInit.py Project: xia2/xia2
    def run(self):
      '''Run init.'''

      #image_header = self.get_header()

      ## crank through the header dictionary and replace incorrect
      ## information with updated values through the indexer
      ## interface if available...

      ## need to add distance, wavelength - that should be enough...

      #if self.get_distance():
        #image_header['distance'] = self.get_distance()

      #if self.get_wavelength():
        #image_header['wavelength'] = self.get_wavelength()

      #if self.get_two_theta():
        #image_header['two_theta'] = self.get_two_theta()

      header = imageset_to_xds(self.get_imageset())

      xds_inp = open(os.path.join(self.get_working_directory(),
                                  'XDS.INP'), 'w')

      # what are we doing?
      xds_inp.write('JOB=INIT\n')

      for record in header:
        xds_inp.write('%s\n' % record)

      name_template = template_to_xds(
        os.path.join(self.get_directory(), self.get_template()))

      record = 'NAME_TEMPLATE_OF_DATA_FRAMES=%s\n' % \
               name_template

      xds_inp.write(record)

      xds_inp.write('DATA_RANGE=%d %d\n' % self._data_range)
      for spot_range in self._spot_range:
        xds_inp.write('SPOT_RANGE=%d %d\n' % spot_range)
      xds_inp.write('BACKGROUND_RANGE=%d %d\n' % \
                    self._background_range)

      if self._params.fix_scale:
        if _running_xds_version() >= 20130330:
          xds_inp.write('DATA_RANGE_FIXED_SCALE_FACTOR= %d %d 1\n' %
                        self._data_range)
        else:
          xds_inp.write('FIXED_SCALE_FACTOR=TRUE\n')

      xds_inp.close()

      # copy the input file...
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'XDS.INP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_INIT.INP' % self.get_xpid()))

      # write the input data files...

      for file_name in self._input_data_files_list:
        src = self._input_data_files[file_name]
        dst = os.path.join(
            self.get_working_directory(), file_name)
        if src != dst:
          shutil.copyfile(src, dst)

      self.start()
      self.close_wait()

      xds_check_version_supported(self.get_all_output())

      # check the job status here

      # copy the LP file
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'INIT.LP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_INIT.LP' % self.get_xpid()))

      # gather the output files

      for file in self._output_data_files_list:
        self._output_data_files[file] = os.path.join(
          self.get_working_directory(), file)

      return
Example #5
0
        def run(self):
            """Run correct."""

            # this is ok...
            # if not self._cell:
            # raise RuntimeError, 'cell not set'
            # if not self._spacegroup_number:
            # raise RuntimeError, 'spacegroup not set'

            # image_header = self.get_header()

            ## crank through the header dictionary and replace incorrect
            ## information with updated values through the indexer
            ## interface if available...

            ## need to add distance, wavelength - that should be enough...

            # if self.get_distance():
            # image_header['distance'] = self.get_distance()

            # if self.get_wavelength():
            # image_header['wavelength'] = self.get_wavelength()

            # if self.get_two_theta():
            # image_header['two_theta'] = self.get_two_theta()

            header = imageset_to_xds(self.get_imageset())

            xds_inp = open(os.path.join(self.get_working_directory(), "XDS.INP"), "w")

            # what are we doing?
            xds_inp.write("JOB=CORRECT\n")
            xds_inp.write("MAXIMUM_NUMBER_OF_PROCESSORS=%d\n" % self._parallel)

            # check to see if we are excluding ice rings
            if self._ice != 0:
                Debug.write("Excluding ice rings")

                for record in open(
                    os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "Data", "ice-rings.dat"))
                ).readlines():

                    resol = tuple(map(float, record.split()[:2]))

                    xds_inp.write("EXCLUDE_RESOLUTION_RANGE= %.2f %.2f\n" % resol)

            # exclude requested resolution ranges
            if self._excluded_regions:
                Debug.write("Excluding regions: %s" % ` self._excluded_regions `)

                for upper, lower in self._excluded_regions:
                    xds_inp.write("EXCLUDE_RESOLUTION_RANGE= %.2f %.2f\n" % (upper, lower))

            # postrefine everything to give better values to the
            # next INTEGRATE run
            xds_inp.write("REFINE(CORRECT)=%s\n" % " ".join(self._params.refine))

            if self._polarization > 0.0:
                xds_inp.write("FRACTION_OF_POLARIZATION=%.2f\n" % self._polarization)

            if self._params.air is not None:
                xds_inp.write("AIR=%f" % self._params.air)

            for record in header:
                xds_inp.write("%s\n" % record)

            name_template = template_to_xds(os.path.join(self.get_directory(), self.get_template()))

            record = "NAME_TEMPLATE_OF_DATA_FRAMES=%s\n" % name_template

            xds_inp.write(record)

            xds_inp.write("DATA_RANGE=%d %d\n" % self._data_range)
            # xds_inp.write('MINIMUM_ZETA=0.1\n')
            # include the resolution range, perhaps
            if self._resolution_high or self._resolution_low:
                xds_inp.write("INCLUDE_RESOLUTION_RANGE=%.2f %.2f\n" % (self._resolution_low, self._resolution_high))

            if self._anomalous:
                xds_inp.write("FRIEDEL'S_LAW=FALSE\n")
                xds_inp.write("STRICT_ABSORPTION_CORRECTION=TRUE\n")
            else:
                xds_inp.write("FRIEDEL'S_LAW=TRUE\n")

            if self._spacegroup_number:
                if not self._cell:
                    raise RuntimeError, "cannot set spacegroup without unit cell"

                xds_inp.write("SPACE_GROUP_NUMBER=%d\n" % self._spacegroup_number)
            if self._cell:
                xds_inp.write("UNIT_CELL_CONSTANTS=")
                xds_inp.write("%6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n" % tuple(self._cell))
            if self._reindex_matrix:
                xds_inp.write("REIDX=%d %d %d %d %d %d %d %d %d %d %d %d" % tuple(map(int, self._reindex_matrix)))

            xds_inp.close()

            # copy the input file...
            shutil.copyfile(
                os.path.join(self.get_working_directory(), "XDS.INP"),
                os.path.join(self.get_working_directory(), "%d_CORRECT.INP" % self.get_xpid()),
            )

            # write the input data files...

            for file_name in self._input_data_files_list:
                src = self._input_data_files[file_name]
                dst = os.path.join(self.get_working_directory(), file_name)
                if src != dst:
                    shutil.copyfile(src, dst)

            self.start()
            self.close_wait()

            xds_check_version_supported(self.get_all_output())
            xds_check_error(self.get_all_output())

            # look for errors
            # like this perhaps
            #   !!! ERROR !!! ILLEGAL SPACE GROUP NUMBER OR UNIT CELL

            # copy the LP file
            shutil.copyfile(
                os.path.join(self.get_working_directory(), "CORRECT.LP"),
                os.path.join(self.get_working_directory(), "%d_CORRECT.LP" % self.get_xpid()),
            )

            # gather the output files

            for file in self._output_data_files_list:
                self._output_data_files[file] = os.path.join(self.get_working_directory(), file)

            self._xds_ascii_hkl = os.path.join(self.get_working_directory(), "XDS_ASCII.HKL")

            # do some parsing of the correct output...

            self._results = _parse_correct_lp(os.path.join(self.get_working_directory(), "CORRECT.LP"))

            # check that the unit cell is comparable to what went in i.e.
            # the volume is the same to within a factor of 10 (which is
            # extremely generous and should only spot gross errors)

            original = unit_cell(self._cell)
            refined = unit_cell(self._results["cell"])

            if original.volume() / refined.volume() > 10:
                raise RuntimeError, "catastrophic change in unit cell volume"

            if refined.volume() / original.volume() > 10:
                raise RuntimeError, "catastrophic change in unit cell volume"

            # record reindex operation used for future reference... this
            # is to trap trac #419

            if "reindex_op" in self._results:
                format = "XDS applied reindex:" + 12 * " %d"
                Debug.write(format % tuple(self._results["reindex_op"]))
                self._reindex_used = self._results["reindex_op"]

            # get the reflections to remove...
            for line in open(os.path.join(self.get_working_directory(), "CORRECT.LP"), "r").readlines():
                if '"alien"' in line:
                    h, k, l = tuple(map(int, line.split()[:3]))
                    z = float(line.split()[4])
                    if not (h, k, l, z) in self._remove:
                        self._remove.append((h, k, l, z))

            return
Example #6
0
    def run(self):
      '''Run colspot.'''

      #image_header = self.get_header()

      ## crank through the header dictionary and replace incorrect
      ## information with updated values through the indexer
      ## interface if available...

      ## need to add distance, wavelength - that should be enough...

      #if self.get_distance():
        #image_header['distance'] = self.get_distance()

      #if self.get_wavelength():
        #image_header['wavelength'] = self.get_wavelength()

      #if self.get_two_theta():
        #image_header['two_theta'] = self.get_two_theta()

      header = imageset_to_xds(self.get_imageset())

      xds_inp = open(os.path.join(self.get_working_directory(),
                                  'XDS.INP'), 'w')

      # what are we doing?
      xds_inp.write('JOB=COLSPOT\n')
      xds_inp.write('MAXIMUM_NUMBER_OF_PROCESSORS=%d\n' % \
                    self._parallel)

      #if image_header['detector'] in ('pilatus', 'dectris'):
      if self.get_imageset().get_detector()[0].get_type() == 'SENSOR_PAD':
        xds_inp.write('MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=%d\n' %
                      self._params.minimum_pixels_per_spot)

      for record in header:
        xds_inp.write('%s\n' % record)

      name_template = template_to_xds(
        os.path.join(self.get_directory(), self.get_template()))

      record = 'NAME_TEMPLATE_OF_DATA_FRAMES=%s\n' % \
               name_template

      xds_inp.write(record)

      xds_inp.write('DATA_RANGE=%d %d\n' % self._data_range)
      for spot_range in self._spot_range:
        xds_inp.write('SPOT_RANGE=%d %d\n' % spot_range)
      xds_inp.write('BACKGROUND_RANGE=%d %d\n' % \
                    self._background_range)

      if PhilIndex.params.xia2.settings.small_molecule == True:
        xds_inp.write('STRONG_PIXEL=5\n')
        # FIXME should probably be moved to a phil parameter

      xds_inp.close()

      # copy the input file...
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'XDS.INP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_COLSPOT.INP' % self.get_xpid()))

      # write the input data files...

      for file_name in self._input_data_files_list:
        src = self._input_data_files[file_name]
        dst = os.path.join(
            self.get_working_directory(), file_name)
        if src != dst:
          shutil.copyfile(src, dst)

      self.start()
      self.close_wait()

      xds_check_version_supported(self.get_all_output())

      # copy the LP file
      shutil.copyfile(os.path.join(self.get_working_directory(),
                                   'COLSPOT.LP'),
                      os.path.join(self.get_working_directory(),
                                   '%d_COLSPOT.LP' % self.get_xpid()))

      # gather the output files

      for file in self._output_data_files_list:
        self._output_data_files[file] = os.path.join(
          self.get_working_directory(), file)

      return