示例#1
0
 def merge_models(self, pdb_hierarchy):
   t0=time.time()
   assert pdb_hierarchy.models_size() == self.number_of_trials, \
     pdb_hierarchy.models_size()
   from mmtbx.building.merge_models import run as merge_models
   pdb_hierarchy_merged = merge_models(
     map_data         = self.map_data,
     pdb_hierarchy    = pdb_hierarchy,
     crystal_symmetry = self.xray_structure.crystal_symmetry(),
     out              = self.log)
   if(self.show):
     pdb_hierarchy_merged.write_pdb_file(
       file_name="SA_ensemble_refined_merged.pdb")
   self.xray_structure = self.xray_structure.replace_sites_cart(
     new_sites=pdb_hierarchy_merged.atoms().extract_xyz())
   self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
   print >> self.log, "Time (merge): %10.3f"%(time.time()-t0)
def tst_01():
  print "\nTesting merge_model\n"
  prefix='tst_01'
  # Full good answer model
  pdb_file_name_answer_full = "%s_answer_full.pdb"%prefix
  pdb_inp = iotbx.pdb.input(source_info=None, lines = pdb_str_answer_AE)
  pdb_inp.write_pdb_file(file_name="%s_answer.pdb"%prefix)
  ph_answer_full = pdb_inp.construct_hierarchy()
  ph_answer_full.atoms().reset_i_seq()
  xrs_answer_full = pdb_inp.xray_structure_simple()

  # Two models we want to merge
  pdb_file_name_two_models = "%s_poor_two_models.pdb"%prefix
  pdb_inp = iotbx.pdb.input(source_info=None, lines = pdb_str_two_models)
  pdb_inp.write_pdb_file(file_name="%s_two_models.pdb"%prefix)
  xrs_two_models_full = pdb_inp.xray_structure_simple()

  # Compute target map
  fc = xrs_answer_full.structure_factors(d_min=3.5).f_calc()
  fft_map = fc.fft_map(resolution_factor = 0.25)
  fft_map.apply_sigma_scaling()
  target_map_data = fft_map.real_map_unpadded()
  ccp4_map(crystal_symmetry=fc.crystal_symmetry(),
    file_name="%s_map.ccp4" %prefix,
    map_data=target_map_data)
  # Output map coefficients
  mtz_dataset = fc.as_mtz_dataset(column_root_label="FC")
  mtz_object = mtz_dataset.mtz_object()
  mtz_object.write(file_name = "%s_map.mtz"%prefix)

  from mmtbx.building.merge_models import run as merge_models
  hierarchy=merge_models(
      map_data=target_map_data,
      pdb_inp=pdb_inp,
      dist_max=100,
      verbose=True)

  pdb_inp=hierarchy.as_pdb_input(crystal_symmetry=fc.crystal_symmetry())
  xrs=pdb_inp.xray_structure_simple()
  hierarchy.write_pdb_file(file_name="%s_refined.pdb"%prefix)
  rmsd=xrs.sites_cart().rms_difference(xrs_answer_full.sites_cart())
  print "RMSD from TARGET allowing any CROSSOVERS: %8.2f " %(rmsd)
  return rmsd
示例#3
0
def tst_01():
    print "\nTesting merge_model\n"
    prefix = 'tst_01'
    # Full good answer model
    pdb_file_name_answer_full = "%s_answer_full.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_answer_AE)
    pdb_inp.write_pdb_file(file_name="%s_answer.pdb" % prefix)
    ph_answer_full = pdb_inp.construct_hierarchy()
    ph_answer_full.atoms().reset_i_seq()
    xrs_answer_full = pdb_inp.xray_structure_simple()

    # Two models we want to merge
    pdb_file_name_two_models = "%s_poor_two_models.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_two_models)
    pdb_inp.write_pdb_file(file_name="%s_two_models.pdb" % prefix)
    xrs_two_models_full = pdb_inp.xray_structure_simple()

    # Compute target map
    fc = xrs_answer_full.structure_factors(d_min=3.5).f_calc()
    fft_map = fc.fft_map(resolution_factor=0.25)
    fft_map.apply_sigma_scaling()
    target_map_data = fft_map.real_map_unpadded()
    ccp4_map(crystal_symmetry=fc.crystal_symmetry(),
             file_name="%s_map.ccp4" % prefix,
             map_data=target_map_data)
    # Output map coefficients
    mtz_dataset = fc.as_mtz_dataset(column_root_label="FC")
    mtz_object = mtz_dataset.mtz_object()
    mtz_object.write(file_name="%s_map.mtz" % prefix)

    from mmtbx.building.merge_models import run as merge_models
    hierarchy = merge_models(map_data=target_map_data,
                             pdb_inp=pdb_inp,
                             dist_max=100,
                             verbose=True)

    pdb_inp = hierarchy.as_pdb_input(crystal_symmetry=fc.crystal_symmetry())
    xrs = pdb_inp.xray_structure_simple()
    hierarchy.write_pdb_file(file_name="%s_refined.pdb" % prefix)
    rmsd = xrs.sites_cart().rms_difference(xrs_answer_full.sites_cart())
    print "RMSD from TARGET allowing any CROSSOVERS: %8.2f " % (rmsd)
    return rmsd
 def merge_models(self, pdb_hierarchy):
     #
     t0 = time.time()
     sites_cart = []
     if ("geometry" in self.score_method or "cc" in self.score_method):
         if ("geometry" in self.score_method):
             sites_cart.append(
                 self._score_by_geometry(pdb_hierarchy=pdb_hierarchy))
         if ("cc" in self.score_method):
             sites_cart.append(
                 self._score_by_cc(pdb_hierarchy=pdb_hierarchy))
         sites_cart_best = None
         cc_best = -1
         for sc in sites_cart:
             cc = self.get_cc(sites_cart=sc)
             print("CC:", cc)
             if (cc > cc_best):
                 cc_best = cc
                 sites_cart_best = sc.deep_copy()
         self.xray_structure.set_sites_cart(sites_cart=sites_cart_best)
         self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
         self.pdb_hierarchy.write_pdb_file(file_name="merged.pdb")
     #
     if ("merge_models" in self.score_method):
         assert pdb_hierarchy.models_size() == self.number_of_trials, \
           pdb_hierarchy.models_size()
         from mmtbx.building.merge_models import run as merge_models
         pdb_hierarchy_merged = merge_models(
             map_data=self.map_data,
             resolution=self.resolution,
             pdb_hierarchy=pdb_hierarchy,
             crystal_symmetry=self.xray_structure.crystal_symmetry(),
             out=self.log)
         if (self.show):
             pdb_hierarchy_merged.write_pdb_file(
                 file_name="SA_ensemble_refined_merged.pdb")
         self.xray_structure = self.xray_structure.replace_sites_cart(
             new_sites=pdb_hierarchy_merged.atoms().extract_xyz())
         self.pdb_hierarchy.adopt_xray_structure(self.xray_structure)
     print("Time (merge): %10.3f" % (time.time() - t0), file=self.log)