def update_xyz(self, sites_cart): self.pdb_hierarchy.atoms().set_xyz(sites_cart) pre_atoms = [ atom.pdb_label_columns() for atom in self.pdb_hierarchy_super.atoms() ] self.expansion = self.expansion.update_xyz(sites_cart=sites_cart) self.pdb_hierarchy_super = self.expansion.ph_super_sphere new_atoms = [ atom.pdb_label_columns() for atom in self.pdb_hierarchy_super.atoms() ] #if(self.expansion.ph_super_sphere.atoms_size()!=pre_size): if (pre_atoms != new_atoms): if (self.debug): print( "the content of the super sphere has been changed,reset up fragments" ) #Note: the atom size of self.expansion.ph_super_sphere gets changeed, #while the atom size in super_sphere_geometry_restraints_manager #does not get changed. Re-generate the object of expand if (1): self.expansion = expand( pdb_hierarchy=self.pdb_hierarchy, crystal_symmetry=self.crystal_symmetry, select_within_radius=self.select_within_radius) self.pdb_hierarchy_super = self.expansion.ph_super_sphere self.get_fragments() self.get_fragment_hierarchies_and_charges()
def run(prefix): """ Exercise supercell. """ of = open("%s.pdb"%prefix,"w") print >> of, pdb_str of.close() pdb_inp = iotbx.pdb.input(source_info=None, lines=pdb_str) ph = pdb_inp.construct_hierarchy() sites_cart_start = ph.atoms().extract_xyz() o = super_cell.expand( pdb_hierarchy = ph, crystal_symmetry = pdb_inp.crystal_symmetry(), select_within_radius = 11) # o.write_super_cell_selected_in_sphere(file_name="%s_super_sphere.pdb"%prefix) sites_cart = ph.atoms().extract_xyz() o.update(sites_cart = sites_cart) o.write_super_cell_selected_in_sphere(file_name="%s_super_sphere.pdb"%prefix) # sites_cart_super_sphere_answer = iotbx.pdb.input(source_info=None, lines=pdb_str_super_sphere_answer).atoms().extract_xyz() super_sphere_answer = list(sites_cart_super_sphere_answer.as_double()) super_sphere = list(o.ph_super_sphere.atoms().extract_xyz().as_double()) super_sphere_answer.sort() super_sphere.sort() assert approx_equal(super_sphere_answer,super_sphere)
def run(file_name, pdb_code): pdb_inp = iotbx.pdb.input(file_name=file_name) pdb_hierarchy = pdb_inp.construct_hierarchy() n_atoms = pdb_hierarchy.atoms().size() if (n_atoms > 10000): return None if (len(list(pdb_hierarchy.models())) > 1): return None fraction_of_nonH_incomplete = complete_model(pdb_hierarchy=pdb_hierarchy) cs = pdb_inp.crystal_symmetry() resolution = get_resolution(pdb_inp=pdb_inp) super_cell = expand(pdb_hierarchy=pdb_hierarchy, crystal_symmetry=cs, create_restraints_manager=False) symmetry_ss_bonds = find_ss_across_symmetry(super_cell=super_cell) result_occupancies = get_altloc_counts(pdb_hierarchy=pdb_hierarchy) ligands = get_non_standard_items(pdb_hierarchy=pdb_hierarchy) result = group_args( number_of_atoms=pdb_hierarchy.atoms().size(), number_of_atoms_super_sphere=super_cell.ph_super_sphere.atoms().size(), occupancies=result_occupancies, unit_cell=cs.unit_cell().parameters(), space_group_symbol=cs.space_group().type().lookup_symbol(), resolution=resolution, data_type=pdb_inp.get_experiment_type(), ligands=ligands, symmetry_ss_bonds=symmetry_ss_bonds, fraction_of_nonH_incomplete=fraction_of_nonH_incomplete) easy_pickle.dump(pdb_code + ".pkl", result)
def _expand(self): expansion = expand( pdb_hierarchy = self.pdb_hierarchy, crystal_symmetry = self.crystal_symmetry, select_within_radius = self.params.cluster.select_within_radius) pdb_hierarchy_super = expansion.ph_super_sphere pdb_hierarchy_super.write_pdb_file(file_name="supersphere.pdb", crystal_symmetry = expansion.cs_box) self.crystal_symmetry_ss = expansion.cs_box # Use same route for CCTBX and QM ! # if(self.restraints_source.source_of_restraints_qm()): if 1: self.pdb_hierarchy_super_completed = model_completion.run( #pdb_hierarchy = pdb_hierarchy_super, crystal_symmetry = expansion.cs_box, model_completion = False, pdb_filename = "supersphere.pdb", original_pdb_filename = None) else: self.pdb_hierarchy_super_completed = pdb_hierarchy_super selection = flex.bool( self.pdb_hierarchy_super_completed.atoms().size(), False) self.selection = selection.set_selected( flex.size_t(range(self.pdb_hierarchy.atoms().size())), True) self.restraints_manager = self.restraints_source.update( pdb_hierarchy = self.pdb_hierarchy_super_completed, crystal_symmetry = expansion.cs_box)
def __init__(self, working_folder="ase", clustering_method=None, altloc_method=None, maxnum_residues_in_cluster=20, charge_embedding=False, two_buffers=False, pdb_hierarchy=None, qm_engine_name=None, crystal_symmetry=None, clustering=True, qm_run=True, cif_objects=None, debug=False, charge_cutoff=8.0, save_clusters=False): self.charge_embedding = charge_embedding self.two_buffers = two_buffers self.crystal_symmetry = crystal_symmetry self.working_folder = os.path.abspath(working_folder) self.pdb_hierarchy = pdb_hierarchy self.charge_cutoff = charge_cutoff self.system_size = pdb_hierarchy.atoms_size() self.qm_engine_name = qm_engine_name self.clustering_method = clustering_method self.altloc_method = altloc_method self.debug = debug self.maxnum_residues_in_cluster = maxnum_residues_in_cluster self.save_clusters = save_clusters raw_records = pdb_hierarchy.as_pdb_string( crystal_symmetry=crystal_symmetry) self.charge_service = charges_class(raw_records=raw_records, ligand_cif_file_names=cif_objects) if (os.path.exists(self.working_folder) is not True): os.mkdir(self.working_folder) self.backbone_connections = fragment_utils.get_backbone_connections( self.pdb_hierarchy) self.get_altloc_molecular_indices() if (1): self.altloc_atoms = [ atom for atom in list(pdb_hierarchy.atoms()) if atom.pdb_label_columns()[4] != " " ] self.expansion = expand(pdb_hierarchy=self.pdb_hierarchy, crystal_symmetry=self.crystal_symmetry, select_within_radius=10.0) self.pdb_hierarchy_super = self.expansion.ph_super_sphere ## write expansion.pdb as the reference for capping self.expansion_file = "expansion.pdb" self.expansion.write_super_cell_selected_in_sphere( file_name=self.expansion_file) if (clustering): self.yoink_dat_path = os.path.join(qrefine, "plugin", "yoink", "dat") self.pyoink = PYoink( os.path.join(qrefine, "plugin", "yoink", "Yoink-0.0.1.jar")) self.qm_run = qm_run #t0 = time.time() self.set_up_cluster_qm()
def run(prefix): """ Make sure expand works for this particular file. """ pdb_name = os.path.join( qr_unit_tests_data, "1bdw_ala_refine_001_complete_minimized.pdb_modified.pdb") pdb_inp = iotbx.pdb.input(pdb_name) ph = pdb_inp.construct_hierarchy() cs = pdb_inp.crystal_symmetry() super_cell = expand(pdb_hierarchy=ph, crystal_symmetry=cs)
return interacting_pairs if __name__ == "__main__": f = qr_unit_tests_data + "/1yjp.pdb" print("1. clustering") pdb_inp = iotbx.pdb.input(f) ph = pdb_inp.construct_hierarchy() run(ph) print("2. fragment for residues 1 and 2") pdb_inp = iotbx.pdb.input(f) ph = pdb_inp.construct_hierarchy() run(ph, core=[1, 2]) print("3. clustering within expanded ph") pdb_inp = iotbx.pdb.input(f) cs = pdb_inp.crystal_symmetry() ph = pdb_inp.construct_hierarchy() expansion = expand(pdb_hierarchy=ph, crystal_symmetry=cs, select_within_radius=10.0).ph_super_sphere run(expansion) print("4. fragment for residues 1 and 2 within expanded ph") pdb_inp = iotbx.pdb.input(f) ph = pdb_inp.construct_hierarchy() cs = pdb_inp.crystal_symmetry() expansion = expand(pdb_hierarchy=ph, crystal_symmetry=cs, select_within_radius=10.0).ph_super_sphere run(expansion, core=[1, 2])