Пример #1
0
 def generate_ca(self):
     t0 = time.time()
     self.hierarchy.reset_atom_i_seqs()
     self.hierarchy.reset_i_seq_if_necessary()
     for five in generate_protein_fragments(
             self.hierarchy, self.geometry_restraints_manager, length=5):
         rc = []
         for atom in five.atoms():
             if atom.name == ' CA ':
                 rc.append(atom)
         if len(rc) == 5:
             yield rc
Пример #2
0
 def generate_ca(self, length=5):
   """
   Geting all C-alpha atoms from an whole pdb file.
   """
   # faster with atom selection to CA re CJW update
   protain_fragments = generate_protein_fragments(
     hierarchy = self.chain_hierarchy,
     geometry = self.geometry_restraints_manager,
     include_non_standard_peptides=True,
     length=length)
   for five in protain_fragments:
     rc = []
     for residue in five:
       for atom in residue.atoms():
         if atom.name == ' CA ':
           rc.append(atom)
     if len(rc) == length:
       yield rc
Пример #3
0
def count_residue_sets(pdb_hierarchy=None, length=3, allow_poly_ca=False):
    count = 0
    resnames = []
    for residue_set in generate_protein_fragments(
            hierarchy=pdb_hierarchy,
            geometry=None,
            length=length,
            include_non_linked=False,
            backbone_only=True,
            include_non_standard_peptides=True,
            allow_poly_ca=allow_poly_ca,
            verbose=False):
        count += 1
        #resnames = []
        #for res in residue_set:
        #  resnames.append(res.resname+res.resseq)
        #resstring = '-'.join(resnames)
        #print(resstring)
    #print(count)
    return count
Пример #4
0

if __name__ == "__main__":
    import sys
    from iotbx import pdb
    from tst_rdl import get_geometry_restraints_manager
    filename = sys.argv[1]
    pdb_inp = pdb.input(filename)
    pdb_hierarchy = pdb_inp.construct_hierarchy()
    geometry_restraints_manager = get_geometry_restraints_manager(filename)
    pdb_hierarchy.reset_i_seq_if_necessary()
    from mmtbx.conformation_dependent_library import generate_protein_fragments
    for i in range(2, 6):
        for threes in generate_protein_fragments(
                pdb_hierarchy,
                geometry_restraints_manager,
                length=i,
                #verbose=verbose,
        ):
            print threes
            try:
                print '  omega   %5.1f' % threes.get_omega_value()
            except:
                print '  omega is not valid'  # intentional
            print '  omegas  %s' % threes.get_omega_values()
            try:
                print "  cis?    %-5s %s" % (threes.cis_group(),
                                             threes.cis_group(limit=30))
            except:
                print '  cis? is not valid'  # intentional
            try:
                print "  trans?  %-5s %s" % (threes.trans_group(),
Пример #5
0
    def __init__(self,
                 pdb_hierarchy,
                 nontrans_only=False,
                 out=sys.stdout,
                 quiet=True):
        validation.__init__(self)
        self.residue_count = [0, 0]
        #[OMEGA_GENERAL, OMEGA_PRO]
        self.omega_count = [[0, 0, 0], [0, 0, 0]]
        #[OMEGA_GENERAL, OMEGA_PRO], then
        #[OMEGALYZE_TRANS, OMEGALYZE_CIS, OMEGALYZE_TWISTED]

        from mmtbx.validation import utils
        from scitbx.array_family import flex
        self._outlier_i_seqs = flex.size_t()
        pdb_atoms = pdb_hierarchy.atoms()
        all_i_seqs = pdb_atoms.extract_i_seq()
        if all_i_seqs.all_eq(0):
            pdb_atoms.reset_i_seq()
        use_segids = utils.use_segids_in_place_of_chainids(
            hierarchy=pdb_hierarchy)

        first_conf_altloc = None
        prev_chain_id = None
        for twores in generate_protein_fragments(
                pdb_hierarchy,
                length=2,
                geometry=None,
                include_non_standard_peptides=True):
            main_residue = twores[
                1]  #this is the relevant residue for id-ing cis-Pro
            conf_altloc = get_conformer_altloc(twores)
            prevres_altloc, mainres_altloc = get_local_omega_altlocs(twores)
            twores_altloc = prevres_altloc or mainres_altloc  #default '' evals False

            chain = main_residue.parent().parent()
            if use_segids:
                chain_id = utils.get_segid_as_chainid(chain=chain)
            else:
                chain_id = chain.id

            if chain_id != prev_chain_id:  #if we've moved to a new chain...
                first_conf_altloc = conf_altloc  #...reset reference altloc
                prev_chain_id = chain_id
            if (conf_altloc != first_conf_altloc) and twores_altloc == '':
                #skip non-alternate residues unless this is the first time thru a chain
                continue
            omega_atoms = get_omega_atoms(twores)
            #omega_atoms is the list [CA1 C1 N2 CA2], with None for missing atoms
            if None in omega_atoms:
                continue
            omega = get_omega(omega_atoms)
            if omega is None: continue
            omega_type = find_omega_type(omega)
            if omega_type == OMEGALYZE_TRANS:
                is_nontrans = False
            else:
                is_nontrans = True
                self.n_outliers += 1
            if main_residue.resname == "PRO": res_type = OMEGA_PRO
            else: res_type = OMEGA_GENERAL
            self.residue_count[res_type] += 1
            self.omega_count[res_type][omega_type] += 1
            highest_mc_b = get_highest_mc_b(twores[0].atoms(),
                                            twores[1].atoms())
            coords = get_center(main_residue)
            markup_atoms = []
            for omega_atom in omega_atoms:
                markup_atoms.append(
                    kin_atom(omega_atom.parent().id_str(), omega_atom.xyz))

            result = omega_result(
                model_id=twores[0].parent().parent().parent().id,
                chain_id=chain_id,
                resseq=main_residue.resseq,
                icode=main_residue.icode,
                resname=main_residue.resname,
                altloc=mainres_altloc,
                prev_resseq=twores[0].resseq,
                prev_icode=twores[0].icode,
                prev_resname=twores[0].resname,
                prev_altloc=prevres_altloc,
                segid=None,
                omega=omega,
                omega_type=omega_type,
                res_type=res_type,
                is_nontrans=is_nontrans,
                outlier=is_nontrans,
                highest_mc_b=highest_mc_b,
                xyz=coords,
                markup_atoms=markup_atoms)

            if is_nontrans or not nontrans_only:  #(not nontrans_only or is_nontrans)
                self.results.append(result)
            if is_nontrans:
                i_seqs = main_residue.atoms().extract_i_seq()
                assert (not i_seqs.all_eq(0)
                        )  #This assert copied from ramalyze
                self._outlier_i_seqs.extend(i_seqs)
            self.results.sort(key=lambda x: x.model_id + ':' + x.id_str())
Пример #6
0
def main():
    pdb_inp = pdb.input(lines=model_1yjp, source_info='model_1yjp')
    pdb_hierarchy = pdb_inp.construct_hierarchy()
    geometry_restraints_manager = get_geometry_restraints_manager(
        raw_records=model_1yjp)
    pdb_hierarchy.reset_i_seq_if_necessary()
    from mmtbx.conformation_dependent_library import generate_protein_fragments
    for k in range(2, 6):
        for j, threes in enumerate(
                generate_protein_fragments(
                    pdb_hierarchy,
                    geometry_restraints_manager,
                    length=k,
                    #verbose=verbose,
                )):
            i = k - 2
            print(i, j, k, threes)
            rc = None
            try:
                rc = threes.get_omega_value()
            except:
                print('  omega is not valid')  # intentional
            if i > 0: assert rc == None
            else:
                print('  omega   %5.1f' % rc)
                assert approx_equal(
                    rc, answers['omegas'][j],
                    0.1), '%f != %f' % (rc, answers['omegas'][j])
            rc = threes.get_omega_values()
            print('  omegas  %s' % rc)
            assert approx_equal(rc,
                                answers['omegas'][j:j + i + 1]), '%s != %s' % (
                                    rc, answers['omegas'][j:j + i + 1])
            rc = None
            try:
                rc = threes.cis_group()
            except:
                pass  # intentional
            try:
                print("  cis?    %-5s %s" % (rc, threes.cis_group(limit=30)))
            except:
                print('  cis? is not valid')  # intentional
            if i >= 2:
                assert (rc == None or rc == False), '%s!=%s' % (rc, None)
            else:
                assert rc == False
            try:
                print("  trans?  %-5s %s" %
                      (threes.trans_group(), threes.trans_group(limit=30)))
            except:
                print('  tran? is not valid')  # intentional
            print('  cis/trans/twisted? %s' %
                  ' '.join(threes.cis_trans_twisted_list()))
            try:
                print("  rama    %s" % threes.get_ramalyze_key())
            except:
                print('  rama not specified')  # intentional
            print('  conf    %s' % threes.is_pure_main_conf())
            rc = None
            try:
                rc = threes.get_phi_psi_angles()
            except:
                print('  phi/psi not specified')  # intentional
            print('  phi/psi %s' % rc)
            if i < 1: assert rc == None
            else:
                test = answers['phi_psi'][j * 2:(j + i) * 2]
                assert approx_equal(rc[0], test[0]), '%s!=%s' % (rc, test)
                assert approx_equal(rc[1], test[1]), '%s!=%s' % (rc, test)
            rc = None
            try:
                rc = threes.get_ca_dihedrals()
            except:
                print('  CA dihedrals not specified')  # intentional
            print('  CA dihedrals %s' % rc)
            if i <= 1: assert rc == None
            else:
                test = answers['calphas'][j:j + i + 1 - 2]
                assert approx_equal(rc[0], test[0]), '%s != %s' % (rc, test)

        print("OK", i + 2)