mailr16672 - in /1.3/test_suite/system_tests: relax_data.py scripts/bug_19785_relax_data_delete.py


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

Header


Content

Posted by edward on June 05, 2012 - 17:52:
Author: bugman
Date: Tue Jun  5 17:52:56 2012
New Revision: 16672

URL: http://svn.gna.org/viewcvs/relax?rev=16672&view=rev
Log:
Created a system test for catching bug #19785 (https://gna.org/bugs/?19785).


Added:
    1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py
      - copied, changed from r16669, 
1.3/test_suite/system_tests/scripts/model_free/dauvergne_protocol.py
Modified:
    1.3/test_suite/system_tests/relax_data.py

Modified: 1.3/test_suite/system_tests/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/relax_data.py?rev=16672&r1=16671&r2=16672&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/relax_data.py (original)
+++ 1.3/test_suite/system_tests/relax_data.py Tue Jun  5 17:52:56 2012
@@ -25,7 +25,6 @@
 
 # relax module imports.
 from base_classes import SystemTestCase
-from data import Relax_data_store; ds = Relax_data_store()
 from generic_fns.mol_res_spin import spin_loop
 from status import Status; status = Status()
 
@@ -100,3 +99,32 @@
 
             # Increment.
             index += 1
+
+
+    def test_delete(self):
+        """Test the relax_data.delete user function, replicating bug 
#19785."""
+
+        # Execute the script.
+        self.interpreter.run(script_file=status.install_path + 
sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'bug_19785_relax_data_delete.py')
+
+        # Switch to the first pipe.
+        self.interpreter.pipe.switch('delete 1')
+
+        # Checks.
+        self.assertEqual(cdp.ri_ids, ['R1_900', 'NOE_900', 'R1_500', 
'R2_500', 'NOE_500'])
+        self.assert_(not cdp.frq.has_key('R2_900'))
+        self.assert_(not cdp.ri_type.has_key('R2_900'))
+        for spin in spin_loop():
+            self.assert_(not spin.ri_data.has_key('R2_900'))
+            self.assert_(not spin.ri_data_err.has_key('R2_900'))
+
+        # Switch to the second pipe.
+        self.interpreter.pipe.switch('delete 2')
+
+        # Checks.
+        self.assert_(not hasattr(cdp, 'ri_ids'))
+        self.assert_(not hasattr(cdp, 'frq'))
+        self.assert_(not hasattr(cdp, 'ri_type'))
+        for spin in spin_loop():
+            self.assert_(not hasattr(spin, 'ri_data'))
+            self.assert_(not hasattr(spin, 'ri_data_err'))

Copied: 1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py 
(from r16669, 
1.3/test_suite/system_tests/scripts/model_free/dauvergne_protocol.py)
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py?p2=1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py&p1=1.3/test_suite/system_tests/scripts/model_free/dauvergne_protocol.py&r1=16669&r2=16672&rev=16672&view=diff
==============================================================================
--- 1.3/test_suite/system_tests/scripts/model_free/dauvergne_protocol.py 
(original)
+++ 1.3/test_suite/system_tests/scripts/bug_19785_relax_data_delete.py Tue 
Jun  5 17:52:56 2012
@@ -1,229 +1,47 @@
-###############################################################################
-#                                                                            
 #
-# Copyright (C) 2004-2012 Edward d'Auvergne                                  
 #
-#                                                                            
 #
-# This file is part of the program relax.                                    
 #
-#                                                                            
 #
-# relax is free software; you can redistribute it and/or modify              
 #
-# it under the terms of the GNU General Public License as published by       
 #
-# the Free Software Foundation; either version 2 of the License, or          
 #
-# (at your option) any later version.                                        
 #
-#                                                                            
 #
-# relax is distributed in the hope that it will be useful,                   
 #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
-# GNU General Public License for more details.                               
 #
-#                                                                            
 #
-# You should have received a copy of the GNU General Public License          
 #
-# along with relax; if not, write to the Free Software                       
 #
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
 #
-#                                                                            
 #
-###############################################################################
+"""This system test script catches the relax_data.delete bug submitted by 
Martin Ballaschk.
 
-"""Script for black-box model-free analysis.
-
-This script is designed for those who appreciate black-boxes or those who 
appreciate complex code.  Importantly data at multiple magnetic field 
strengths is essential for this analysis.  The script will need to be heavily 
tailored to the molecule in question by changing the variables just below 
this documentation.  If you would like to change how model-free analysis is 
performed, the code in the class Main can be changed as needed.  For a 
description of object-oriented coding in python using classes, 
functions/methods, self, etc., see the python tutorial.
-
-If you have obtained this script without the program relax, please visit 
http://www.nmr-relax.com.
-
-
-References
-==========
-
-The model-free optimisation methodology herein is that of:
-
-    d'Auvergne, E. J. and Gooley, P. R. (2008b). Optimisation of NMR dynamic 
models II. A new methodology for the dual optimisation of the model-free 
parameters and the Brownian rotational diffusion tensor. J. Biomol. NMR, 
40(2), 121-133
-
-Other references for features of this script include model-free model 
selection using Akaike's Information Criterion:
-
-    d'Auvergne, E. J. and Gooley, P. R. (2003). The use of model selection 
in the model-free analysis of protein dynamics. J. Biomol. NMR, 25(1), 25-39.
-
-The elimination of failed model-free models and Monte Carlo simulations:
-
-    d'Auvergne, E. J. and Gooley, P. R. (2006). Model-free model 
elimination: A new step in the model-free dynamic analysis of NMR relaxation 
data. J. Biomol. NMR, 35(2), 117-135.
-
-Significant model-free optimisation improvements:
-
-    d'Auvergne, E. J. and Gooley, P. R. (2008a). Optimisation of NMR dynamic 
models I. Minimisation algorithms and their performance within the model-free 
and Brownian rotational diffusion spaces. J. Biomol. NMR, 40(2), 107-109.
-
-Rather than searching for the lowest chi-squared value, this script searches 
for the model with the lowest AIC criterion.  This complex multi-universe, 
multi-dimensional search is formulated using set theory as the universal 
solution:
-
-    d'Auvergne, E. J. and Gooley, P. R. (2007). Set theory formulation of 
the model-free problem and the diffusion seeded model-free paradigm. 3(7), 
483-494.
-
-The basic three references for the original and extended model-free theories 
are:
-
-    Lipari, G. and Szabo, A. (1982a). Model-free approach to the 
interpretation of nuclear magnetic-resonance relaxation in macromolecules I. 
Theory and range of validity. J. Am. Chem. Soc., 104(17), 4546-4559.
-
-    Lipari, G. and Szabo, A. (1982b). Model-free approach to the 
interpretation of nuclear magnetic-resonance relaxation in macromolecules II. 
Analysis of experimental results. J. Am. Chem. Soc., 104(17), 4559-4570.
-
-    Clore, G. M., Szabo, A., Bax, A., Kay, L. E., Driscoll, P. C., and 
Gronenborn, A.M. (1990). Deviations from the simple 2-parameter model-free 
approach to the interpretation of N-15 nuclear magnetic-relaxation of 
proteins. J. Am. Chem. Soc., 112(12), 4989-4991.
-
-
-How to use this script
-======================
-
-The value of the variable DIFF_MODEL will determine the behaviour of this 
script.  The five diffusion models used in this script are:
-
-    Model I   (MI)   - Local tm.
-    Model II  (MII)  - Sphere.
-    Model III (MIII) - Prolate spheroid.
-    Model IV  (MIV)  - Oblate spheroid.
-    Model V   (MV)   - Ellipsoid.
-
-Model I must be optimised prior to any of the other diffusion models, while 
the Models II to V can be optimised in any order.  To select the various 
models, set the variable DIFF_MODEL to the following strings:
-
-    MI   - 'local_tm'
-    MII  - 'sphere'
-    MIII - 'prolate'
-    MIV  - 'oblate'
-    MV   - 'ellipsoid'
-
-This approach has the advantage of eliminating the need for an initial 
estimate of a global diffusion tensor and removing all the problems 
associated with the initial estimate.
-
-It is important that the number of parameters in a model does not exceed the 
number of relaxation data sets for that spin.  If this is the case, the list 
of models in the MF_MODELS and LOCAL_TM_MODELS variables will need to be 
trimmed.
-
-
-Model I - Local tm
-~~~~~~~~~~~~~~~~~~
-
-This will optimise the diffusion model whereby all spin of the molecule have 
a local tm value, i.e. there is no global diffusion tensor.  This model needs 
to be optimised prior to optimising any of the other diffusion models.  Each 
spin is fitted to the multiple model-free models separately, where the 
parameter tm is included in each model.
-
-AIC model selection is used to select the models for each spin.
-
-
-Model II - Sphere
-~~~~~~~~~~~~~~~~~
-
-This will optimise the isotropic diffusion model.  Multiple steps are 
required, an initial optimisation of the diffusion tensor, followed by a 
repetitive optimisation until convergence of the diffusion tensor.  Each of 
these steps requires this script to be rerun. For the initial optimisation, 
which will be placed in the directory './sphere/init/', the following steps 
are used:
-
-The model-free models and parameter values for each spin are set to those of 
diffusion model MI.
-
-The local tm parameter is removed from the models.
-
-The model-free parameters are fixed and a global spherical diffusion tensor 
is minimised.
-
-
-For the repetitive optimisation, each minimisation is named from 'round_1' 
onwards.  The initial 'round_1' optimisation will extract the diffusion 
tensor from the results file in './sphere/init/', and the results will be 
placed in the directory './sphere/round_1/'.  Each successive round will take 
the diffusion tensor from the previous round.  The following steps are used:
-
-The global diffusion tensor is fixed and the multiple model-free models are 
fitted to each spin.
-
-AIC model selection is used to select the models for each spin.
-
-All model-free and diffusion parameters are allowed to vary and a global 
optimisation of all parameters is carried out.
-
-
-Model III - Prolate spheroid
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The methods used are identical to those of diffusion model MII, except that 
an axially symmetric diffusion tensor with Da >= 0 is used.  The base 
directory containing all the results is './prolate/'.
-
-
-Model IV - Oblate spheroid
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The methods used are identical to those of diffusion model MII, except that 
an axially symmetric diffusion tensor with Da <= 0 is used.  The base 
directory containing all the results is './oblate/'.
-
-
-Model V - Ellipsoid
-~~~~~~~~~~~~~~~~~~~
-
-The methods used are identical to those of diffusion model MII, except that 
a fully anisotropic diffusion tensor is used (also known as rhombic or 
asymmetric diffusion).  The base directory is './ellipsoid/'.
-
-
-
-Final run
-~~~~~~~~~
-
-Once all the diffusion models have converged, the final run can be executed. 
 This is done by setting the variable DIFF_MODEL to 'final'.  This consists 
of two steps, diffusion tensor model selection, and Monte Carlo simulations.  
Firstly AIC model selection is used to select between the diffusion tensor 
models.  Monte Carlo simulations are then run solely on this selected 
diffusion model.  Minimisation of the model is bypassed as it is assumed that 
the model is already fully optimised (if this is not the case the final run 
is not yet appropriate).
-
-The final black-box model-free results will be placed in the file 
'final/results'.
+The bug is:
+    - Bug #19785 (https://gna.org/bugs/?19785).
 """
 
 # Python module imports.
 from os import sep
-from time import asctime, localtime
 
 # relax module imports.
-from auto_analyses.dauvergne_protocol import dAuvergne_protocol
 from data import Relax_data_store; ds = Relax_data_store()
 from status import Status; status = Status()
 
 
-# Analysis variables.
-#####################
+# The data path.
+DATA_PATH = status.install_path + sep + 'test_suite' + sep + 'shared_data' + 
sep + 'model_free' + sep + 'sphere' + sep
 
-# The diffusion model.
-DIFF_MODEL = 'local_tm'
+# Two pipes for the tests.
+pipes = ['delete 1', 'delete 2']
 
-# The model-free models.  Do not change these unless absolutely necessary, 
the protocol is likely to fail if these are changed.
-MF_MODELS = ['m1', 'm2']
-LOCAL_TM_MODELS = ['tm0', 'tm1']
+# Load the data for each pipe.
+for pipe_name in pipes:
+    # Create a data pipe.
+    pipe.create(pipe_name, 'mf')
 
-# The grid search size (the number of increments per dimension).
-GRID_INC = 3
+    # Load the sequence.
+    sequence.read(file='noe.500.out', dir=DATA_PATH, mol_name_col=1, 
res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5)
 
-# The optimisation technique.
-MIN_ALGOR = 'newton'
+    # Name the spins.
+    spin.name(name='N')
 
-# The number of Monte Carlo simulations to be used for error analysis at the 
end of the analysis.
-MC_NUM = 2
+    # Load the relaxation data.
+    relax_data.read(ri_id='R1_900',  ri_type='R1',  frq=900*1e6, 
file='r1.900.out',  dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
+    relax_data.read(ri_id='R2_900',  ri_type='R2',  frq=900*1e6, 
file='r2.900.out',  dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
+    relax_data.read(ri_id='NOE_900', ri_type='NOE', frq=900*1e6, 
file='noe.900.out', dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
+    relax_data.read(ri_id='R1_500',  ri_type='R1',  frq=500*1e6, 
file='r1.500.out',  dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
+    relax_data.read(ri_id='R2_500',  ri_type='R2',  frq=500*1e6, 
file='r2.500.out',  dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
+    relax_data.read(ri_id='NOE_500', ri_type='NOE', frq=500*1e6, 
file='noe.500.out', dir=DATA_PATH, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
 
-# Automatic looping over all rounds until convergence (must be a boolean 
value of True or False).
-CONV_LOOP = True
-
-
-
-# Set up the data pipe.
-#######################
-
-# The following sequence of user function calls can be changed as needed.
-
-# Create the data pipe.
-name = "mf (%s)" % asctime(localtime())
-pipe.create(name, 'mf')
-
-# The data path.
-data_path = status.install_path + sep + 'test_suite' + sep + 'shared_data' + 
sep + 'model_free' + sep + 'sphere' + sep
-
-# Load the sequence.
-sequence.read(file='noe.500.out', dir=data_path, mol_name_col=1, 
res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5)
-
-# Name the spins.
-spin.name(name='N')
-
-# Load the PDB file.
-structure.read_pdb('sphere.pdb', dir=data_path)
-structure.vectors(attached='H')
-
-# Load the relaxation data.
-relax_data.read(ri_id='R1_900',  ri_type='R1',  frq=900*1e6, 
file='r1.900.out',  dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-relax_data.read(ri_id='R2_900',  ri_type='R2',  frq=900*1e6, 
file='r2.900.out',  dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-relax_data.read(ri_id='NOE_900', ri_type='NOE', frq=900*1e6, 
file='noe.900.out', dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-relax_data.read(ri_id='R1_500',  ri_type='R1',  frq=500*1e6, 
file='r1.500.out',  dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-relax_data.read(ri_id='R2_500',  ri_type='R2',  frq=500*1e6, 
file='r2.500.out',  dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-relax_data.read(ri_id='NOE_500', ri_type='NOE', frq=500*1e6, 
file='noe.500.out', dir=data_path, mol_name_col=1, res_num_col=2, 
res_name_col=3, spin_num_col=4, spin_name_col=5, data_col=6, error_col=7)
-
-# Set the bond length, CSA values, heteronucleus type, and proton type.
-value.set(1.02 * 1e-10, 'r')
-value.set(-172 * 1e-6, 'csa')
-value.set('15N', 'heteronuc_type')
-value.set('1H', 'proton_type')
-
-
-
-# Execution.
-############
-
-# The results dir.
-if not hasattr(ds, 'tmpdir'):
-    results_dir = status.install_path + sep + 'dauvergne_protocol'
-else:
-    results_dir = ds.tmpdir
-
-# Change some opt params.
-dAuvergne_protocol.opt_func_tol = 1e-5
-dAuvergne_protocol.opt_max_iterations = 1000
-
-# Loop over all global models.
-for global_model in ['local_tm', 'sphere', 'prolate', 'oblate', 'ellipsoid', 
'final']:
-    dAuvergne_protocol(pipe_name=name, results_dir=results_dir, 
diff_model=global_model, mf_models=MF_MODELS, 
local_tm_models=LOCAL_TM_MODELS, grid_inc=GRID_INC, 
diff_tensor_grid_inc={'sphere': 5, 'prolate': 5, 'oblate': 5, 'ellipsoid': 
3}, min_algor=MIN_ALGOR, mc_sim_num=MC_NUM, max_iter=1, conv_loop=CONV_LOOP)
+    # Relaxation data deletion.
+    relax_data.delete('R2_900')
+    if pipe_name == 'delete 2':
+        relax_data.delete('R1_900')
+        relax_data.delete('NOE_900')
+        relax_data.delete('R1_500')
+        relax_data.delete('R2_500')
+        relax_data.delete('NOE_500')




Related Messages


Powered by MHonArc, Updated Tue Jun 05 18:20:02 2012