Example #1
0
    def _integrate_finish(self):
        '''Finish off the integration by running dials.export.'''

        # FIXME - do we want to export every time we call this method
        # (the file will not have changed) and also (more important) do
        # we want a different exported MTZ file every time (I do not think
        # that we do; these can be very large) - was exporter.get_xpid() ->
        # now dials

        exporter = self.ExportMtz()
        exporter.set_reflections_filename(self._intgr_integrated_pickle)
        mtz_filename = os.path.join(self.get_working_directory(),
                                    '%s_integrated.mtz' % 'dials')
        exporter.set_mtz_filename(mtz_filename)
        exporter.run()
        self._intgr_integrated_filename = mtz_filename

        # record integrated MTZ file for e.g. BLEND.

        pname, xname, dname = self.get_integrater_project_info()
        sweep = self.get_integrater_sweep_name()
        FileHandler.record_more_data_file(
            '%s %s %s %s INTEGRATE' % (pname, xname, dname, sweep),
            mtz_filename)

        from iotbx.reflection_file_reader import any_reflection_file
        miller_arrays = any_reflection_file(
            self._intgr_integrated_filename).as_miller_arrays()
        # look for profile-fitted intensities
        intensities = [
            ma for ma in miller_arrays
            if ma.info().labels == ['IPR', 'SIGIPR']
        ]
        if len(intensities) == 0:
            # look instead for summation-integrated intensities
            intensities = [
                ma for ma in miller_arrays
                if ma.info().labels == ['I', 'SIGI']
            ]
            assert len(intensities)
        self._intgr_n_ref = intensities[0].size()

        if not os.path.isfile(self._intgr_integrated_filename):
            raise RuntimeError("dials.export failed: %s does not exist." %
                               self._intgr_integrated_filename)

        if self._intgr_reindex_operator is None and \
          self._intgr_spacegroup_number == lattice_to_spacegroup(
            self.get_integrater_refiner().get_refiner_lattice()):
            Debug.write('Not reindexing to spacegroup %d (%s)' % \
                          (self._intgr_spacegroup_number,
                           self._intgr_reindex_operator))
            return mtz_filename

        if self._intgr_reindex_operator is None and \
          self._intgr_spacegroup_number == 0:
            Debug.write('Not reindexing to spacegroup %d (%s)' % \
                          (self._intgr_spacegroup_number,
                           self._intgr_reindex_operator))
            return mtz_filename

        Debug.write('Reindexing to spacegroup %d (%s)' % \
                    (self._intgr_spacegroup_number,
                     self._intgr_reindex_operator))

        hklin = mtz_filename
        reindex = Reindex()
        reindex.set_working_directory(self.get_working_directory())
        auto_logfiler(reindex)

        reindex.set_operator(self._intgr_reindex_operator)

        if self._intgr_spacegroup_number:
            reindex.set_spacegroup(self._intgr_spacegroup_number)
        else:
            reindex.set_spacegroup(
                lattice_to_spacegroup(
                    self.get_integrater_refiner().get_refiner_lattice()))

        hklout = '%s_reindex.mtz' % hklin[:-4]
        reindex.set_hklin(hklin)
        reindex.set_hklout(hklout)
        reindex.reindex()
        self._intgr_integrated_filename = hklout
        self._intgr_cell = reindex.get_cell()

        pname, xname, dname = self.get_integrater_project_info()
        sweep = self.get_integrater_sweep_name()
        FileHandler.record_more_data_file(
            '%s %s %s %s experiments' % (pname, xname, dname, sweep),
            self.get_integrated_experiments())

        return hklout
Example #2
0
  def _integrate_finish(self):
    '''Finish off the integration by running dials.export.'''

    # FIXME - do we want to export every time we call this method
    # (the file will not have changed) and also (more important) do
    # we want a different exported MTZ file every time (I do not think
    # that we do; these can be very large) - was exporter.get_xpid() ->
    # now dials

    exporter = self.ExportMtz()
    exporter.set_reflections_filename(self._intgr_integrated_pickle)
    mtz_filename = os.path.join(
      self.get_working_directory(), '%s_integrated.mtz' % 'dials')
    exporter.set_mtz_filename(mtz_filename)
    exporter.run()
    self._intgr_integrated_filename = mtz_filename

    # record integrated MTZ file for e.g. BLEND.

    pname, xname, dname = self.get_integrater_project_info()
    sweep = self.get_integrater_sweep_name()
    FileHandler.record_more_data_file(
        '%s %s %s %s INTEGRATE' % (pname, xname, dname, sweep), mtz_filename)

    if not os.path.isfile(self._intgr_integrated_filename):
      raise RuntimeError("dials.export failed: %s does not exist."
                         % self._intgr_integrated_filename)

    if self._intgr_reindex_operator is None and \
      self._intgr_spacegroup_number == lattice_to_spacegroup(
        self.get_integrater_refiner().get_refiner_lattice()):
      Debug.write('Not reindexing to spacegroup %d (%s)' % \
                    (self._intgr_spacegroup_number,
                     self._intgr_reindex_operator))
      return mtz_filename

    if self._intgr_reindex_operator is None and \
      self._intgr_spacegroup_number == 0:
      Debug.write('Not reindexing to spacegroup %d (%s)' % \
                    (self._intgr_spacegroup_number,
                     self._intgr_reindex_operator))
      return mtz_filename

    Debug.write('Reindexing to spacegroup %d (%s)' % \
                (self._intgr_spacegroup_number,
                 self._intgr_reindex_operator))

    hklin = mtz_filename
    reindex = Reindex()
    reindex.set_working_directory(self.get_working_directory())
    auto_logfiler(reindex)

    reindex.set_operator(self._intgr_reindex_operator)

    if self._intgr_spacegroup_number:
      reindex.set_spacegroup(self._intgr_spacegroup_number)
    else:
      reindex.set_spacegroup(lattice_to_spacegroup(
        self.get_integrater_refiner().get_refiner_lattice()))

    hklout = '%s_reindex.mtz' % hklin[:-4]
    reindex.set_hklin(hklin)
    reindex.set_hklout(hklout)
    reindex.reindex()
    self._intgr_integrated_filename = hklout
    self._intgr_cell = reindex.get_cell()

    pname, xname, dname = self.get_integrater_project_info()
    sweep = self.get_integrater_sweep_name()
    FileHandler.record_more_data_file(
      '%s %s %s %s experiments' % (pname, xname, dname, sweep),
      self.get_integrated_experiments())

    from iotbx.reflection_file_reader import any_reflection_file
    miller_arrays = any_reflection_file(hklout).as_miller_arrays()
    # look for profile-fitted intensities
    intensities = [ma for ma in miller_arrays
                   if ma.info().labels == ['IPR', 'SIGIPR']]
    if len(intensities) == 0:
      # look instead for summation-integrated intensities
      intensities = [ma for ma in miller_arrays
                     if ma.info().labels == ['I', 'SIGI']]
      assert len(intensities)
    self._intgr_n_ref = intensities[0].size()

    return hklout
    def _integrate_finish(self):
        """Finish off the integration by running dials.export."""

        # FIXME - do we want to export every time we call this method
        # (the file will not have changed) and also (more important) do
        # we want a different exported MTZ file every time (I do not think
        # that we do; these can be very large) - was exporter.get_xpid() ->
        # now dials

        if self._output_format == "hkl":
            exporter = self.ExportMtz()
            exporter.set_reflections_filename(
                self._intgr_integrated_reflections)
            mtz_filename = os.path.join(self.get_working_directory(),
                                        "%s_integrated.mtz" % "dials")
            exporter.set_mtz_filename(mtz_filename)
            exporter.run()
            self._intgr_integrated_filename = mtz_filename

            # record integrated MTZ file for e.g. BLEND.

            pname, xname, dname = self.get_integrater_project_info()
            sweep = self.get_integrater_sweep_name()
            FileHandler.record_more_data_file(
                "%s %s %s %s INTEGRATE" % (pname, xname, dname, sweep),
                mtz_filename)

            from iotbx.reflection_file_reader import any_reflection_file

            miller_arrays = any_reflection_file(
                self._intgr_integrated_filename).as_miller_arrays()
            # look for profile-fitted intensities
            intensities = [
                ma for ma in miller_arrays
                if ma.info().labels == ["IPR", "SIGIPR"]
            ]
            if len(intensities) == 0:
                # look instead for summation-integrated intensities
                intensities = [
                    ma for ma in miller_arrays
                    if ma.info().labels == ["I", "SIGI"]
                ]
                assert len(intensities)
            self._intgr_n_ref = intensities[0].size()

            if not os.path.isfile(self._intgr_integrated_filename):
                raise RuntimeError("dials.export failed: %s does not exist." %
                                   self._intgr_integrated_filename)

            if (self._intgr_reindex_operator is None
                    and self._intgr_spacegroup_number == lattice_to_spacegroup(
                        self.get_integrater_refiner().get_refiner_lattice())):
                Debug.write("Not reindexing to spacegroup %d (%s)" %
                            (self._intgr_spacegroup_number,
                             self._intgr_reindex_operator))
                return mtz_filename

            if (self._intgr_reindex_operator is None
                    and self._intgr_spacegroup_number == 0):
                Debug.write("Not reindexing to spacegroup %d (%s)" %
                            (self._intgr_spacegroup_number,
                             self._intgr_reindex_operator))
                return mtz_filename

            Debug.write(
                "Reindexing to spacegroup %d (%s)" %
                (self._intgr_spacegroup_number, self._intgr_reindex_operator))

            hklin = mtz_filename
            from xia2.Wrappers.CCP4.Reindex import Reindex

            reindex = Reindex()
            reindex.set_working_directory(self.get_working_directory())
            auto_logfiler(reindex)

            reindex.set_operator(self._intgr_reindex_operator)

            if self._intgr_spacegroup_number:
                reindex.set_spacegroup(self._intgr_spacegroup_number)
            else:
                reindex.set_spacegroup(
                    lattice_to_spacegroup(
                        self.get_integrater_refiner().get_refiner_lattice()))

            hklout = "%s_reindex.mtz" % hklin[:-4]
            reindex.set_hklin(hklin)
            reindex.set_hklout(hklout)
            reindex.reindex()
            self._intgr_integrated_filename = hklout
            self._intgr_cell = reindex.get_cell()

            pname, xname, dname = self.get_integrater_project_info()
            sweep = self.get_integrater_sweep_name()
            FileHandler.record_more_data_file(
                "%s %s %s %s" % (pname, xname, dname, sweep),
                self.get_integrated_experiments(),
            )
            FileHandler.record_more_data_file(
                "%s %s %s %s" % (pname, xname, dname, sweep),
                self.get_integrated_reflections(),
            )

            return hklout

        elif self._output_format == "pickle":

            if (self._intgr_reindex_operator is None
                    and self._intgr_spacegroup_number == lattice_to_spacegroup(
                        self.get_integrater_refiner().get_refiner_lattice())):
                Debug.write("Not reindexing to spacegroup %d (%s)" %
                            (self._intgr_spacegroup_number,
                             self._intgr_reindex_operator))
                return self._intgr_integrated_reflections

            if (self._intgr_reindex_operator is None
                    and self._intgr_spacegroup_number == 0):
                Debug.write("Not reindexing to spacegroup %d (%s)" %
                            (self._intgr_spacegroup_number,
                             self._intgr_reindex_operator))
                return self._intgr_integrated_reflections

            Debug.write(
                "Reindexing to spacegroup %d (%s)" %
                (self._intgr_spacegroup_number, self._intgr_reindex_operator))
            from xia2.Wrappers.Dials.Reindex import Reindex

            reindex = Reindex()
            reindex.set_working_directory(self.get_working_directory())
            auto_logfiler(reindex)

            reindex.set_cb_op(self._intgr_reindex_operator)

            if self._intgr_spacegroup_number:
                reindex.set_space_group(self._intgr_spacegroup_number)
            else:
                reindex.set_space_group(
                    lattice_to_spacegroup(
                        self.get_integrater_refiner().get_refiner_lattice()))

            reindex.set_experiments_filename(self.get_integrated_experiments())
            reindex.set_indexed_filename(self.get_integrated_reflections())

            reindex.run()
            self._intgr_integrated_reflections = (
                reindex.get_reindexed_reflections_filename())
            self._intgr_integrated_filename = (
                reindex.get_reindexed_reflections_filename())
            self._intgr_experiments_filename = (
                reindex.get_reindexed_experiments_filename())

            pname, xname, dname = self.get_integrater_project_info()
            sweep = self.get_integrater_sweep_name()
            FileHandler.record_more_data_file(
                "%s %s %s %s" % (pname, xname, dname, sweep),
                self.get_integrated_experiments(),
            )
            FileHandler.record_more_data_file(
                "%s %s %s %s" % (pname, xname, dname, sweep),
                self.get_integrated_reflections(),
            )
            return None  # this will be set to intgr_hklout - better to cause failure