Hi Nicholas,First, the most basic way to calculate torsion (dihedral) angle for 4 given atoms is:from scitbx.math import dihedral_angleangle = dihedral_angle(sites=[(1,0,0), (0,0,0), (0,1,0), (1,1,0)], deg=True)where 'sites' contain atom coordinates.Second, here is more high-level way to get phi-psi angles:from mmtbx.conformation_dependent_library import generate_protein_threespdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchysites_cart = pdb_h.atoms().extract_xyz()# Note that this is a generatorfor three in generate_protein_threes(hierarchy=pdb_h,geometry=None):proxies = three.get_dummy_dihedral_proxies()for p in proxies:print "angle=", dihedral_angle(sites=[sites_cart[x] for x in p.i_seqs],deg=True)Third, to get all proxies, use this function with hierarchy:from mmtbx.geometry_restraints.torsion_restraints.utils import \get_complete_dihedral_proxiesdih_proxies = get_complete_dihedral_proxies(pdb_hierarchy=pdb_h)Hope this helps, full script is below and attached (run with pdb file as the only argument).Best regards,Oleg Sobolev.import sysfrom scitbx.math import dihedral_angleimport iotbx.pdbimport os.pathdef basics():print "Basics:"angle = dihedral_angle(sites=[(1,0,0), (0,0,0), (0,1,0), (1,1,0)], deg=True)print "Angle:", angleangle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=True)print "Angle in degrees:", angleangle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=False)print "Angle in radians:", angleprint "="*50def advanced(args):print "Advanced phi-psi:"if len(args) != 1 or not os.path.isfile(args[0]):print "Bad argument"return# phi-psi anglesfrom mmtbx.conformation_dependent_library import generate_protein_threespdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchysites_cart = pdb_h.atoms().extract_xyz()n_proxies = 0# Note that this is a generatorfor three in generate_protein_threes(hierarchy=pdb_h,geometry=None):proxies = three.get_dummy_dihedral_proxies()for p in proxies:for i_seq in p.i_seqs:print pdb_h.atoms()[i_seq].id_str(),print "angle=", dihedral_angle(sites=[sites_cart[x] for x in p.i_seqs],deg=True)n_proxies += 1print "Total angles:", n_proxiesdef all_dihedral_proxies(args):print "Advanced all:"if len(args) != 1 or not os.path.isfile(args[0]):print "Bad argument"return# all angles:from mmtbx.geometry_restraints.torsion_restraints.utils import \get_complete_dihedral_proxiespdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchysites_cart = pdb_h.atoms().extract_xyz()dih_proxies = get_complete_dihedral_proxies(pdb_hierarchy=pdb_h)for p in dih_proxies:for i_seq in p.i_seqs:print pdb_h.atoms()[i_seq].id_str(),print "angle=", dihedral_angle(sites=[sites_cart[x] for x in p.i_seqs],deg=True)print "Total angles:", dih_proxies.size()def run(args):basics()advanced(args)all_dihedral_proxies(args)if (__name__ == "__main__"):run(sys.argv[1:])On Sun, Sep 20, 2015 at 3:30 PM, Nicholas Pearce <nicholas.pearce@stx.ox.ac.uk> wrote:Hi Everyone,
Phenomenally stupid question, but is there an easy way to calculate phi-psi angles for a protein using cctbx? And, following on from that, Chi-1, Chi-2 etc angles?
I’ve had a poke around, but couldn’t find any obvious (at least to me) way that worked…
I presume this must be implemented rigorously somewhere, and I didn’t want to waste time reimplementing the wheel.
Thanks,
Nick
_______________________________________________
cctbxbb mailing list
cctbxbb@phenix-online.org
http://phenix-online.org/mailman/listinfo/cctbxbb