Author: bugman Date: Tue Aug 3 09:00:27 2010 New Revision: 11387 URL: http://svn.gna.org/viewcvs/relax?rev=11387&view=rev Log: Merged revisions 11381-11385 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r11381 | bugman | 2010-07-28 11:13:46 +0200 (Wed, 28 Jul 2010) | 6 lines Removed the docstring length check from the code validator script and changed a printout. The docstring length is only 100 characters in the user functions. For all other functions, no length is enforced. ........ r11382 | bugman | 2010-07-28 11:38:32 +0200 (Wed, 28 Jul 2010) | 3 lines The attached proton PDB name is no longer hardcoded to 'H' in the dauvergne_protocol auto analysis. ........ r11383 | bugman | 2010-07-29 14:18:18 +0200 (Thu, 29 Jul 2010) | 3 lines The back-calculated alignments tensors are now being stored in the current data pipe. ........ r11384 | bugman | 2010-07-29 16:11:51 +0200 (Thu, 29 Jul 2010) | 3 lines The align_tensor.display() user function now prints out the generalized degree of order (GDO) value. ........ r11385 | bugman | 2010-07-29 17:58:54 +0200 (Thu, 29 Jul 2010) | 3 lines pipe.display() now places quotation marks around the pipe names and shows which is the current data pipe. ........ Modified: branches/bieri_gui/ (props changed) branches/bieri_gui/auto_analyses/dauvergne_protocol.py branches/bieri_gui/generic_fns/align_tensor.py branches/bieri_gui/generic_fns/pipes.py branches/bieri_gui/sample_scripts/full_analysis.py branches/bieri_gui/scripts/code_validator branches/bieri_gui/specific_fns/frame_order.py Propchange: branches/bieri_gui/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Aug 3 09:00:27 2010 @@ -1,1 +1,1 @@ -/1.3:1-11368 +/1.3:1-11386 Modified: branches/bieri_gui/auto_analyses/dauvergne_protocol.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/auto_analyses/dauvergne_protocol.py?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/auto_analyses/dauvergne_protocol.py (original) +++ branches/bieri_gui/auto_analyses/dauvergne_protocol.py Tue Aug 3 09:00:27 2010 @@ -157,7 +157,7 @@ class dAuvergne_protocol: - def __init__(self, save_dir=None, diff_model=None, mf_models=['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9'], local_tm_models=['tm0', 'tm1', 'tm2', 'tm3', 'tm4', 'tm5', 'tm6', 'tm7', 'tm8', 'tm9'], pdb_file=None, seq_args=None, het_name=None, relax_data=None, unres=None, exclude=None, bond_length=None, csa=None, hetnuc=None, proton='1H', grid_inc=11, min_algor='newton', mc_num=500, max_iter=None, user_fns=None, conv_loop=True): + def __init__(self, save_dir=None, diff_model=None, mf_models=['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9'], local_tm_models=['tm0', 'tm1', 'tm2', 'tm3', 'tm4', 'tm5', 'tm6', 'tm7', 'tm8', 'tm9'], pdb_file=None, seq_args=None, het_name=None, attached_name='H', relax_data=None, unres=None, exclude=None, bond_length=None, csa=None, hetnuc=None, proton='1H', grid_inc=11, min_algor='newton', mc_num=500, max_iter=None, user_fns=None, conv_loop=True): """Perform the full model-free analysis protocol of d'Auvergne and Gooley, 2008b. @keyword save_dir: The directory, where files are saved in. @@ -174,6 +174,8 @@ @type seq_args: list of lists of [str, None or str, None or int, None or int, None or int, None or int, None or int, None or int, None or int, None or str] @keyword het_name: The heteronucleus atom name corresponding to that of the PDB file (used if the spin name is not in the sequence data). @type het_name: None or str + @keyword attached_name: The name of the proton attached to the heteronucleus. + @type attached_name: str @keyword relax_data: The relaxation data (data type, frequency label, frequency, file name, dir, mol_name_col, res_num_col, res_name_col, spin_num_col, spin_name_col, data_col, error_col, sep). These are the arguments to the relax_data.read() user function, please see the documentation for that function for more information. @type relax_data: list of lists of [str, str, float, str, None or str, None or int, None or int, None or int, None or int, None or int, None or int, None or int, None or str] @keyword unres: The file containing the list of unresolved spins to exclude from the analysis (set this to None if no spin is to be excluded). @@ -209,6 +211,7 @@ self.pdb_file = pdb_file self.seq_args = seq_args self.het_name = het_name + self.attached_name = attached_name self.relax_data = relax_data self.unres = unres self.exclude = exclude @@ -319,7 +322,7 @@ # Load the PDB file and calculate the unit vectors parallel to the XH bond. if self.pdb_file: self.interpreter.structure.read_pdb(self.pdb_file) - self.interpreter.structure.vectors(attached='H') + self.interpreter.structure.vectors(attached=self.attached_name) # Add an arbitrary diffusion tensor which will be optimised. if self.diff_model == 'sphere': @@ -494,6 +497,8 @@ # Atom name. if not isinstance(self.het_name, str): raise RelaxError("The het_name heteronucleus atom name user variable '%s' must be a string." % self.het_name) + if not isinstance(self.attached_name, str): + raise RelaxError("The attached_name proton atom name user variable '%s' must be a string." % self.attached_name) # Relaxation data. if not isinstance(self.relax_data, list): @@ -809,7 +814,7 @@ # Load the PDB file and calculate the unit vectors parallel to the XH bond. if not local_tm and self.pdb_file: self.interpreter.structure.read_pdb(self.pdb_file) - self.interpreter.structure.vectors(attached='H') + self.interpreter.structure.vectors(attached=self.attached_name) # Load the relaxation data. for data in self.relax_data: Modified: branches/bieri_gui/generic_fns/align_tensor.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/generic_fns/align_tensor.py?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/generic_fns/align_tensor.py (original) +++ branches/bieri_gui/generic_fns/align_tensor.py Tue Aug 3 09:00:27 2010 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2009 Edward d'Auvergne # +# Copyright (C) 2003-2010 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -25,8 +25,9 @@ # Python module imports. from copy import deepcopy -from math import pi +from math import pi, sqrt from numpy import arccos, dot, float64, linalg, zeros +from numpy.linalg import norm from re import search import sys @@ -417,6 +418,10 @@ title = "# Geometric description." print("\n\n" + title + '\n' + '#'*len(title) + '\n') + # The GDO. + print("# Generalized degree of order (GDO).") + print("GDO = %-25.12e\n" % gdo(data.A)) + # Anisotropy. print("# Alignment tensor axial component (Aa = 3/2 * Azz, where Aii are the eigenvalues).") print("Aa = %-25.12e\n" % data.Aa) @@ -525,6 +530,22 @@ elif cdp.align_tensors.beta_sim[sim_index] <= cdp.align_tensors.beta - pi/2.0: cdp.align_tensors.alpha_sim[sim_index] = pi - cdp.align_tensors.alpha_sim[sim_index] cdp.align_tensors.beta_sim[sim_index] = cdp.align_tensors.beta_sim[sim_index] + pi + + +def gdo(A): + """Calculate the generalized degree of order (GDO) for the given alignment tensor. + + @param A: The alignment tensor. + @type A: rank-2, 3D numpy array + @return: The GDO value. + @rtype: float + """ + + # The matrix norm. + gdo = sqrt(3.0/2.0) * norm(A) + + # Return the GDO. + return gdo def get_tensor_index(tensor, pipe=None): Modified: branches/bieri_gui/generic_fns/pipes.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/generic_fns/pipes.py?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/generic_fns/pipes.py (original) +++ branches/bieri_gui/generic_fns/pipes.py Tue Aug 3 09:00:27 2010 @@ -138,11 +138,17 @@ """Print the details of all the data pipes.""" # Heading. - print(("%-20s%-20s" % ("Data pipe name", "Data pipe type"))) + print(("%-20s%-20s%-20s" % ("Data pipe name", "Data pipe type", "Current"))) # Loop over the data pipes. for pipe_name in ds: - print(("%-20s%-20s" % (pipe_name, get_type(pipe_name)))) + # The current data pipe. + current = '' + if pipe_name == cdp_name(): + current = '*' + + # Print out. + print("%-20s%-20s%-20s" % ("'"+pipe_name+"'", get_type(pipe_name), current)) def get_pipe(name=None): Modified: branches/bieri_gui/sample_scripts/full_analysis.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/sample_scripts/full_analysis.py?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/sample_scripts/full_analysis.py (original) +++ branches/bieri_gui/sample_scripts/full_analysis.py Tue Aug 3 09:00:27 2010 @@ -156,8 +156,9 @@ # The sequence data (file name, dir, mol_name_col, res_num_col, res_name_col, spin_num_col, spin_name_col, sep). These are the arguments to the sequence.read() user function, for more information please see the documentation for that function. SEQ_ARGS = ['noe.600.out', None, None, 1, 2, None, None, None] -# The heteronucleus atom name corresponding to that of the PDB file (used if the spin name is not in the sequence data). +# The heteronucleus and attached proton names corresponding to those in the PDB file (used if the spin name is not in the sequence data). HET_NAME = 'N' +ATTACHED_NAME = 'H' # The relaxation data (data type, frequency label, frequency, file name, dir, mol_name_col, res_num_col, res_name_col, spin_num_col, spin_name_col, data_col, error_col, sep). These are the arguments to the relax_data.read() user function, please see the documentation for that function for more information. RELAX_DATA = [['R1', '600', 599.719 * 1e6, 'r1.600.out', None, None, 1, 2, None, None, 3, 4, None], @@ -194,4 +195,4 @@ # Execution (do not change!). -dAuvergne_protocol(diff_model=DIFF_MODEL, mf_models=MF_MODELS, local_tm_models=LOCAL_TM_MODELS, pdb_file=PDB_FILE, seq_args=SEQ_ARGS, het_name=HET_NAME, relax_data=RELAX_DATA, unres=UNRES, exclude=EXCLUDE, bond_length=BOND_LENGTH, csa=CSA, hetnuc=HETNUC, proton=PROTON, grid_inc=GRID_INC, min_algor=MIN_ALGOR, mc_num=MC_NUM, conv_loop=CONV_LOOP) +dAuvergne_protocol(diff_model=DIFF_MODEL, mf_models=MF_MODELS, local_tm_models=LOCAL_TM_MODELS, pdb_file=PDB_FILE, seq_args=SEQ_ARGS, het_name=HET_NAME,attached_name=ATTACHED_NAME, relax_data=RELAX_DATA, unres=UNRES, exclude=EXCLUDE, bond_length=BOND_LENGTH, csa=CSA, hetnuc=HETNUC, proton=PROTON, grid_inc=GRID_INC, min_algor=MIN_ALGOR, mc_num=MC_NUM, conv_loop=CONV_LOOP) Modified: branches/bieri_gui/scripts/code_validator URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/scripts/code_validator?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/scripts/code_validator (original) +++ branches/bieri_gui/scripts/code_validator Tue Aug 3 09:00:27 2010 @@ -58,9 +58,6 @@ # Empty line after docstring. self.docstring_clearance() - # Docstring length. - self.docstring_length() - # Variable, function, and class names. ###################################### @@ -173,7 +170,7 @@ """Test for proper class naming.""" # Heading. - sys.stdout.write(self.indent + "Class naming (must start with a capital).\n") + sys.stdout.write(self.indent + "Class naming (should start with a capital).\n") # Flags. ok = 1 @@ -461,72 +458,6 @@ self.terminate(ok) - def docstring_length(self): - """Test that the docstring is less than 100 char long.""" - - # Heading. - sys.stdout.write(self.indent + "Docstring length. Should be less than 100 characters including all leading whitespace (equations can be longer).\n") - - # Flags. - ok = 1 - - # Loop over the file. - for i in xrange(len(self.lines)): - # Flags. - too_long = 0 - - # Find the functions. - if search("^ *def ", self.lines[i]): - # Skip functions without docstrings! - if not search("^ *\"\"\"", self.lines[i+1]) and not search("^ *\'\'\'", self.lines[i+1]): - continue - - # Split the docstring line. - if search("^ *\"\"\"", self.lines[i+1]): - row = split(self.lines[i+1], "\"\"\"") - else: - row = split(self.lines[i+1], "\'\'\'") - - # Loop over the docstring. - j = 0 - while 1: - # Single line docstring. - if len(row) == 3: - # Test the length of the line. - if len(row[0]) + 3 + len(row[1]) > 101: - too_long = 1 - break - - # Test the length of the line. - if len(self.lines[i+1+j]) > 101: - too_long = 1 - break - - # Increment the line counter. - j = j + 1 - - # End of the docstring. - if search("\"\"\"", self.lines[i+1+j]) or search("\'\'\'", self.lines[i+1+j]): - break - - # Docstring is ok. - if not too_long: - continue - - # Initial print out. - if ok: - sys.stdout.write(self.indent + " Line num: ") - sys.stdout.write(`i+1+j+2`) - ok = 0 - - # Print the line number. - else: - sys.stdout.write(", " + `i+1+j+2`) - - # Termination. - self.terminate(ok) - - def function_args(self): """Test for proper function argment spacing.""" Modified: branches/bieri_gui/specific_fns/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/specific_fns/frame_order.py?rev=11387&r1=11386&r2=11387&view=diff ============================================================================== --- branches/bieri_gui/specific_fns/frame_order.py (original) +++ branches/bieri_gui/specific_fns/frame_order.py Tue Aug 3 09:00:27 2010 @@ -36,7 +36,7 @@ from api_base import API_base from api_common import API_common from float import isNaN, isInf -from generic_fns import pipes +from generic_fns import align_tensor, pipes from generic_fns.angles import wrap_angles from generic_fns.structure.cones import Iso_cone from generic_fns.structure.geometric import cone_edge, generate_vector_dist, generate_vector_residues, stitch_cone_to_edge @@ -114,6 +114,9 @@ # Make a single function call. This will cause back calculation and the data will be stored in the class instance. target.func(param_vector) + + # Store the back-calculated tensors. + self._store_bc_tensors(target) # Return the reduced tensors. return target.red_tensors_bc @@ -416,6 +419,22 @@ # Update the model. self._update_model() + + + def _store_bc_tensors(self, target_fn): + """Store the back-calculated reduced alignment tensors. + + @param target_fn: The frame-order target function class. + @type target_fn: class instance + """ + + # Loop over the reduced tensors. + for i, tensor in self._tensor_loop(red=True): + # New name. + name = tensor.name + ' bc' + + # Initialise the new tensor. + align_tensor.init(tensor=name, params=(target_fn.red_tensors_bc[5*i + 0], target_fn.red_tensors_bc[5*i + 1], target_fn.red_tensors_bc[5*i + 2], target_fn.red_tensors_bc[5*i + 3], target_fn.red_tensors_bc[5*i + 4]), param_types=2) def _tensor_loop(self, red=False): @@ -673,6 +692,9 @@ # Set the chi2. cdp.chi2 = chi2 + + # Store the back-calculated tensors. + self._store_bc_tensors(target) def create_mc_data(self, spin_id=None): @@ -1073,6 +1095,10 @@ # Unpack the results. self._unpack_opt_results(results, sim_index) + # Store the back-calculated tensors. + self._store_bc_tensors(target) + + def model_loop(self): """Dummy generator method.