Пример #1
0
def print_params():
    """ Print out master parameters for IOTA """

    help_out = convert_phil_to_text(master_phil, att_level=1)
    txt_out = convert_phil_to_text(master_phil)

    return help_out, txt_out
Пример #2
0
    def onOutputScript(self, e):

        # Determine param filepath
        save_dlg = wx.FileDialog(self,
                                 message="Save IOTA Script",
                                 defaultDir=os.curdir,
                                 defaultFile="*.param",
                                 wildcard="*",
                                 style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        if save_dlg.ShowModal() == wx.ID_OK:
            script_filepath = save_dlg.GetPath()

            # Finalize settings
            self.init_settings()
            self.gparams = self.iota_phil.extract()

            # Save target PHIL file, if a PHIL script exists
            if self.target_phil is not None:
                if self.gparams.advanced.processing_backend == 'ha14':
                    phil_filepath = os.path.join(
                        os.path.dirname(script_filepath), 'cctbx_ha14.phil')
                    self.gparams.cctbx_ha14.target = phil_filepath
                if self.gparams.advanced.processing_backend == 'cctbx.xfel':
                    phil_filepath = os.path.join(
                        os.path.dirname(script_filepath), 'cctbx_xfel.phil')
                    self.gparams.cctbx_xfel.target = phil_filepath

            # Generate text of params
            final_phil = self.iota_phil.format(python_object=self.gparams)
            final_phil_txt = util.convert_phil_to_text(final_phil,
                                                       script_filepath)

            if self.target_phil is not None:
                with open(phil_filepath, 'w') as phil_file:
                    phil_file.write(self.target_phil)
Пример #3
0
  def initialize_main_log(self):
    """ Initialize main log (iota.log) and record starting parameters

    :return: True if successful, False if fails
    """
    try:
      # Generate text of params
      self.iota_phil_string = util.convert_phil_to_text(self.iota_phil)

      # Initialize main log
      self.logfile = os.path.abspath(os.path.join(self.int_base, 'iota.log'))

      # Log starting info
      util.main_log(self.logfile, '{:*^80} \n'.format(' IOTA MAIN LOG '))
      util.main_log(self.logfile, '{:-^80} \n'.format(' SETTINGS FOR THIS RUN '))
      util.main_log(self.logfile, self.iota_phil_string)

      # Log cctbx.xfel / DIALS settings
      util.main_log(self.logfile, '{:-^80} \n'.format('BACKEND SETTINGS'))
      util.main_log(self.logfile, self.target_phil)

      return True, 'IOTA_INIT: MAIN LOG INITIALIZED'
    except Exception as e:
      return False, 'IOTA_INIT_ERROR: MAIN LOG NOT INITIALIZED, {}'.format(e)
  def make_prime_input(self,
                       filename='prime.phil',
                       run_zero=False):
    """ Imports default PRIME input parameters, modifies correct entries and
        prints out a starting PHIL file to be used with PRIME
    """
    pixel_size = self.final_objects[0].final['pixel_size']
    try:
      sg = str(self.cons_pg).replace(" ", "")
    except AttributeError as e:
      print ('PRIME INPUT ERROR, SPACE GROUP: ', e)
      sg = 'P1'

    sym = crystal.symmetry(space_group_symbol=sg)
    crystal_system = str(sym.space_group().crystal_system())

    # Determine number of images for indexing ambiguity resolution
    # My default: 1/2 of images or 300, whichever is smaller
    if len(self.final_objects) >= 600:
      idx_ambiguity_sample = 300
      idx_ambiguity_selected = 100
    else:
      idx_ambiguity_sample = int(round(len(self.final_objects) / 2))
      idx_ambiguity_selected = int(round(idx_ambiguity_sample / 3))

    prime_params = mod_input.master_phil.extract()

    if run_zero:
      run_no = '000'
    else:
      run_no = '001'

    # Populate pertinent data parameters
    prime_params.run_no = os.path.join(os.path.dirname(self.prime_data_path),
                                         'prime/{}'.format(run_no))
    prime_params.data = [self.prime_data_path]
    prime_params.title = 'Auto-generated by IOTA v{} on {}'.format(self.ver, self.now)
    prime_params.scale.d_min = np.mean(self.hres)
    prime_params.scale.d_max = 8
    prime_params.postref.scale.d_min = np.mean(self.hres)
    prime_params.postref.scale.d_max = np.max(self.lres)
    prime_params.postref.crystal_orientation.d_min = np.mean(self.hres)
    prime_params.postref.crystal_orientation.d_max = np.max(self.lres)
    prime_params.postref.reflecting_range.d_min = np.mean(self.hres)
    prime_params.postref.reflecting_range.d_max = np.max(self.lres)
    prime_params.postref.unit_cell.d_min = np.mean(self.hres)
    prime_params.postref.unit_cell.d_max = np.max(self.lres)
    prime_params.postref.allparams.d_min = np.mean(self.hres)
    prime_params.postref.allparams.d_max = np.max(self.lres)
    prime_params.merge.d_min = np.mean(self.hres)
    prime_params.merge.d_max = np.max(self.lres)
    prime_params.target_unit_cell = uctbx.unit_cell(self.cons_uc)
    prime_params.target_space_group = sg
    prime_params.target_crystal_system = crystal_system
    prime_params.pixel_size_mm = pixel_size
    prime_params.n_residues = 500
    prime_params.indexing_ambiguity.n_sample_frames = idx_ambiguity_sample
    prime_params.indexing_ambiguity.n_selected_frames = idx_ambiguity_selected

    # Determine which queue to run on (i.e. match IOTA queue)
    # Modify specific options based in IOTA settings
    # Queue options
    if (
            self.params.mp.method == 'lsf' and
            self.params.mp.queue is not None
    ):
      prime_params.queue.mode = 'bsub'
      prime_params.queue.qname = self.params.mp.queue

    # Number of processors (automatically, 1/2 of IOTA procs)
    prime_params.n_processors = int(self.params.mp.n_processors / 2)

    # Generate PRIME param PHIL
    prime_phil = mod_input.master_phil.format(python_object=prime_params)
    prime_file = os.path.join(self.output_dir, filename)
    prime_phil_txt = util.convert_phil_to_text(prime_phil, prime_file)

    return prime_phil
Пример #5
0
    params.cctbx_ha14.image_conversion.rename_pickle_prefix = args.prefix

  #Check -s option to bypass grid search and run selection/integration only
  if args.select:
    params.cctbx_ha14.selection.select_only.flag_on = True

  # Check if grid search is turned off; if so, set everything to zero
  if str(params.cctbx_ha14.grid_search.type).lower() == 'none':
    params.cctbx_ha14.grid_search.area_range = 0
    params.cctbx_ha14.grid_search.height_range = 0
    params.cctbx_ha14.grid_search.sig_height_search = False

  final_phil = master_phil.format(python_object=params)

  if mode == 'auto':
    txt_out = convert_phil_to_text(final_phil)
    write_defaults(os.path.abspath(os.curdir), txt_out,
                   params.advanced.processing_backend)

  return final_phil


def write_defaults(current_path=None, txt_out=None, method='current',
                   write_target_file=True, write_param_file=True):
  """ Generates list of default parameters for a reasonable target file:
        - old cctbx.xfel (HA14) now deprecated, but can still be used
        - also writes out the IOTA parameter file.

  :param current_path: path to current output folder
  :param txt_out: text of IOTA parameters
  :param method: which backend is used (default = cctbx.xfel AB18)