示例#1
0
def run(prefix="tst_00"):
    # Good answer model
    pdb_file_name_answer = "%s_answer.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_answer)
    pdb_inp.write_pdb_file(file_name="%s_answer.pdb" % prefix)
    ph_answer = pdb_inp.construct_hierarchy()
    ph_answer.atoms().reset_i_seq()
    xrs_answer = pdb_inp.xray_structure_simple()
    # Poor model that we want to refine so it matches the answer
    pdb_file_name_poor = "%s_poor.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_poor)
    pdb_inp.write_pdb_file(file_name="%s_poor.pdb" % prefix)
    ph_poor = pdb_inp.construct_hierarchy()
    ph_poor.atoms().reset_i_seq()
    xrs_poor = pdb_inp.xray_structure_simple()
    # Initialize states accumulator
    states = mmtbx.utils.states(pdb_hierarchy=ph_answer, xray_structure=xrs_poor)
    states.add(sites_cart=xrs_poor.sites_cart())
    # Compute target map
    fc = xrs_answer.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="map.ccp4", 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="map.mtz")
    # Build geometry restraints
    params = monomer_library.pdb_interpretation.master_params.extract()
    # params.nonbonded_weight=200
    # params.peptide_link.ramachandran_restraints=True
    # params.peptide_link.rama_potential="emsley"
    processed_pdb_file = monomer_library.pdb_interpretation.process(
        mon_lib_srv=monomer_library.server.server(),
        ener_lib=monomer_library.server.ener_lib(),
        raw_records=pdb_str_poor,
        params=params,
        strict_conflict_handling=True,
        force_symmetry=True,
        log=None,
    )

    geometry = processed_pdb_file.geometry_restraints_manager(
        show_energies=False, plain_pairs_radius=5, assume_hydrogens_all_missing=True
    )
    restraints_manager = mmtbx.restraints.manager(geometry=geometry, normalization=True)
    # Do real-space refinement
    t0 = time.time()
    ear = mmtbx.refinement.real_space.explode_and_refine.run(
        xray_structure=xrs_poor,
        pdb_hierarchy=ph_poor,
        map_data=target_map_data,
        restraints_manager=restraints_manager,
        states=states,
        nproc=1,
    )
    print "Time: %6.4f" % (time.time() - t0)
    ear.pdb_hierarchy.write_pdb_file(file_name="%s_refined.pdb" % prefix)
    states.write(file_name="%s_refined_all_states.pdb" % prefix)
示例#2
0
 def write_output_files(self, mtz_file_name, ccp4_map_file_name, fem_label,
                        orig_label):
   mtz_dataset = self.mc_result.as_mtz_dataset(column_root_label=fem_label)
   mtz_dataset.add_miller_array(
     miller_array      = self.mc_orig,
     column_root_label = orig_label)
   mtz_object = mtz_dataset.mtz_object()
   mtz_object.write(file_name = mtz_file_name)
   ccp4_map(cg=self.crystal_gridding, file_name=ccp4_map_file_name,
     map_data=self.map_result)
示例#3
0
def run(prefix="tst_00"):
    # Poor model that we want to refine so it matches the answer
    pdb_inp = iotbx.pdb.input(file_name="poor_model.pdb")
    ph_poor = pdb_inp.construct_hierarchy()
    ph_poor.atoms().reset_i_seq()
    xrs_poor = pdb_inp.xray_structure_simple()
    # Initialize states accumulator
    states = mmtbx.utils.states(pdb_hierarchy=ph_poor, xray_structure=xrs_poor)
    states.add(sites_cart=xrs_poor.sites_cart())
    # Compute target map
    mas = reflection_file_reader.any_reflection_file(
        file_name="poor_map.mtz").as_miller_arrays()
    assert len(mas) == 1
    fc = mas[0]

    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="map.ccp4",
             map_data=target_map_data)
    # Build geometry restraints
    params = monomer_library.pdb_interpretation.master_params.extract()
    params.nonbonded_weight = 200
    #params.peptide_link.ramachandran_restraints=True
    #params.peptide_link.rama_potential="oldfield"
    #print dir(params)
    #STOP()
    processed_pdb_file = monomer_library.pdb_interpretation.process(
        mon_lib_srv=monomer_library.server.server(),
        ener_lib=monomer_library.server.ener_lib(),
        file_name="poor_model.pdb",
        params=params,
        #crystal_symmetry = fc.crystal_symmetry(),
        strict_conflict_handling=True,
        force_symmetry=True,
        log=None)

    geometry = processed_pdb_file.geometry_restraints_manager(
        show_energies=False,
        plain_pairs_radius=5,
        assume_hydrogens_all_missing=True)
    restraints_manager = mmtbx.restraints.manager(geometry=geometry,
                                                  normalization=True)

    #for a in ph_answer.atoms():
    #  print a.i_seq, a.name, a.xyz
    #STOP()

    #ref_xyz = flex.vec3_double([(14.323, 35.055, 14.635), (16.099, 12.317, 16.37)])
    #selection = flex.size_t([1,76])
    #
    #restraints_manager.geometry.adopt_reference_coordinate_restraints_in_place(
    #  reference.add_coordinate_restraints(
    #    sites_cart = ref_xyz,
    #    selection = selection,
    #    sigma = 0.1))

    # Do real-space refinement
    t0 = time.time()
    ear = mmtbx.refinement.real_space.explode_and_refine.run(
        xray_structure=xrs_poor,
        pdb_hierarchy=ph_poor,
        map_data=target_map_data,
        restraints_manager=restraints_manager,
        states=states)
    print "Time: %6.4f" % (time.time() - t0)
    ear.pdb_hierarchy.write_pdb_file(file_name="%s_refined.pdb" % prefix)
    states.write(file_name="%s_refined_all_states.pdb" % prefix)
示例#4
0
def run(prefix="tst_00"):
  # Poor model that we want to refine so it matches the answer
  pdb_inp = iotbx.pdb.input(file_name="poor_model.pdb")
  ph_poor = pdb_inp.construct_hierarchy()
  ph_poor.atoms().reset_i_seq()
  xrs_poor = pdb_inp.xray_structure_simple()
  # Initialize states accumulator
  states = mmtbx.utils.states(pdb_hierarchy=ph_poor, xray_structure=xrs_poor)
  states.add(sites_cart = xrs_poor.sites_cart())
  # Compute target map
  mas = reflection_file_reader.any_reflection_file(file_name =
    "poor_map.mtz").as_miller_arrays()
  assert len(mas)==1
  fc = mas[0]

  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="map.ccp4",
    map_data=target_map_data)
  # Build geometry restraints
  params = monomer_library.pdb_interpretation.master_params.extract()
  params.nonbonded_weight=200
  #params.peptide_link.ramachandran_restraints=True
  #params.peptide_link.rama_potential="oldfield"
  #print dir(params)
  #STOP()
  processed_pdb_file = monomer_library.pdb_interpretation.process(
    mon_lib_srv              = monomer_library.server.server(),
    ener_lib                 = monomer_library.server.ener_lib(),
    file_name              = "poor_model.pdb",
    params                   = params,
    #crystal_symmetry = fc.crystal_symmetry(),
    strict_conflict_handling = True,
    force_symmetry           = True,
    log                      = None)

  geometry = processed_pdb_file.geometry_restraints_manager(
    show_energies                = False,
    plain_pairs_radius           = 5,
    assume_hydrogens_all_missing = True)
  restraints_manager = mmtbx.restraints.manager(
    geometry      = geometry,
    normalization = True)

  #for a in ph_answer.atoms():
  #  print a.i_seq, a.name, a.xyz
    #STOP()

  #ref_xyz = flex.vec3_double([(14.323, 35.055, 14.635), (16.099, 12.317, 16.37)])
  #selection = flex.size_t([1,76])
  #
  #restraints_manager.geometry.adopt_reference_coordinate_restraints_in_place(
  #  reference.add_coordinate_restraints(
  #    sites_cart = ref_xyz,
  #    selection = selection,
  #    sigma = 0.1))

  # Do real-space refinement
  t0=time.time()
  ear = mmtbx.refinement.real_space.explode_and_refine.run(
    xray_structure          = xrs_poor,
    pdb_hierarchy           = ph_poor,
    map_data                = target_map_data,
    restraints_manager      = restraints_manager,
    states                  = states)
  print "Time: %6.4f"%(time.time()-t0)
  ear.pdb_hierarchy.write_pdb_file(file_name="%s_refined.pdb"%prefix)
  states.write(file_name="%s_refined_all_states.pdb"%prefix)
示例#5
0
def run(prefix="tst_00"):
    # Good answer model
    pdb_file_name_answer = "%s_answer.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_answer)
    pdb_inp.write_pdb_file(file_name="%s_answer.pdb" % prefix)
    ph_answer = pdb_inp.construct_hierarchy()
    ph_answer.atoms().reset_i_seq()
    xrs_answer = pdb_inp.xray_structure_simple()
    # Poor model that we want to refine so it matches the answer
    pdb_file_name_poor = "%s_poor.pdb" % prefix
    pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str_poor)
    pdb_inp.write_pdb_file(file_name="%s_poor.pdb" % prefix)
    ph_poor = pdb_inp.construct_hierarchy()
    ph_poor.atoms().reset_i_seq()
    xrs_poor = pdb_inp.xray_structure_simple()
    # Initialize states accumulator
    states = mmtbx.utils.states(pdb_hierarchy=ph_answer,
                                xray_structure=xrs_poor)
    states.add(sites_cart=xrs_poor.sites_cart())
    # Compute target map
    fc = xrs_answer.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="map.ccp4",
             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="map.mtz")
    # Build geometry restraints
    params = monomer_library.pdb_interpretation.master_params.extract()
    #params.nonbonded_weight=200
    #params.peptide_link.ramachandran_restraints=True
    #params.peptide_link.rama_potential="emsley"
    processed_pdb_file = monomer_library.pdb_interpretation.process(
        mon_lib_srv=monomer_library.server.server(),
        ener_lib=monomer_library.server.ener_lib(),
        raw_records=pdb_str_poor,
        params=params,
        strict_conflict_handling=True,
        force_symmetry=True,
        log=None)

    geometry = processed_pdb_file.geometry_restraints_manager(
        show_energies=False,
        plain_pairs_radius=5,
        assume_hydrogens_all_missing=True)
    restraints_manager = mmtbx.restraints.manager(geometry=geometry,
                                                  normalization=True)
    # Do real-space refinement
    t0 = time.time()
    ear = mmtbx.refinement.real_space.explode_and_refine.run(
        xray_structure=xrs_poor,
        pdb_hierarchy=ph_poor,
        map_data=target_map_data,
        restraints_manager=restraints_manager,
        states=states,
        nproc=1)
    print "Time: %6.4f" % (time.time() - t0)
    ear.pdb_hierarchy.write_pdb_file(file_name="%s_refined.pdb" % prefix)
    states.write(file_name="%s_refined_all_states.pdb" % prefix)