Author: bugman
Date: Sun Nov 25 20:28:23 2007
New Revision: 3957

URL: http://svn.gna.org/viewcvs/relax?rev=3957&view=rev
Log:
Converted all the methods of the Angles class into module functions.


Modified:
    1.3/generic_fns/angles.py

Modified: 1.3/generic_fns/angles.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/angles.py?rev=3957&r1=3956&r2=3957&view=diff
==============================================================================
--- 1.3/generic_fns/angles.py (original)
+++ 1.3/generic_fns/angles.py Sun Nov 25 20:28:23 2007
@@ -30,99 +30,91 @@
 
 
 
+def angles(self, run):
+    """Function for calculating the angle defining the XH vector in the 
diffusion frame."""
 
-class Angles:
-    def __init__(self, relax):
-        """Class containing the functions relating to angles."""
+    # Test if the run exists.
+    if not run in relax_data_store.run_names:
+        raise RelaxNoPipeError, run
 
-        self.relax = relax
+    # Test if the PDB file has been loaded.
+    if not relax_data_store.pdb.has_key(run):
+        raise RelaxNoPdbError, run
+
+    # Test if sequence data is loaded.
+    if not relax_data_store.res.has_key(run):
+        raise RelaxNoSequenceError, run
+
+    # Test if the diffusion tensor data is loaded.
+    if not relax_data_store.diff.has_key(run):
+        raise RelaxNoTensorError, run
+
+    # Arguments.
+    self.run = run
+
+    # Sphere.
+    if relax_data_store.diff[self.run].type == 'sphere':
+        return
+
+    # Spheroid.
+    elif relax_data_store.diff[self.run].type == 'spheroid':
+        self.spheroid_frame()
+
+    # Ellipsoid.
+    elif relax_data_store.diff[self.run].type == 'ellipsoid':
+        raise RelaxError, "No coded yet."
 
 
-    def angles(self, run):
-        """Function for calculating the angle defining the XH vector in the 
diffusion frame."""
+def ellipsoid_frame(self):
+    """Function for calculating the spherical angles of the XH vector in the 
ellipsoid frame."""
 
-        # Test if the run exists.
-        if not run in relax_data_store.run_names:
-            raise RelaxNoPipeError, run
+    # Get the unit vectors Dx, Dy, and Dz of the diffusion tensor axes.
+    Dx, Dy, Dz = self.relax.generic.diffusion_tensor.unit_axes()
 
-        # Test if the PDB file has been loaded.
-        if not relax_data_store.pdb.has_key(run):
-            raise RelaxNoPdbError, run
+    # Loop over the sequence.
+    for i in xrange(len(relax_data_store.res[self.run])):
+        # Test if the vector exists.
+        if not hasattr(relax_data_store.res[self.run][i], 'xh_vect'):
+            print "No angles could be calculated for residue '" + 
`relax_data_store.res[self.run][i].num` + " " + 
relax_data_store.res[self.run][i].name + "'."
+            continue
 
-        # Test if sequence data is loaded.
-        if not relax_data_store.res.has_key(run):
-            raise RelaxNoSequenceError, run
+        # dz and dx direction cosines.
+        dz = dot(Dz, relax_data_store.res[self.run][i].xh_vect)
+        dx = dot(Dx, relax_data_store.res[self.run][i].xh_vect)
 
-        # Test if the diffusion tensor data is loaded.
-        if not relax_data_store.diff.has_key(run):
-            raise RelaxNoTensorError, run
+        # Calculate the polar angle theta.
+        relax_data_store.res[self.run][i].theta = acos(dz)
 
-        # Arguments.
-        self.run = run
-
-        # Sphere.
-        if relax_data_store.diff[self.run].type == 'sphere':
-            return
-
-        # Spheroid.
-        elif relax_data_store.diff[self.run].type == 'spheroid':
-            self.spheroid_frame()
-
-        # Ellipsoid.
-        elif relax_data_store.diff[self.run].type == 'ellipsoid':
-            raise RelaxError, "No coded yet."
+        # Calculate the azimuthal angle phi.
+        relax_data_store.res[self.run][i].phi = acos(dx / 
sin(relax_data_store.res[self.run][i].theta))
 
 
-    def ellipsoid_frame(self):
-        """Function for calculating the spherical angles of the XH vector in 
the ellipsoid frame."""
+def spheroid_frame(self):
+    """Function for calculating the angle alpha of the XH vector within the 
spheroid frame."""
 
-        # Get the unit vectors Dx, Dy, and Dz of the diffusion tensor axes.
-        Dx, Dy, Dz = self.relax.generic.diffusion_tensor.unit_axes()
+    # Get the unit vector Dpar of the diffusion tensor axis.
+    Dpar = self.relax.generic.diffusion_tensor.unit_axes()
 
-        # Loop over the sequence.
-        for i in xrange(len(relax_data_store.res[self.run])):
-            # Test if the vector exists.
-            if not hasattr(relax_data_store.res[self.run][i], 'xh_vect'):
-                print "No angles could be calculated for residue '" + 
`relax_data_store.res[self.run][i].num` + " " + 
relax_data_store.res[self.run][i].name + "'."
-                continue
+    # Loop over the sequence.
+    for i in xrange(len(relax_data_store.res[self.run])):
+        # Test if the vector exists.
+        if not hasattr(relax_data_store.res[self.run][i], 'xh_vect'):
+            print "No angles could be calculated for residue '" + 
`relax_data_store.res[self.run][i].num` + " " + 
relax_data_store.res[self.run][i].name + "'."
+            continue
 
-            # dz and dx direction cosines.
-            dz = dot(Dz, relax_data_store.res[self.run][i].xh_vect)
-            dx = dot(Dx, relax_data_store.res[self.run][i].xh_vect)
-
-            # Calculate the polar angle theta.
-            relax_data_store.res[self.run][i].theta = acos(dz)
-
-            # Calculate the azimuthal angle phi.
-            relax_data_store.res[self.run][i].phi = acos(dx / 
sin(relax_data_store.res[self.run][i].theta))
+        # Calculate alpha.
+        relax_data_store.res[self.run][i].alpha = acos(dot(Dpar, 
relax_data_store.res[self.run][i].xh_vect))
 
 
-    def spheroid_frame(self):
-        """Function for calculating the angle alpha of the XH vector within 
the spheroid frame."""
+def wrap_angles(self, angle, lower, upper):
+    """Convert the given angle to be between the lower and upper values."""
 
-        # Get the unit vector Dpar of the diffusion tensor axis.
-        Dpar = self.relax.generic.diffusion_tensor.unit_axes()
+    while 1:
+        if angle > upper:
+            angle = angle - upper
+        elif angle < lower:
+            angle = angle + upper
+        else:
+            break
 
-        # Loop over the sequence.
-        for i in xrange(len(relax_data_store.res[self.run])):
-            # Test if the vector exists.
-            if not hasattr(relax_data_store.res[self.run][i], 'xh_vect'):
-                print "No angles could be calculated for residue '" + 
`relax_data_store.res[self.run][i].num` + " " + 
relax_data_store.res[self.run][i].name + "'."
-                continue
-
-            # Calculate alpha.
-            relax_data_store.res[self.run][i].alpha = acos(dot(Dpar, 
relax_data_store.res[self.run][i].xh_vect))
-
-
-    def wrap_angles(self, angle, lower, upper):
-        """Convert the given angle to be between the lower and upper values."""
-
-        while 1:
-            if angle > upper:
-                angle = angle - upper
-            elif angle < lower:
-                angle = angle + upper
-            else:
-                break
-
-        return angle
+    return angle


_______________________________________________
relax (http://nmr-relax.com)

This is the relax-commits mailing list
relax-commits@gna.org

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to