Author: bugman Date: Thu Apr 3 19:33:15 2014 New Revision: 22629 URL: http://svn.gna.org/viewcvs/relax?rev=22629&view=rev Log: Merged revisions 22047-22048 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/branches/double_rotor ........ r22047 | bugman | 2014-01-24 16:39:29 +0100 (Fri, 24 Jan 2014) | 7 lines Created a simple double rotor geometric system to used for this frame order test data generation. The system_create.py script creates the geometric system based on the CoMs of both domains in the parent directory and two perpendicular rotation axes passing through both CoMs. A PDB file of the representation is created by the script. ........ r22048 | bugman | 2014-01-27 15:58:22 +0100 (Mon, 27 Jan 2014) | 8 lines 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. ........ Added: trunk/test_suite/shared_data/frame_order/cam/double_rotor/system.bz2 - copied unchanged from r22048, branches/double_rotor/test_suite/shared_data/frame_order/cam/double_rotor/system.bz2 trunk/test_suite/shared_data/frame_order/cam/double_rotor/system.pdb - copied unchanged from r22048, branches/double_rotor/test_suite/shared_data/frame_order/cam/double_rotor/system.pdb trunk/test_suite/shared_data/frame_order/cam/double_rotor/system_create.log - copied unchanged from r22048, branches/double_rotor/test_suite/shared_data/frame_order/cam/double_rotor/system_create.log trunk/test_suite/shared_data/frame_order/cam/double_rotor/system_create.py - copied unchanged from r22048, branches/double_rotor/test_suite/shared_data/frame_order/cam/double_rotor/system_create.py Modified: trunk/ (props changed) trunk/test_suite/shared_data/frame_order/cam/generate_base.py Propchange: trunk/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Thu Apr 3 19:33:15 2014 @@ -1 +1 @@ -/branches/double_rotor:1-21950,22022-22023,22039-22040 +/branches/double_rotor:1-21950,22022-22023,22039-22040,22047-22048 Modified: trunk/test_suite/shared_data/frame_order/cam/generate_base.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/shared_data/frame_order/cam/generate_base.py?rev=22629&r1=22628&r2=22629&view=diff ============================================================================== --- trunk/test_suite/shared_data/frame_order/cam/generate_base.py (original) +++ trunk/test_suite/shared_data/frame_order/cam/generate_base.py Thu Apr 3 19:33:15 2014 @@ -30,7 +30,7 @@ import sys # relax module imports. -from lib.check_types import float16 +from lib.check_types import float16, is_float from lib.frame_order.format import print_frame_order_2nd_degree from lib.geometry.angles import wrap_angles from lib.geometry.coord_transform import cartesian_to_spherical @@ -44,107 +44,118 @@ class Main: - # The pivot and CoM for the CaM system. - PIVOT = array([ 37.254, 0.5, 16.7465]) - COM = array([ 26.83678091, -12.37906417, 28.34154128]) - - # The PDB distribution flag. - DIST_PDB = False - - def run(self, save_path=None): - """Generate the distribution and alignment data. - - @keyword save_path: The path to place the files into. If set to None, then the current path will be used. - @type save_path: None or str - """ - - # The paths to the files. - self.path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam'+sep - self.save_path = save_path - if self.save_path == None: - self.save_path = getcwd() - - # Load the interpreter. - self.interpreter = Interpreter(show_script=False, raise_relax_error=True) - self.interpreter.populate_self() - self.interpreter.on(verbose=False) - - # Build the axis system. - self.build_axes() - self._print_axis_system() - self.axes_to_pdb() - - # Create the distribution. - self._create_distribution() - - # Back-calculate the RDCs and PCSs. - self._back_calc() - - # Save a state file for debugging. - self.interpreter.state.save('generate_distribution', dir=self.save_path, force=True) - - - def _back_calc(self): - """Calculate the RDCs and PCSs expected for the structural distribution.""" - - # Load the tensors. - self.interpreter.script(self.path+'tensors.py') - - # Set up the model. - self.interpreter.n_state_model.select_model(model='fixed') - self.interpreter.n_state_model.number_of_states(self.N) - - # Set the paramagnetic centre. - self.interpreter.paramag.centre(pos=[35.934, 12.194, -4.206]) - - # Loop over the alignments. - tensors = ['dy', 'tb', 'tm', 'er'] - for i in range(len(tensors)): - # The tag. - tag = tensors[i] - - # The temperature and field strength. - self.interpreter.spectrometer.temperature(id=tag, temp=303) - self.interpreter.spectrometer.frequency(id=tag, frq=900e6) - - # Back-calculate the data. - self.interpreter.rdc.back_calc(tag) - self.interpreter.pcs.back_calc(tag) - - # Set 1 Hz and 0.1 ppm errors on all data. - for spin in spin_loop(): - # Init. - if not hasattr(spin, 'rdc_err'): - spin.rdc_err = {} - if not hasattr(spin, 'pcs_err'): - spin.pcs_err = {} - - # Set the errors. - spin.rdc_err[tag] = 1.0 - spin.pcs_err[tag] = 0.1 - - # Write the data. - self.interpreter.rdc.write(align_id=tag, file='rdc_%s.txt'%tensors[i], dir=self.save_path, bc=True, force=True) - self.interpreter.pcs.write(align_id=tag, file='pcs_%s.txt'%tensors[i], dir=self.save_path, bc=True, force=True) - - # Store the state. - self.interpreter.state.save('back_calc', dir=self.save_path, force=True) - - - def _backup_pos(self): - """Back up the positional data prior to the rotations.""" - - # Store and then reinitalise the atomic position. +# The pivot and CoM for the CaM system. +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 + +def run(self, save_path=None): + """Generate the distribution and alignment data. + + @keyword save_path: The path to place the files into. If set to None, then the current path will be used. + @type save_path: None or str + """ + + # The paths to the files. + self.path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam'+sep + self.save_path = save_path + if self.save_path == None: + self.save_path = getcwd() + + # Load the interpreter. + self.interpreter = Interpreter(show_script=False, raise_relax_error=True) + self.interpreter.populate_self() + self.interpreter.on(verbose=False) + + # Build the axis system. + self.build_axes() + self.print_axis_system() + self.axes_to_pdb() + + # Create the distribution. + self._multi_system() + self._create_distribution() + + # Back-calculate the RDCs and PCSs. + self._back_calc() + + # Save a state file for debugging. + self.interpreter.state.save('generate_distribution', dir=self.save_path, force=True) + + +def _back_calc(self): + """Calculate the RDCs and PCSs expected for the structural distribution.""" + + # Load the tensors. + self.interpreter.script(self.path+'tensors.py') + + # Set up the model. + self.interpreter.n_state_model.select_model(model='fixed') + self.interpreter.n_state_model.number_of_states(self.N) + + # Set the paramagnetic centre. + self.interpreter.paramag.centre(pos=[35.934, 12.194, -4.206]) + + # Loop over the alignments. + tensors = ['dy', 'tb', 'tm', 'er'] + for i in range(len(tensors)): + # The tag. + tag = tensors[i] + + # The temperature and field strength. + self.interpreter.spectrometer.temperature(id=tag, temp=303) + self.interpreter.spectrometer.frequency(id=tag, frq=900e6) + + # Back-calculate the data. + self.interpreter.rdc.back_calc(tag) + self.interpreter.pcs.back_calc(tag) + + # Set 1 Hz and 0.1 ppm errors on all data. for spin in spin_loop(): - if hasattr(spin, 'pos'): - spin.orig_pos = array(spin.pos, float16) - spin.pos = zeros((self.N, 3), float16) + # Init. + if not hasattr(spin, 'rdc_err'): + spin.rdc_err = {} + if not hasattr(spin, 'pcs_err'): + spin.pcs_err = {} + + # Set the errors. + spin.rdc_err[tag] = 1.0 + spin.pcs_err[tag] = 0.1 + + # Write the data. + self.interpreter.rdc.write(align_id=tag, file='rdc_%s.txt'%tensors[i], dir=self.save_path, bc=True, force=True) + self.interpreter.pcs.write(align_id=tag, file='pcs_%s.txt'%tensors[i], dir=self.save_path, bc=True, force=True) + + # Store the state. + self.interpreter.state.save('back_calc', dir=self.save_path, force=True) + + +def _backup_pos(self): + """Back up the positional data prior to the rotations.""" + + # Store and then reinitalise the atomic position. + for spin in spin_loop(): + if hasattr(spin, 'pos'): + spin.orig_pos = array(spin.pos, 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): @@ -182,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') @@ -233,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') @@ -268,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).""" @@ -282,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): @@ -328,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):