示例#1
0
  def create_trial(self, d_min = 1.5, n_bins = 10, **kwargs):
    # d_min and n_bins only used if isoforms are in this trial

    trial = Trial(self, d_min = d_min, **kwargs)
    if trial.target_phil_str is not None:
      from iotbx.phil import parse
      backend = ['labelit', 'dials'][['cxi.xtc_process', 'cctbx.xfel.xtc_process'].index(self.params.dispatcher)]
      if backend == 'labelit':
        from spotfinder.applications.xfel import cxi_phil
        trial_params = cxi_phil.cxi_versioned_extract().persist.phil_scope.fetch(parse(trial.target_phil_str)).extract()
        isoforms = trial_params.isoforms
      elif backend == 'dials':
        from xfel.command_line.xtc_process import phil_scope
        trial_params = phil_scope.fetch(parse(trial.target_phil_str)).extract()
        isoforms = trial_params.indexing.stills.isoforms
      else:
        assert False
      if len(isoforms) > 0:
        for isoform in isoforms:
          print "Creating isoform", isoform.name
          db_isoform = Isoform(self,
                               name = isoform.name,
                               trial_id = trial.id)
          a, b, c, alpha, beta, gamma = isoform.cell.parameters()
          cell = self.create_cell(cell_a = a, cell_b = b, cell_c = c,
                                  cell_alpha = alpha, cell_beta = beta, cell_gamma = gamma,
                                  lookup_symbol = isoform.lookup_symbol,
                                  isoform_id = db_isoform.id)
          from cctbx.crystal import symmetry

          cs = symmetry(unit_cell = isoform.cell,space_group_symbol=str(isoform.lookup_symbol))
          mset = cs.build_miller_set(anomalous_flag=False, d_min=d_min)
          binner = mset.setup_binner(n_bins=n_bins)
          for i in binner.range_used():
            d_max, d_min = binner.bin_d_range(i)
            Bin(self, number = i, d_min = d_min, d_max = d_max,
                total_hkl = binner.counts_complete()[i], cell_id = cell.id)
      elif backend == 'labelit':
        pass # TODO: labelit target
      elif backend == 'dials':
        if trial_params.indexing.known_symmetry.unit_cell is not None and \
            trial_params.indexing.known_symmetry.space_group is not None:
          print "Creating target cell"
          unit_cell = trial_params.indexing.known_symmetry.unit_cell
          symbol = str(trial_params.indexing.known_symmetry.space_group)
          a, b, c, alpha, beta, gamma = unit_cell.parameters()
          cell = self.create_cell(cell_a = a, cell_b = b, cell_c = c,
                                  cell_alpha = alpha, cell_beta = beta, cell_gamma = gamma,
                                  lookup_symbol = symbol,
                                  trial_id = trial.id)
          from cctbx.crystal import symmetry

          cs = symmetry(unit_cell = unit_cell, space_group_symbol = symbol)
          mset = cs.build_miller_set(anomalous_flag=False, d_min=d_min)
          binner = mset.setup_binner(n_bins=n_bins)
          for i in binner.range_used():
            d_max, d_min = binner.bin_d_range(i)
            Bin(self, number = i, d_min = d_min, d_max = d_max,
                total_hkl = binner.counts_complete()[i], cell_id = cell.id)
    return trial
示例#2
0
 def get_trial(self, trial_id = None, trial_number = None):
   assert [trial_id, trial_number].count(None) == 1
   if trial_id is None:
     trials = [t for t in self.get_all_trials() if t.trial == trial_number]
     assert len(trials) == 1
     return trials[0]
   else:
     return Trial(self, trial_id)
示例#3
0
    def __init__(self, params, composite_tag=None, rank=0):
        super(DialsProcessorWithLogging,
              self).__init__(params, composite_tag, rank)
        self.tt_low = None
        self.tt_high = None
        if self.params.experiment_tag is None:
            return

        assert params.db.logging_batch_size >= 1

        from libtbx.mpi4py import MPI
        comm = MPI.COMM_WORLD

        self.queries = []
        self.rank = rank

        if comm.size > 1:
            if rank == 0:
                db_app = dxtbx_xfel_db_application(params,
                                                   cache_connection=False,
                                                   mode='cache_commits')
                run = db_app.get_run(run_number=self.params.input.run_num)
                run_id = run.id
                rund = run._db_dict
                trial = db_app.get_trial(trial_number=params.input.trial)
                trial_id = trial.id
                triald = trial._db_dict
            else:
                db_app = None
                run_id = None
                rund = None
                trial_id = None
                triald = None
            self.db_app, run_id, rund, trial_id, triald = comm.bcast(
                (db_app, run_id, rund, trial_id, triald), root=0)
            self.run = Run(self.db_app, run_id=run_id, **rund)
            self.trial = Trial(self.db_app, trial_id=trial_id, **triald)
        else:
            self.db_app = dxtbx_xfel_db_application(params,
                                                    cache_connection=False,
                                                    mode='cache_commits')
            self.run = self.db_app.get_run(
                run_number=self.params.input.run_num)
            self.trial = self.db_app.get_trial(trial_number=params.input.trial)
        self.n_strong = None