def generate_protein_fragments( hierarchy, geometry, backbone_only=False, use_capping_hydrogens=False, verbose=False, ): from mmtbx.conformation_dependent_library.multi_residue_class import \ ThreeProteinResidues, RestraintsRegistry registry = RestraintsRegistry() threes = ThreeProteinResidues(geometry, registry=registry) for residue in generate_residues_via_conformer( hierarchy, backbone_only=backbone_only, verbose=verbose, ): list.append(threes, residue) if verbose: print 'THREE', threes sub_unit = threes.provide_second_sub_unit_if_unlinked() if verbose: print 'THREE, SUBUNIT', threes, sub_unit if sub_unit: threes.start = True threes.end = True yield threes threes = sub_unit threes.start = True threes.end = True yield threes
def generate_protein_threes( hierarchy, geometry, include_non_linked=False, omega_cdl=False, backbone_only=True, include_non_standard_peptides=False, verbose=False, ): peptide_lookup = ['common_amino_acid'] if include_non_standard_peptides: peptide_lookup.append('modified_amino_acid') backbone_asc = hierarchy.atom_selection_cache() backbone_sel = backbone_asc.selection( "name ca or name c or name n or name o or name cb") backbone_hierarchy = hierarchy.select(backbone_sel) get_class = iotbx.pdb.common_residue_names_get_class threes = ThreeProteinResidues(geometry, registry=registry) loop_hierarchy = hierarchy if backbone_only: loop_hierarchy = backbone_hierarchy for model in loop_hierarchy.models(): if verbose: print 'model: "%s"' % model.id for chain in model.chains(): if verbose: print 'chain: "%s"' % chain.id for conformer in chain.conformers(): if verbose: print ' conformer: altloc="%s"' % (conformer.altloc) while threes: del threes[0] threes.start = None threes.end = None list_of_threes = [] for residue in conformer.residues(): if verbose: if residue.resname not in ["HOH"]: print ' residue: resname="%s" resid="%s"' % ( residue.resname, residue.resid()) if verbose: print ' residue class : %s' % get_class( residue.resname) if get_class(residue.resname) not in peptide_lookup: continue if include_non_linked: list.append(threes, residue) if len(threes) > 3: del threes[0] else: threes.append(residue) if len(threes) != 3: if omega_cdl: if len(threes) == 2: threes.insert(0, None) else: continue else: continue assert len(threes) <= 3 list_of_threes.append(copy.copy(threes)) # per conformer for i, threes in enumerate(list_of_threes): if i == 0: threes.start = True if i == len(list_of_threes) - 1: threes.end = True else: if len(threes) != 3: pass elif threes[1] != list_of_threes[i + 1][0]: threes.end = True list_of_threes[i + 1].start = True yield threes threes = ThreeProteinResidues(geometry, registry=registry)
def backrub_move( prev_res, cur_res, next_res, angle, move_oxygens=False, accept_worse_rama=False, rotamer_manager=None, rama_manager=None): import boost.python ext = boost.python.import_ext("mmtbx_validation_ramachandran_ext") from mmtbx_validation_ramachandran_ext import rama_eval from scitbx.matrix import rotate_point_around_axis from mmtbx.conformation_dependent_library.multi_residue_class import ThreeProteinResidues, \ RestraintsRegistry if abs(angle) < 1e-4: return if prev_res is None or next_res is None: return saved_res = [{},{},{}] for i, r in enumerate([prev_res, cur_res, next_res]): for a in r.atoms(): saved_res[i][a.name.strip()] = a.xyz if rotamer_manager is None: rotamer_manager = RotamerEval() prev_ca = prev_res.find_atom_by(name=" CA ") cur_ca = cur_res.find_atom_by(name=" CA ") next_ca = next_res.find_atom_by(name=" CA ") if prev_ca is None or next_ca is None or cur_ca is None: return atoms_to_move = [] atoms_to_move.append(prev_res.find_atom_by(name=" C ")) atoms_to_move.append(prev_res.find_atom_by(name=" O ")) for atom in cur_res.atoms(): atoms_to_move.append(atom) atoms_to_move.append(next_res.find_atom_by(name=" N ")) for atom in atoms_to_move: assert atom is not None new_xyz = rotate_point_around_axis( axis_point_1 = prev_ca.xyz, axis_point_2 = next_ca.xyz, point = atom.xyz, angle = angle, deg = True) atom.xyz = new_xyz if move_oxygens: registry = RestraintsRegistry() if rama_manager is None: rama_manager = rama_eval() tpr = ThreeProteinResidues(geometry=None, registry=registry) tpr.append(prev_res) tpr.append(cur_res) tpr.append(next_res) phi_psi_angles = tpr.get_phi_psi_angles() rama_key = tpr.get_ramalyze_key() ev_before = rama_manager.evaluate_angles(rama_key, phi_psi_angles[0], phi_psi_angles[1]) theta1 = _find_theta( ap1 = prev_ca.xyz, ap2 = cur_ca.xyz, cur_xyz = prev_res.find_atom_by(name=" O ").xyz, needed_xyz = saved_res[0]["O"]) theta2 = _find_theta( ap1 = cur_ca.xyz, ap2 = next_ca.xyz, cur_xyz = cur_res.find_atom_by(name=" O ").xyz, needed_xyz = saved_res[1]["O"]) for a in [prev_res.find_atom_by(name=" C "), prev_res.find_atom_by(name=" O "), cur_res.find_atom_by(name=" C ")]: new_xyz = rotate_point_around_axis( axis_point_1 = prev_ca.xyz, axis_point_2 = cur_ca.xyz, point = a.xyz, angle = theta1, deg = True) a.xyz = new_xyz for a in [cur_res.find_atom_by(name=" C "), cur_res.find_atom_by(name=" O "), next_res.find_atom_by(name=" N ")]: new_xyz = rotate_point_around_axis( axis_point_1 = cur_ca.xyz, axis_point_2 = next_ca.xyz, point = a.xyz, angle = theta2, deg = True) a.xyz = new_xyz phi_psi_angles = tpr.get_phi_psi_angles() rama_key = tpr.get_ramalyze_key() ev_after = rama_manager.evaluate_angles(rama_key, phi_psi_angles[0], phi_psi_angles[1]) if ev_before > ev_after and not accept_worse_rama: for a in [prev_res.find_atom_by(name=" C "), prev_res.find_atom_by(name=" O "), cur_res.find_atom_by(name=" C ")]: new_xyz = rotate_point_around_axis( axis_point_1 = prev_ca.xyz, axis_point_2 = cur_ca.xyz, point = a.xyz, angle = -theta1, deg = True) a.xyz = new_xyz for a in [cur_res.find_atom_by(name=" C "), cur_res.find_atom_by(name=" O "), next_res.find_atom_by(name=" N ")]: new_xyz = rotate_point_around_axis( axis_point_1 = cur_ca.xyz, axis_point_2 = next_ca.xyz, point = a.xyz, angle = -theta2, deg = True) a.xyz = new_xyz
def generate_protein_threes(hierarchy, geometry, include_non_linked=False, omega_cdl=False, backbone_only=True, verbose=False, ): backbone_asc = hierarchy.atom_selection_cache() backbone_sel = backbone_asc.selection("name ca or name c or name n or name o or name cb") backbone_hierarchy = hierarchy.select(backbone_sel) get_class = iotbx.pdb.common_residue_names_get_class threes = ThreeProteinResidues(geometry, registry=registry) loop_hierarchy=hierarchy if backbone_only: loop_hierarchy=backbone_hierarchy for model in loop_hierarchy.models(): if verbose: print 'model: "%s"' % model.id for chain in model.chains(): if verbose: print 'chain: "%s"' % chain.id for conformer in chain.conformers(): if verbose: print ' conformer: altloc="%s"' % ( conformer.altloc) while threes: del threes[0] threes.start=None threes.end=None list_of_threes = [] for residue in conformer.residues(): if verbose: if residue.resname not in ["HOH"]: print ' residue: resname="%s" resid="%s"' % ( residue.resname, residue.resid()) if verbose: print ' residue class : %s' % get_class(residue.resname) if get_class(residue.resname) not in ["common_amino_acid"]: continue if include_non_linked: list.append(threes, residue) if len(threes)>3: del threes[0] else: threes.append(residue) if len(threes)!=3: if omega_cdl: if len(threes)==2: threes.insert(0,None) else: continue else: continue assert len(threes)<=3 list_of_threes.append(copy.copy(threes)) # per conformer for i, threes in enumerate(list_of_threes): if i==0: threes.start = True if i==len(list_of_threes)-1: threes.end = True else: if len(threes)!=3: pass elif threes[1] != list_of_threes[i+1][0]: threes.end = True list_of_threes[i+1].start = True yield threes threes = ThreeProteinResidues(geometry, registry=registry)