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)
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)