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
Hi Nicholas, First, the most basic way to calculate torsion (dihedral) angle for 4 given atoms is: from scitbx.math import dihedral_angle angle = 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_threes pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_cart = pdb_h.atoms().extract_xyz() # Note that this is a generator for 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_proxies dih_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 sys from scitbx.math import dihedral_angle import iotbx.pdb import os.path def basics(): print "Basics:" angle = dihedral_angle(sites=[(1,0,0), (0,0,0), (0,1,0), (1,1,0)], deg=True) print "Angle:", angle angle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=True) print "Angle in degrees:", angle angle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=False) print "Angle in radians:", angle print "="*50 def advanced(args): print "Advanced phi-psi:" if len(args) != 1 or not os.path.isfile(args[0]): print "Bad argument" return # phi-psi angles from mmtbx.conformation_dependent_library import generate_protein_threes pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_cart = pdb_h.atoms().extract_xyz() n_proxies = 0 # Note that this is a generator for 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 += 1 print "Total angles:", n_proxies def 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_proxies pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_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 < [email protected]> 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 [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
PS.
Please note, that for some of the features mentioned you will need the
latest cctbx version, preferably fresh check-out from svn.
Oleg.
On Mon, Sep 21, 2015 at 9:49 AM, Oleg Sobolev
Hi Nicholas,
First, the most basic way to calculate torsion (dihedral) angle for 4 given atoms is: from scitbx.math import dihedral_angle angle = 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_threes pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_cart = pdb_h.atoms().extract_xyz() # Note that this is a generator for 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_proxies dih_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 sys from scitbx.math import dihedral_angle import iotbx.pdb import os.path
def basics(): print "Basics:" angle = dihedral_angle(sites=[(1,0,0), (0,0,0), (0,1,0), (1,1,0)], deg=True) print "Angle:", angle angle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=True) print "Angle in degrees:", angle angle = dihedral_angle(sites=[(2,1,1), (0,0,0), (0,1,0), (1,1,0)], deg=False) print "Angle in radians:", angle print "="*50
def advanced(args): print "Advanced phi-psi:" if len(args) != 1 or not os.path.isfile(args[0]): print "Bad argument" return
# phi-psi angles from mmtbx.conformation_dependent_library import generate_protein_threes pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_cart = pdb_h.atoms().extract_xyz() n_proxies = 0 # Note that this is a generator for 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 += 1 print "Total angles:", n_proxies
def 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_proxies
pdb_h = iotbx.pdb.hierarchy.input(file_name=args[0]).hierarchy sites_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 < [email protected]> 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 [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
participants (2)
-
Nicholas Pearce
-
Oleg Sobolev