mailr22048 - /branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 27, 2014 - 15:58:
Author: bugman
Date: Mon Jan 27 15:58:22 2014
New Revision: 22048

URL: http://svn.gna.org/viewcvs/relax?rev=22048&view=rev
Log:
Improvements and expansion of the frame order test data generation base 
script.

More of the class variables are now defined in this base class and dummy 
methods are provided to
allow certain operations to be skipped (print_axis_system(), axes_to_pdb() 
and build_axes()).
Importantly, the script can now handle multiple modes of motion with the 
introduction of the key
_multi_system() and _state_loop() methods.


Modified:
    
branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py

Modified: 
branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py?rev=22048&r1=22047&r2=22048&view=diff
==============================================================================
--- 
branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py 
(original)
+++ 
branches/double_rotor/test_suite/shared_data/frame_order/cam/generate_base.py 
Mon Jan 27 15:58:22 2014
@@ -30,6 +30,7 @@
 import sys
 
 # relax module imports.
+from lib.check_types import is_float
 from lib.frame_order.format import print_frame_order_2nd_degree
 from lib.geometry.coord_transform import cartesian_to_spherical
 from lib.geometry.rotations import axis_angle_to_R, R_to_euler_zyz
@@ -47,6 +48,16 @@
     PIVOT = array([ 37.254, 0.5, 16.7465])
     COM = array([ 26.83678091, -12.37906417,  28.34154128])
 
+    # The number of rotation modes.
+    MODES = 1
+
+    # The number of states for each rotation mode.
+    N = 100
+
+    # The tilt angles.
+    TILT_ANGLE = 0
+    INC = 0
+
     # The PDB distribution flag.
     DIST_PDB = False
 
@@ -70,10 +81,11 @@
 
         # Build the axis system.
         self.build_axes()
-        self._print_axis_system()
+        self.print_axis_system()
         self.axes_to_pdb()
 
         # Create the distribution.
+        self._multi_system()
         self._create_distribution()
 
         # Back-calculate the RDCs and PCSs.
@@ -137,13 +149,13 @@
         for spin in spin_loop():
             if hasattr(spin, 'pos'):
                 spin.orig_pos = array(spin.pos, float16)
-                spin.pos = zeros((self.N, 3), float16)
+                spin.pos = zeros((self.N**self.MODES, 3), float16)
 
         # Store and then reinitalise the bond vector.
         for interatom in interatomic_loop():
             if hasattr(interatom, 'vector'):
                 interatom.orig_vect = array(interatom.vector, float16)
-                interatom.vector = zeros((self.N, 3), float16)
+                interatom.vector = zeros((self.N**self.MODES, 3), float16)
 
 
     def _create_distribution(self):
@@ -181,40 +193,44 @@
 
         # Load N copies of the original C-domain.
         if self.DIST_PDB:
-            # Loop over the N states.
-            for i in range(self.N):
+            # Loop over each position.
+            for global_index, mode_indices in self._state_loop():
                 # Load the structure for the PDB distribution.
-                self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', 
dir=self.path, set_mol_name='C-dom', set_model_num=i+1)
-
-        # Loop over the N states.
+                self.interpreter.structure.read_pdb('1J7P_1st_NH.pdb', 
dir=self.path, set_mol_name='C-dom', set_model_num=global_index+1)
+
+        # Turn off the relax interpreter echoing to allow the progress meter 
to be shown correctly.
         self.interpreter.off()
-        for i in range(self.N):
-            # Print out.
-            self._progress(i)
-
-            # Generate the distribution specific rotation.
-            self.rotation(i)
-
-            # Rotate the atomic position.
-            for spin in spin_loop():
-                if hasattr(spin, 'pos'):
-                    spin.pos[i] = dot(self.R, (spin.orig_pos[0] - 
self.PIVOT)) + self.PIVOT
-
-            # Rotate the NH vector.
-            for interatom in interatomic_loop():
-                if hasattr(interatom, 'vector'):
-                    interatom.vector[i] = dot(self.R, interatom.orig_vect)
-
-            # Decompose the rotation into Euler angles and store them.
-            a, b, g = R_to_euler_zyz(self.R)
-            rot_file.write('%10.7f %10.7f %10.7f\n' % (a, b, g))
-
-            # The frame order matrix component.
-            self.daeg += kron_prod(self.R, self.R)
-
-            # Rotate the structure for the PDB distribution.
-            if self.DIST_PDB:
-                self.interpreter.structure.rotate(R=self.R, 
origin=self.PIVOT, model=i+1)
+
+        # Loop over each position.
+        for global_index, mode_indices in self._state_loop():
+            # The progress meter.
+            self._progress(global_index)
+
+            # Loop over each motional mode.
+            for motion_index in range(self.MODES):
+                # Generate the distribution specific rotation.
+                self.rotation(mode_indices[motion_index], 
motion_index=motion_index)
+
+                # Rotate the atomic position.
+                for spin in spin_loop():
+                    if hasattr(spin, 'pos'):
+                        spin.pos[global_index] = dot(self.R, 
(spin.orig_pos[0] - self.PIVOT[motion_index])) + self.PIVOT[motion_index]
+
+                # Rotate the NH vector.
+                for interatom in interatomic_loop():
+                    if hasattr(interatom, 'vector'):
+                        interatom.vector[global_index] = dot(self.R, 
interatom.orig_vect)
+
+                # Decompose the rotation into Euler angles and store them.
+                a, b, g = R_to_euler_zyz(self.R)
+                rot_file.write('%10.7f %10.7f %10.7f\n' % (a, b, g))
+
+                # The frame order matrix component.
+                self.daeg += kron_prod(self.R, self.R)
+
+                # Rotate the structure for the PDB distribution.
+                if self.DIST_PDB:
+                    self.interpreter.structure.rotate(R=self.R, 
origin=self.PIVOT[motion_index], model=global_index+1)
 
         # Print out.
         sys.stdout.write('\n\n')
@@ -232,8 +248,12 @@
             self.interpreter.structure.write_pdb('distribution.pdb', 
compress_type=2, force=True)
 
 
-    def _print_axis_system(self):
-        """Print out of the full system."""
+    def print_axis_system(self):
+        """Dummy base method for printing out the axis system to a file."""
+
+
+    def print_axis_system_full(self):
+        """Print out of the full system to file."""
 
         # Open the file.
         file = open(self.save_path+sep+'axis_system', 'w')
@@ -267,6 +287,26 @@
         file.write("    phi:   %.20f\n" % wrap_angles(p, 0, 2*pi))
 
 
+    def _multi_system(self):
+        """Convert the angle, pivot and axis data structures for handling 
multiple motional modes."""
+
+        # The tilt angle.
+        if is_float(self.TILT_ANGLE):
+            self.TILT_ANGLE = [self.TILT_ANGLE]
+
+        # The increment value.
+        if is_float(self.INC):
+            self.INC = [self.INC]
+
+        # The pivot.
+        if is_float(self.PIVOT[0]):
+            self.PIVOT = [self.PIVOT]
+
+        # The axis.
+        if is_float(self.axes[0]):
+            self.axes = [self.axes]
+
+
     def _progress(self, i, a=5, b=100):
         """A simple progress write out (which goes to the terminal 
STDERR)."""
 
@@ -281,6 +321,30 @@
         # Dump the progress.
         if i % b == 0:
             sys.stderr.write('\b%i\n' % i)
+
+
+    def _state_loop(self):
+        """Generator method for looping over all states of all motional 
modes.
+
+        @return:    The global index, the list of indices for each mode
+        @rtype:     int, list of int
+        """
+
+        # Single mode.
+        if self.MODES == 1:
+            for i in range(self.N):
+                yield i, [i]
+
+        # Double mode.
+        if self.MODES == 2:
+            global_index = -1
+            for i in range(self.N):
+                for j in range(self.N):
+                    global_index += 1
+                    yield global_index, [i, j]
+
+    def axes_to_pdb(self):
+        """Dummy base method for creating a PDB for the motional axis 
system."""
 
 
     def axes_to_pdb_full(self):
@@ -327,6 +391,10 @@
 
         # Write out the PDB.
         self.interpreter.structure.write_pdb('axis.pdb', dir=self.save_path, 
compress_type=0, force=True)
+
+
+    def build_axes(self):
+        """Dummy base method for creating the axis system."""
 
 
     def build_axes_alt(self):




Related Messages


Powered by MHonArc, Updated Mon Jan 27 19:00:02 2014