"Fossies" - the Fresh Open Source Software Archive

Member "relax-5.0.0/test_suite/system_tests/model_free.py" (2 Dec 2019, 157387 Bytes) of package /linux/privat/relax-5.0.0.src.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "model_free.py": 4.1.3_vs_5.0.0.

    1 ###############################################################################
    2 #                                                                             #
    3 # Copyright (C) 2006-2015,2017,2019 Edward d'Auvergne                         #
    4 #                                                                             #
    5 # This file is part of the program relax (http://www.nmr-relax.com).          #
    6 #                                                                             #
    7 # This program is free software: you can redistribute it and/or modify        #
    8 # it under the terms of the GNU General Public License as published by        #
    9 # the Free Software Foundation, either version 3 of the License, or           #
   10 # (at your option) any later version.                                         #
   11 #                                                                             #
   12 # This program is distributed in the hope that it will be useful,             #
   13 # but WITHOUT ANY WARRANTY; without even the implied warranty of              #
   14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
   15 # GNU General Public License for more details.                                #
   16 #                                                                             #
   17 # You should have received a copy of the GNU General Public License           #
   18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
   19 #                                                                             #
   20 ###############################################################################
   21 
   22 # Python module imports.
   23 from math import pi
   24 import platform
   25 import numpy
   26 from os import path, sep, walk
   27 from re import search
   28 import sys
   29 from tempfile import mkdtemp, mkstemp
   30 
   31 # relax module imports.
   32 from auto_analyses.dauvergne_protocol import dAuvergne_protocol
   33 from data_store import Relax_data_store; ds = Relax_data_store()
   34 import dep_check
   35 from lib.compat import linux_distribution
   36 from pipe_control import pipes
   37 from pipe_control.interatomic import interatomic_loop
   38 from pipe_control.mol_res_spin import spin_loop
   39 from lib.errors import RelaxError, RelaxMultiSpinIDError
   40 from lib.physical_constants import N15_CSA
   41 from lib.io import DummyFileObject, open_read_file
   42 from status import Status; status = Status()
   43 from test_suite.system_tests.base_classes import SystemTestCase
   44 
   45 
   46 # Get the platform/version information.
   47 SYSTEM = platform.system()
   48 RELEASE = platform.release()
   49 VERSION = platform.version()
   50 WIN32_VER = platform.win32_ver()
   51 DIST = linux_distribution()
   52 ARCH = platform.architecture()
   53 MACH = platform.machine()
   54 PROC = platform.processor()
   55 PY_VER = platform.python_version()
   56 NUMPY_VER = numpy.__version__
   57 LIBC_VER = platform.libc_ver()
   58 
   59 # Windows system name pain.
   60 if SYSTEM == 'Windows' or SYSTEM == 'Microsoft':
   61     # Set the system to 'Windows' no matter what.
   62     SYSTEM = 'Windows'
   63 
   64 
   65 
   66 class Mf(SystemTestCase):
   67     """TestCase class for the functional tests of model-free analysis."""
   68 
   69     def __init__(self, methodName='runTest'):
   70         """Skip some tests if bmrblib is not installed.
   71 
   72         @keyword methodName:    The name of the test.
   73         @type methodName:       str
   74         """
   75 
   76         # Execute the base class method.
   77         super(Mf, self).__init__(methodName)
   78 
   79         # Missing module.
   80         if not dep_check.bmrblib_module and methodName in ['test_bug_24131_bmrb_deposition', 'test_bug_24131_missing_interaction']:
   81             # Store in the status object.
   82             status.skipped_tests.append([methodName, 'Bmrblib', self._skip_type])
   83 
   84 
   85     def setUp(self):
   86         """Set up for all the functional tests."""
   87 
   88         # Create the data pipe.
   89         self.interpreter.pipe.create('mf', 'mf')
   90 
   91 
   92     def check_read_results_1_3(self):
   93         """Common code for the test_read_results_1_3*() tests."""
   94 
   95         # Path of the files.
   96         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
   97 
   98         # Read the equivalent 1.2 results file for the checks.
   99         self.interpreter.pipe.create('1.2', 'mf')
  100         self.interpreter.results.read(file='final_results_trunc2_1.2', dir=path)
  101 
  102         # Get the two data pipes.
  103         pipe_12 = pipes.get_pipe('1.2')
  104         pipe_13 = pipes.get_pipe('1.3')
  105 
  106         # Test that the objects in the base pipes are the same.
  107         print("Comparison of the objects of the base data pipe:")
  108         self.object_comparison(obj1=pipe_12, obj2=pipe_13, skip=['mol', 'interatomic', 'diff_tensor'])
  109 
  110         # Test that the diffusion tensor data is the same.
  111         print("Comparison of the objects of the diffusion tensor:")
  112         self.object_comparison(obj1=pipe_12.diff_tensor, obj2=pipe_13.diff_tensor)
  113 
  114         # Test the number of molecules.
  115         self.assertEqual(len(pipe_12.mol), len(pipe_13.mol))
  116 
  117         # Loop over the molecules.
  118         for i in range(len(pipe_12.mol)):
  119             # Test the objects.
  120             print("Comparison of the objects of the molecule:")
  121             self.object_comparison(obj1=pipe_12.mol[i], obj2=pipe_13.mol[i], skip=['res'])
  122 
  123             # Test the number of residues.
  124             self.assertEqual(len(pipe_12.mol[i].res), len(pipe_13.mol[i].res))
  125 
  126             # Loop over the residues.
  127             for j in range(len(pipe_12.mol[i].res)):
  128                 # Ok, really don't need to do a full comparison of all 162 residues for this test!
  129                 if j > 10:
  130                     break
  131 
  132                 # Test the objects.
  133                 print("Comparison of the objects of the residue:")
  134                 self.object_comparison(obj1=pipe_12.mol[i].res[j], obj2=pipe_13.mol[i].res[j], skip=['spin'])
  135 
  136                 # Test the number of spins.
  137                 self.assertEqual(len(pipe_12.mol[i].res[j].spin), len(pipe_13.mol[i].res[j].spin))
  138 
  139                 # Loop over the spins.
  140                 for k in range(len(pipe_12.mol[i].res[j].spin)):
  141                     # Test the objects.
  142                     print("Comparison of the objects of the spin:")
  143                     self.object_comparison(obj1=pipe_12.mol[i].res[j].spin[k], obj2=pipe_13.mol[i].res[j].spin[k])
  144 
  145         # Loop over the interatomic data containers.
  146         for i in range(len(pipe_12.interatomic)):
  147             # Test the objects.
  148             print("Comparison of the objects of the interatomic data containers:")
  149             self.object_comparison(obj1=pipe_12.interatomic[i], obj2=pipe_13.interatomic[i])
  150 
  151 
  152     def mesg_opt_debug(self, spin):
  153         """Method for returning a string to help debug the minimisation.
  154 
  155         @param spin:    The SpinContainer of the optimised spin.
  156         @type spin:     SpinContainer instance
  157         @return:        The debugging string.
  158         @rtype:         str
  159         """
  160 
  161         # Initialise the string.
  162         string = 'Optimisation failure.\n\n'
  163 
  164         # Create the string.
  165         string = string + "%-18s%-25s\n" % ("System: ", SYSTEM)
  166         string = string + "%-18s%-25s\n" % ("Release: ", RELEASE)
  167         string = string + "%-18s%-25s\n" % ("Version: ", VERSION)
  168         string = string + "%-18s%-25s\n" % ("Win32 version: ", (WIN32_VER[0] + " " + WIN32_VER[1] + " " + WIN32_VER[2] + " " + WIN32_VER[3]))
  169         string = string + "%-18s%-25s\n" % ("Distribution: ", (DIST[0] + " " + DIST[1] + " " + DIST[2]))
  170         string = string + "%-18s%-25s\n" % ("Architecture: ", (ARCH[0] + " " + ARCH[1]))
  171         string = string + "%-18s%-25s\n" % ("Machine: ", MACH)
  172         string = string + "%-18s%-25s\n" % ("Processor: ", PROC)
  173         string = string + "%-18s%-25s\n" % ("Python version: ", PY_VER)
  174         string = string + "%-18s%-25s\n" % ("Numpy version: ", NUMPY_VER)
  175         string = string + "%-18s%-25s\n" % ("Libc version: ", (LIBC_VER[0] + " " + LIBC_VER[1]))
  176 
  177 
  178         # Minimisation info.
  179         string = string + '\n'
  180         if spin.local_tm != None:
  181             string = string + "%-15s %30.16g\n" % ('local_tm (ns):',    spin.local_tm * 1e9)
  182         if spin.s2 != None:
  183             string = string + "%-15s %30.16g\n" % ('s2:',               spin.s2)
  184         if spin.s2f != None:
  185             string = string + "%-15s %30.16g\n" % ('s2f:',              spin.s2f)
  186         if spin.s2s != None:
  187             string = string + "%-15s %30.16g\n" % ('s2s:',              spin.s2s)
  188         if spin.te != None:
  189             string = string + "%-15s %30.13g\n" % ('te (ps):',          spin.te * 1e12)
  190         if spin.tf != None:
  191             string = string + "%-15s %30.13g\n" % ('tf (ps):',          spin.tf * 1e12)
  192         if spin.ts != None:
  193             string = string + "%-15s %30.13g\n" % ('ts (ps):',          spin.ts * 1e12)
  194         if spin.rex != None:
  195             string = string + "%-15s %30.17g\n" % ('rex:',      spin.rex * (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2)
  196         string = string +   "%-15s %30.17g\n" % ('chi2:',   spin.chi2)
  197         string = string +   "%-15s %30i\n"   % ('iter:',    spin.iter)
  198         string = string +   "%-15s %30i\n"   % ('f_count:', spin.f_count)
  199         string = string +   "%-15s %30i\n"   % ('g_count:', spin.g_count)
  200         string = string +   "%-15s %30i\n"   % ('h_count:', spin.h_count)
  201         string = string +   "%-15s %30s\n"   % ('warning:', spin.warning)
  202 
  203         # Return the string.
  204         return string
  205 
  206 
  207     def monte_carlo(self):
  208         """Run Monte Carlo simulations for the optimised model-free model."""
  209 
  210         # Monte Carlo simulations.
  211         self.interpreter.monte_carlo.setup(number=3)
  212         self.interpreter.monte_carlo.create_data()
  213         self.interpreter.monte_carlo.initial_values()
  214         self.interpreter.minimise.execute('newton')
  215         #self.interpreter.eliminate()
  216         self.interpreter.monte_carlo.error_analysis()
  217 
  218 
  219     def object_comparison(self, obj1=None, obj2=None, skip=None):
  220         """Check if the contents of 2 objects are the same."""
  221 
  222         # The names are the same.
  223         print("dir(obj1):  %s" % dir(obj1))
  224         print("dir(obj2):  %s" % dir(obj2))
  225         self.assertEqual(dir(obj1), dir(obj2))
  226 
  227         # Loop over the objects in the base objects.
  228         for name in dir(obj1):
  229             # Skip special objects.
  230             if skip and name in skip:
  231                 continue
  232 
  233             # Skip objects starting with '_'.
  234             if search('^_', name):
  235                 continue
  236 
  237             # Skip original class methods.
  238             if name in obj1.__class__.__dict__:
  239                 continue
  240 
  241             # Print out.
  242             print("\t" + name)
  243 
  244             # Get the sub-objects.
  245             sub_obj1 = getattr(obj1, name)
  246             sub_obj2 = getattr(obj2, name)
  247 
  248             # Check that they are of the same type.
  249             self.assertEqual(type(sub_obj1), type(sub_obj2))
  250 
  251             # Check that they are equal (converting to strings to avoid comparison nastiness).
  252             if isinstance(sub_obj1, dict):
  253                 self.assertEqual(sub_obj1, sub_obj2)
  254             else:
  255                 self.assertEqual(str(sub_obj1), str(sub_obj2))
  256 
  257 
  258     def test_bug_14872_unicode_selection(self):
  259         """Test catching U{bug #14872<https://web.archive.org/web/https://gna.org/bugs/?14872>}, the unicode string selection failure as submitted by Olivier Serve."""
  260 
  261         # Execute the script.
  262         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_14872_unicode_selection.py')
  263 
  264 
  265     def test_bug_14941_local_tm_global_selection(self):
  266         """Test catching U{bug #14941<https://web.archive.org/web/https://gna.org/bugs/?14941>}, the local tm global model selection problem as submitted by Mikaela Stewart (mikaela dot stewart att gmail dot com)."""
  267 
  268         # Execute the script.
  269         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_14941_local_tm_global_selection.py')
  270 
  271 
  272     def test_bug_15050(self):
  273         """Test catching U{bug #15050<https://web.archive.org/web/https://gna.org/bugs/?15050>}, 'PipeContainer' object has no attribute 'diff_tensor' error as submitted by U{Tiago Pais<https://web.archive.org/web/https://gna.org/users/tpais>}."""
  274 
  275         # Execute the script.
  276         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_15050.py')
  277 
  278 
  279     def test_bugs_12582_12591_12607(self):
  280         """Test catching bugs U{#12582<https://web.archive.org/web/https://gna.org/bugs/?12582>}, U{#12591<https://web.archive.org/web/https://gna.org/bugs/?12591>} and U{#12607<https://web.archive.org/web/https://gna.org/bugs/?12607>} as submitted by Chris Brosey."""
  281 
  282         # Execute the script.
  283         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bugs_12582_12591_12607.py')
  284 
  285         # Test for bug #12607 (S2 changes because it is in the grid search when it should not be).
  286         self.assertNotEqual(cdp.mol[0].res[1].spin[0].s2, 1.0)
  287 
  288 
  289     def test_bug_18790(self):
  290         """Test catching U{bug #18790<https://web.archive.org/web/https://gna.org/bugs/?18790>}, the negative relaxation data RelaxError reported by Vitaly Vostrikov."""
  291 
  292         # Execute the script.
  293         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_18790_negative_error.py')
  294 
  295 
  296     def test_bug_20213_asn_sidechain(self):
  297         """U{Bug #20213<https://web.archive.org/web/https://gna.org/bugs/?20213>} catch, the model selection failure due to the presence of Asp and Gln sidechain N spins."""
  298 
  299         # Create a temporary directory for dumping files.
  300         ds.tmpdir = mkdtemp()
  301 
  302         # Execute the script.
  303         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_20213_asn_sidechain.py')
  304 
  305 
  306     def test_bug_20464_missing_ri_data(self):
  307         """U{Bug #20464<https://web.archive.org/web/https://gna.org/bugs/?20464>} catch, the failure due to missing relaxation data."""
  308 
  309         # Clear the data store.
  310         self.interpreter.reset()
  311 
  312         # Execute the script.
  313         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_20464_missing_ri_data.py')
  314 
  315 
  316     def test_bug_20563_missing_ri_error(self):
  317         """U{Bug #20563<https://web.archive.org/web/https://gna.org/bugs/?20563>} catch, the failure due to missing relaxation data errors."""
  318 
  319         # Clear the data store.
  320         self.interpreter.reset()
  321 
  322         # Execute the script.
  323         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_20563_missing_ri_error.py')
  324 
  325 
  326     def test_bug_20531_molmol_macro_write_relaxfault(self):
  327         """U{Bug #20531<https://web.archive.org/web/https://gna.org/bugs/?20531>} catch, the RelaxFault when creating the Molmol macros."""
  328 
  329         # Clear the data store.
  330         self.interpreter.reset()
  331 
  332         # Load the state.
  333         state = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states'+sep+'bug_20531_mf_relaxfault.bz2'
  334         self.interpreter.state.load(state, force=True)
  335 
  336         # Create a temporary directory for dumping files.
  337         ds.tmpdir = mkdtemp()
  338 
  339         # Attempt to create the Molmol macros.
  340         self.interpreter.molmol.macro_write(data_type='s2',        dir=ds.tmpdir, force=True)
  341         self.interpreter.molmol.macro_write(data_type='s2f',       dir=ds.tmpdir, force=True)
  342         self.interpreter.molmol.macro_write(data_type='s2s',       dir=ds.tmpdir, force=True)
  343         self.interpreter.molmol.macro_write(data_type='amp_fast',  dir=ds.tmpdir, force=True)
  344         self.interpreter.molmol.macro_write(data_type='amp_slow',  dir=ds.tmpdir, force=True)
  345         self.interpreter.molmol.macro_write(data_type='te',        dir=ds.tmpdir, force=True)
  346         self.interpreter.molmol.macro_write(data_type='tf',        dir=ds.tmpdir, force=True)
  347         self.interpreter.molmol.macro_write(data_type='ts',        dir=ds.tmpdir, force=True)
  348         self.interpreter.molmol.macro_write(data_type='time_fast', dir=ds.tmpdir, force=True)
  349         self.interpreter.molmol.macro_write(data_type='time_slow', dir=ds.tmpdir, force=True)
  350         self.interpreter.molmol.macro_write(data_type='rex',       dir=ds.tmpdir, force=True)
  351 
  352         # Attempt to create the PyMOL macros.
  353         self.interpreter.pymol.macro_write(data_type='s2',        dir=ds.tmpdir, force=True)
  354         self.interpreter.pymol.macro_write(data_type='s2f',       dir=ds.tmpdir, force=True)
  355         self.interpreter.pymol.macro_write(data_type='s2s',       dir=ds.tmpdir, force=True)
  356         self.interpreter.pymol.macro_write(data_type='amp_fast',  dir=ds.tmpdir, force=True)
  357         self.interpreter.pymol.macro_write(data_type='amp_slow',  dir=ds.tmpdir, force=True)
  358         self.interpreter.pymol.macro_write(data_type='te',        dir=ds.tmpdir, force=True)
  359         self.interpreter.pymol.macro_write(data_type='tf',        dir=ds.tmpdir, force=True)
  360         self.interpreter.pymol.macro_write(data_type='ts',        dir=ds.tmpdir, force=True)
  361         self.interpreter.pymol.macro_write(data_type='time_fast', dir=ds.tmpdir, force=True)
  362         self.interpreter.pymol.macro_write(data_type='time_slow', dir=ds.tmpdir, force=True)
  363         self.interpreter.pymol.macro_write(data_type='rex',       dir=ds.tmpdir, force=True)
  364 
  365         # Attempt to create the Grace plots.
  366         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2',  file='s2.agr',        dir=ds.tmpdir, force=True)
  367         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2f', file='s2f.agr',       dir=ds.tmpdir, force=True)
  368         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2s', file='s2s.agr',       dir=ds.tmpdir, force=True)
  369         self.interpreter.grace.write(x_data_type='res_num', y_data_type='te',  file='te.agr',        dir=ds.tmpdir, force=True)
  370         self.interpreter.grace.write(x_data_type='res_num', y_data_type='tf',  file='tf.agr',        dir=ds.tmpdir, force=True)
  371         self.interpreter.grace.write(x_data_type='res_num', y_data_type='ts',  file='ts.agr',        dir=ds.tmpdir, force=True)
  372         self.interpreter.grace.write(x_data_type='res_num', y_data_type='rex', file='rex.agr',       dir=ds.tmpdir, force=True)
  373         self.interpreter.grace.write(x_data_type='s2',      y_data_type='te',  file='s2_vs_te.agr',  dir=ds.tmpdir, force=True)
  374         self.interpreter.grace.write(x_data_type='s2',      y_data_type='rex', file='s2_vs_rex.agr', dir=ds.tmpdir, force=True)
  375         self.interpreter.grace.write(x_data_type='te',      y_data_type='rex', file='te_vs_rex.agr', dir=ds.tmpdir, force=True)
  376 
  377         # Attempt to create the text files of the values.
  378         self.interpreter.value.write(param='s2',       file='s2.txt',       dir=ds.tmpdir, force=True)
  379         self.interpreter.value.write(param='s2f',      file='s2f.txt',      dir=ds.tmpdir, force=True)
  380         self.interpreter.value.write(param='s2s',      file='s2s.txt',      dir=ds.tmpdir, force=True)
  381         self.interpreter.value.write(param='te',       file='te.txt',       dir=ds.tmpdir, force=True)
  382         self.interpreter.value.write(param='tf',       file='tf.txt',       dir=ds.tmpdir, force=True)
  383         self.interpreter.value.write(param='ts',       file='ts.txt',       dir=ds.tmpdir, force=True)
  384         self.interpreter.value.write(param='rex',      file='rex.txt',      dir=ds.tmpdir, force=True)
  385         self.interpreter.value.write(param='local_tm', file='local_tm.txt', dir=ds.tmpdir, force=True)
  386 
  387 
  388     def test_bug_20531_molmol_macro_write_relaxfault2(self):
  389         """U{Bug #20531<https://web.archive.org/web/https://gna.org/bugs/?20531>} catch, the RelaxFault when creating the Molmol macros.
  390 
  391         This was the first attempt at catching the bug, but it failed.  However the code paths tested here are not tested in any other tests, so this system test will remain.
  392         """
  393 
  394         # Load some sequence data.
  395         self.interpreter.sequence.read(file='Ap4Aase.seq', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep, res_num_col=1, res_name_col=2)
  396 
  397         # Set some spin info.
  398         self.interpreter.spin.name('N')
  399         self.interpreter.spin.element('N')
  400         self.interpreter.spin.isotope('15N')
  401 
  402         # The models to create.
  403         models = ['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9'] + ['tm0', 'tm1', 'tm2', 'tm3', 'tm4', 'tm5', 'tm6', 'tm7', 'tm8', 'tm9']
  404 
  405         # Set the spectrometer frequency.
  406         self.interpreter.spectrometer.frequency(id='600', frq=600000000.1)
  407 
  408         # Loop over the models.
  409         for i in range(len(models)):
  410             self.interpreter.model_free.select_model(model=models[i], spin_id=':%s'%(i+1))
  411 
  412         # Set values for all parameters.
  413         self.interpreter.value.set(param='s2', val=0.8)
  414         self.interpreter.value.set(param='s2f', val=0.85)
  415         self.interpreter.value.set(param='s2s', val=0.7)
  416         self.interpreter.value.set(param='local_tm', val=8000e-12)
  417         self.interpreter.value.set(param='te', val=20e-12)
  418         self.interpreter.value.set(param='tf', val=40e-12)
  419         self.interpreter.value.set(param='ts', val=2000e-12)
  420         self.interpreter.value.set(param='rex', val=1.5e-18)
  421 
  422         # Create a temporary directory for dumping files.
  423         ds.tmpdir = mkdtemp()
  424 
  425         # Attempt to create the Molmol macros.
  426         self.interpreter.molmol.macro_write(data_type='s2',        dir=ds.tmpdir, force=True)
  427         self.interpreter.molmol.macro_write(data_type='s2f',       dir=ds.tmpdir, force=True)
  428         self.interpreter.molmol.macro_write(data_type='s2s',       dir=ds.tmpdir, force=True)
  429         self.interpreter.molmol.macro_write(data_type='amp_fast',  dir=ds.tmpdir, force=True)
  430         self.interpreter.molmol.macro_write(data_type='amp_slow',  dir=ds.tmpdir, force=True)
  431         self.interpreter.molmol.macro_write(data_type='te',        dir=ds.tmpdir, force=True)
  432         self.interpreter.molmol.macro_write(data_type='tf',        dir=ds.tmpdir, force=True)
  433         self.interpreter.molmol.macro_write(data_type='ts',        dir=ds.tmpdir, force=True)
  434         self.interpreter.molmol.macro_write(data_type='time_fast', dir=ds.tmpdir, force=True)
  435         self.interpreter.molmol.macro_write(data_type='time_slow', dir=ds.tmpdir, force=True)
  436         self.interpreter.molmol.macro_write(data_type='rex',       dir=ds.tmpdir, force=True)
  437 
  438         # Attempt to create the PyMOL macros.
  439         self.interpreter.pymol.macro_write(data_type='s2',        dir=ds.tmpdir, force=True)
  440         self.interpreter.pymol.macro_write(data_type='s2f',       dir=ds.tmpdir, force=True)
  441         self.interpreter.pymol.macro_write(data_type='s2s',       dir=ds.tmpdir, force=True)
  442         self.interpreter.pymol.macro_write(data_type='amp_fast',  dir=ds.tmpdir, force=True)
  443         self.interpreter.pymol.macro_write(data_type='amp_slow',  dir=ds.tmpdir, force=True)
  444         self.interpreter.pymol.macro_write(data_type='te',        dir=ds.tmpdir, force=True)
  445         self.interpreter.pymol.macro_write(data_type='tf',        dir=ds.tmpdir, force=True)
  446         self.interpreter.pymol.macro_write(data_type='ts',        dir=ds.tmpdir, force=True)
  447         self.interpreter.pymol.macro_write(data_type='time_fast', dir=ds.tmpdir, force=True)
  448         self.interpreter.pymol.macro_write(data_type='time_slow', dir=ds.tmpdir, force=True)
  449         self.interpreter.pymol.macro_write(data_type='rex',       dir=ds.tmpdir, force=True)
  450 
  451         # Attempt to create the Grace plots.
  452         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2',  file='s2.agr',        dir=ds.tmpdir, force=True)
  453         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2f', file='s2f.agr',       dir=ds.tmpdir, force=True)
  454         self.interpreter.grace.write(x_data_type='res_num', y_data_type='s2s', file='s2s.agr',       dir=ds.tmpdir, force=True)
  455         self.interpreter.grace.write(x_data_type='res_num', y_data_type='te',  file='te.agr',        dir=ds.tmpdir, force=True)
  456         self.interpreter.grace.write(x_data_type='res_num', y_data_type='tf',  file='tf.agr',        dir=ds.tmpdir, force=True)
  457         self.interpreter.grace.write(x_data_type='res_num', y_data_type='ts',  file='ts.agr',        dir=ds.tmpdir, force=True)
  458         self.interpreter.grace.write(x_data_type='res_num', y_data_type='rex', file='rex.agr',       dir=ds.tmpdir, force=True)
  459         self.interpreter.grace.write(x_data_type='s2',      y_data_type='te',  file='s2_vs_te.agr',  dir=ds.tmpdir, force=True)
  460         self.interpreter.grace.write(x_data_type='s2',      y_data_type='rex', file='s2_vs_rex.agr', dir=ds.tmpdir, force=True)
  461         self.interpreter.grace.write(x_data_type='te',      y_data_type='rex', file='te_vs_rex.agr', dir=ds.tmpdir, force=True)
  462 
  463         # Attempt to create the text files of the values.
  464         self.interpreter.value.write(param='s2',       file='s2.txt',       dir=ds.tmpdir, force=True)
  465         self.interpreter.value.write(param='s2f',      file='s2f.txt',      dir=ds.tmpdir, force=True)
  466         self.interpreter.value.write(param='s2s',      file='s2s.txt',      dir=ds.tmpdir, force=True)
  467         self.interpreter.value.write(param='te',       file='te.txt',       dir=ds.tmpdir, force=True)
  468         self.interpreter.value.write(param='tf',       file='tf.txt',       dir=ds.tmpdir, force=True)
  469         self.interpreter.value.write(param='ts',       file='ts.txt',       dir=ds.tmpdir, force=True)
  470         self.interpreter.value.write(param='rex',      file='rex.txt',      dir=ds.tmpdir, force=True)
  471         self.interpreter.value.write(param='local_tm', file='local_tm.txt', dir=ds.tmpdir, force=True)
  472 
  473 
  474     def test_bug_20613_auto_mf_diff_tensor_pdb(self):
  475         """U{Bug #20613<https://web.archive.org/web/https://gna.org/bugs/?20613>} catch, the failure of the auto-analysis due to diffusion tensor PDB creation for the local tm global model."""
  476 
  477         # Clear the data store.
  478         self.interpreter.reset()
  479 
  480         # Execute the script.
  481         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_20613_auto_mf_diff_tensor_pdb.py')
  482 
  483 
  484     def test_bug_20683_bdc_inf_values(self):
  485         """Catch U{bug #20683<https://web.archive.org/web/https://gna.org/bugs/?20683>}, the model-free analysis failure due to infinite values in the Bruker Dynamics Centre files."""
  486 
  487         # Clear the data store.
  488         self.interpreter.reset()
  489 
  490         # Execute the script.
  491         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_20683_bdc_inf_values.py')
  492 
  493 
  494     def test_bug_21079_local_tm_global_selection(self):
  495         """Test catching U{bug #21079<https://web.archive.org/web/https://gna.org/bugs/?21079>}, the local tm global model selection."""
  496 
  497         # Execute the script.
  498         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_21079_local_tm_global_selection.py')
  499 
  500 
  501     def test_bug_23933_relax_data_read_ids(self):
  502         """U{Bug #23933<https://web.archive.org/web/https://gna.org/bugs/?23933>} catch, the global name 'ids' is not defined error when loading relaxation data."""
  503 
  504         # Path of the files.
  505         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'bug_23933_relax_data_read_ids'
  506 
  507         # Load the truncated PDB file.
  508         self.interpreter.structure.read_pdb(file='LARA_N_term_no_helixFH_reg.pdb', dir=path)
  509 
  510         # Load the spin systems.
  511         self.interpreter.structure.load_spins(spin_id='@N')
  512         self.interpreter.structure.load_spins(spin_id='@H')
  513         self.interpreter.structure.load_spins(spin_id='@NE1')
  514         self.interpreter.structure.load_spins(spin_id='@HE1')
  515 
  516         # Load the relaxation data.
  517         self.assertRaises(RelaxMultiSpinIDError, self.interpreter.relax_data.read, ri_id='R1_600', ri_type='R1', frq=600402816.0, file='r1_600.txt', dir=path, res_num_col=1, data_col=2, error_col=3)
  518 
  519 
  520     def test_bug_24131_bmrb_deposition(self):
  521         """Test catching U{bug #24131<https://web.archive.org/web/https://gna.org/bugs/?24131>}, the BMRB export failure with the SpinContainer object having no s2 value."""
  522 
  523         # The output file.
  524         ds.tmpfile_handle, ds.tmpfile = mkstemp()
  525 
  526         # Execute the script.
  527         self.assertRaises(RelaxError, self.script_exec, status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_24131_bmrb_deposition.py')
  528 
  529 
  530     def test_bug_24131_missing_interaction(self):
  531         """Test catching U{bug #24131<https://web.archive.org/web/https://gna.org/bugs/?24131>}, the BMRB export failure with missing interatomic interactions."""
  532 
  533         # The output file.
  534         ds.tmpfile_handle, ds.tmpfile = mkstemp()
  535 
  536         # Execute the script.
  537         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'bug_24131_missing_interaction.py')
  538 
  539 
  540     def test_create_m4(self):
  541         """Creating model m4 with parameters {S2, te, Rex} using model_free.create_model()."""
  542 
  543         # Execute the script.
  544         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'create_m4.py')
  545 
  546         # Test the model.
  547         self.assertEqual(cdp.mol[0].res[1].spin[0].model, 'm4')
  548         self.assertEqual(cdp.mol[0].res[1].spin[0].params, ['s2', 'te', 'rex'])
  549 
  550 
  551     def test_data_loading_failures(self):
  552         """Catch a failure when loading relaxation data."""
  553 
  554         # The data directory.
  555         dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'sphere'
  556 
  557         # Set up the spin systems.
  558         self.interpreter.sequence.read(file='noe.500.out', dir=dir, spin_id_col=None, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, sep=None, spin_id=None)
  559 
  560         # Load the data.
  561         self.interpreter.relax_data.read(ri_id='noe500', ri_type='NOE', frq=500000000.0, file='noe.500.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id='@N')
  562 
  563 
  564     def test_dauvergne_protocol(self):
  565         """Check the execution of auto_analyses.dauvergne_protocol."""
  566 
  567         # Create a temporary directory for dumping files.
  568         ds.tmpdir = mkdtemp()
  569 
  570         # Execute the script.
  571         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'dauvergne_protocol.py')
  572 
  573         # Check the diffusion tensor.
  574         self.assertEqual(cdp.diff_tensor.type, 'sphere')
  575         self.assertAlmostEqual(cdp.diff_tensor.tm, 1e-8)
  576         self.assertEqual(cdp.diff_tensor.fixed, True)
  577 
  578         # The global minimisation info.
  579         self.assertAlmostEqual(cdp.chi2, 4e-19)
  580 
  581         # The spin info.
  582         mol_names = ["sphere_mol1"] * 20
  583         res_names = ["GLY"] * 20
  584         res_nums = []
  585         for i in range(1, 10):
  586             res_nums.append(i)
  587             res_nums.append(i)
  588         res_nums.append(i)
  589         res_nums.append(i)
  590         spin_names = ["N", "H"] * 9 + ["NE1", "HE1"]
  591         spin_nums = list(range(1, 21))
  592         isotopes = ["15N", "1H"] * 10
  593         csa = [-172e-6, None] * 10
  594         select = [True, False] * 10
  595         fixed = [False, False] * 10
  596         s2 = [0.8, None] * 10
  597         te = [20e-12, None] * 10
  598 
  599         # Check the spin data.
  600         i = 0
  601         for spin, mol_name, res_num, res_name in spin_loop(full_info=True):
  602             # The ID info.
  603             self.assertEqual(mol_name, mol_names[i])
  604             self.assertEqual(res_name, res_names[i])
  605             self.assertEqual(res_num,  res_nums[i])
  606             self.assertEqual(spin.name, spin_names[i])
  607             self.assertEqual(spin.num,  spin_nums[i])
  608 
  609             # The data.
  610             self.assertEqual(spin.select, select[i])
  611             self.assertEqual(spin.fixed, fixed[i])
  612             self.assertEqual(spin.isotope, isotopes[i])
  613             if csa[i] == None:
  614                 self.assertEqual(spin.csa, None)
  615             else:
  616                 self.assertAlmostEqual(spin.csa, csa[i])
  617 
  618             # The model-free data.
  619             self.assertEqual(spin.model, 'm2')
  620             self.assertEqual(spin.equation, 'mf_orig')
  621             self.assertEqual(len(spin.params), 2)
  622             self.assertEqual(spin.params[0], 's2')
  623             self.assertEqual(spin.params[1], 'te')
  624             if s2[i] == None:
  625                 self.assertEqual(spin.s2, None)
  626             else:
  627                 self.assertAlmostEqual(spin.s2, 0.8)
  628             self.assertEqual(spin.s2f, None)
  629             self.assertEqual(spin.s2s, None)
  630             self.assertEqual(spin.local_tm, None)
  631             if te[i] == None:
  632                 self.assertEqual(spin.te, None)
  633             else:
  634                 self.assertAlmostEqual(spin.te, 20e-12)
  635             self.assertEqual(spin.tf, None)
  636             self.assertEqual(spin.ts, None)
  637             self.assertEqual(spin.rex, None)
  638 
  639             # The spin minimisation info.
  640             self.assertEqual(spin.chi2, None)
  641             self.assertEqual(spin.iter, None)
  642             self.assertEqual(spin.f_count, None)
  643             self.assertEqual(spin.g_count, None)
  644             self.assertEqual(spin.h_count, None)
  645             self.assertEqual(spin.warning, None)
  646 
  647             # Increment the index.
  648             i += 1
  649 
  650         # Check the interatomic data.
  651         i = 0
  652         for interatom in interatomic_loop():
  653             self.assertAlmostEqual(interatom.r, 1.02 * 1e-10)
  654 
  655         # File and directory formatting strings.
  656         format1 = "%s%s%s" % (ds.tmpdir, sep, '%s')
  657         format2 = "%s%s%s%s%s" % (ds.tmpdir, sep, '%s', sep, '%s')
  658         format3 = "%s%s%s%s%s%s%s" % (ds.tmpdir, sep, '%s', sep, '%s', sep, '%s')
  659         format4 = "%s%s%s%s%s%s%s%s%s" % (ds.tmpdir, sep, '%s', sep, '%s', sep, '%s', sep, '%s')
  660 
  661         # Check the generated directories.
  662         dirs = [
  663             format1 % ("local_tm"),
  664             format2 % ("local_tm", "tm1"),
  665             format2 % ("local_tm", "tm0"),
  666             format2 % ("local_tm", "aic"),
  667             format1 % ("sphere"),
  668             format2 % ("sphere", "init"),
  669             format2 % ("sphere", "round_1"),
  670             format3 % ("sphere", "round_1", "m1"),
  671             format3 % ("sphere", "round_1", "m2"),
  672             format3 % ("sphere", "round_1", "aic"),
  673             format3 % ("sphere", "round_1", "opt"),
  674             format2 % ("sphere", "round_2"),
  675             format3 % ("sphere", "round_2", "m1"),
  676             format3 % ("sphere", "round_2", "m2"),
  677             format3 % ("sphere", "round_2", "aic"),
  678             format3 % ("sphere", "round_2", "opt"),
  679             format1 % ("prolate"),
  680             format2 % ("prolate", "init"),
  681             format2 % ("prolate", "round_1"),
  682             format3 % ("prolate", "round_1", "m1"),
  683             format3 % ("prolate", "round_1", "m2"),
  684             format3 % ("prolate", "round_1", "aic"),
  685             format3 % ("prolate", "round_1", "opt"),
  686             format2 % ("prolate", "round_2"),
  687             format3 % ("prolate", "round_2", "m1"),
  688             format3 % ("prolate", "round_2", "m2"),
  689             format3 % ("prolate", "round_2", "aic"),
  690             format3 % ("prolate", "round_2", "opt"),
  691             format1 % ("oblate"),
  692             format2 % ("oblate", "init"),
  693             format2 % ("oblate", "round_1"),
  694             format3 % ("oblate", "round_1", "m1"),
  695             format3 % ("oblate", "round_1", "m2"),
  696             format3 % ("oblate", "round_1", "aic"),
  697             format3 % ("oblate", "round_1", "opt"),
  698             format2 % ("oblate", "round_2"),
  699             format3 % ("oblate", "round_2", "m1"),
  700             format3 % ("oblate", "round_2", "m2"),
  701             format3 % ("oblate", "round_2", "aic"),
  702             format3 % ("oblate", "round_2", "opt"),
  703             format1 % ("ellipsoid"),
  704             format2 % ("ellipsoid", "init"),
  705             format2 % ("ellipsoid", "round_1"),
  706             format3 % ("ellipsoid", "round_1", "m1"),
  707             format3 % ("ellipsoid", "round_1", "m2"),
  708             format3 % ("ellipsoid", "round_1", "aic"),
  709             format3 % ("ellipsoid", "round_1", "opt"),
  710             format2 % ("ellipsoid", "round_2"),
  711             format3 % ("ellipsoid", "round_2", "m1"),
  712             format3 % ("ellipsoid", "round_2", "m2"),
  713             format3 % ("ellipsoid", "round_2", "aic"),
  714             format3 % ("ellipsoid", "round_2", "opt"),
  715             format1 % ("final"),
  716             format2 % ("final", "grace"),
  717             format2 % ("final", "pymol"),
  718             format2 % ("final", "molmol")
  719         ]
  720         for root, dirs, files in walk(ds.tmpdir):
  721             for dir in dirs:
  722                 dir_path = "%s%s%s" % (root, sep, dir)
  723                 print("Checking for the directory '%s'." % dir_path)
  724                 self.assert_(path.isdir(dir_path))
  725 
  726         # Check the generated files.
  727         files = [
  728             format3 % ("local_tm", "tm0", "results.bz2"),
  729             format3 % ("local_tm", "tm1", "results.bz2"),
  730             format3 % ("local_tm", "aic", "results.bz2"),
  731             format3 % ("sphere", "init", "results.bz2"),
  732             format4 % ("sphere", "round_1", "m1", "results.bz2"),
  733             format4 % ("sphere", "round_1", "m2", "results.bz2"),
  734             format4 % ("sphere", "round_1", "aic", "results.bz2"),
  735             format4 % ("sphere", "round_1", "opt", "results.bz2"),
  736             format4 % ("sphere", "round_2", "m1", "results.bz2"),
  737             format4 % ("sphere", "round_2", "m2", "results.bz2"),
  738             format4 % ("sphere", "round_2", "aic", "results.bz2"),
  739             format4 % ("sphere", "round_2", "opt", "results.bz2"),
  740             format3 % ("prolate", "init", "results.bz2"),
  741             format4 % ("prolate", "round_1", "m1", "results.bz2"),
  742             format4 % ("prolate", "round_1", "m2", "results.bz2"),
  743             format4 % ("prolate", "round_1", "aic", "results.bz2"),
  744             format4 % ("prolate", "round_1", "opt", "results.bz2"),
  745             format4 % ("prolate", "round_2", "m1", "results.bz2"),
  746             format4 % ("prolate", "round_2", "m2", "results.bz2"),
  747             format4 % ("prolate", "round_2", "aic", "results.bz2"),
  748             format4 % ("prolate", "round_2", "opt", "results.bz2"),
  749             format3 % ("oblate", "init", "results.bz2"),
  750             format4 % ("oblate", "round_1", "m1", "results.bz2"),
  751             format4 % ("oblate", "round_1", "m2", "results.bz2"),
  752             format4 % ("oblate", "round_1", "aic", "results.bz2"),
  753             format4 % ("oblate", "round_1", "opt", "results.bz2"),
  754             format4 % ("oblate", "round_2", "m1", "results.bz2"),
  755             format4 % ("oblate", "round_2", "m2", "results.bz2"),
  756             format4 % ("oblate", "round_2", "aic", "results.bz2"),
  757             format4 % ("oblate", "round_2", "opt", "results.bz2"),
  758             format3 % ("ellipsoid", "init", "results.bz2"),
  759             format4 % ("ellipsoid", "round_1", "m1", "results.bz2"),
  760             format4 % ("ellipsoid", "round_1", "m2", "results.bz2"),
  761             format4 % ("ellipsoid", "round_1", "aic", "results.bz2"),
  762             format4 % ("ellipsoid", "round_1", "opt", "results.bz2"),
  763             format4 % ("ellipsoid", "round_2", "m1", "results.bz2"),
  764             format4 % ("ellipsoid", "round_2", "m2", "results.bz2"),
  765             format4 % ("ellipsoid", "round_2", "aic", "results.bz2"),
  766             format4 % ("ellipsoid", "round_2", "opt", "results.bz2"),
  767             format2 % ("final", "results.bz2"),
  768             format2 % ("final", "s2.txt"),
  769             format2 % ("final", "s2f.txt"),
  770             format2 % ("final", "s2s.txt"),
  771             format2 % ("final", "local_tm.txt"),
  772             format2 % ("final", "te.txt"),
  773             format2 % ("final", "tf.txt"),
  774             format2 % ("final", "ts.txt"),
  775             format2 % ("final", "rex.txt"),
  776             format2 % ("final", "rex_500.txt"),
  777             format2 % ("final", "rex_900.txt"),
  778             format2 % ("final", "tensor.pdb"),
  779             format3 % ("final", "grace", "s2.agr"),
  780             format3 % ("final", "grace", "s2f.agr"),
  781             format3 % ("final", "grace", "s2s.agr"),
  782             format3 % ("final", "grace", "te.agr"),
  783             format3 % ("final", "grace", "tf.agr"),
  784             format3 % ("final", "grace", "ts.agr"),
  785             format3 % ("final", "grace", "rex.agr"),
  786             format3 % ("final", "grace", "s2_vs_rex.agr"),
  787             format3 % ("final", "grace", "s2_vs_te.agr"),
  788             format3 % ("final", "grace", "te_vs_rex.agr"),
  789             format3 % ("final", "pymol", "s2.pml"),
  790             format3 % ("final", "pymol", "s2f.pml"),
  791             format3 % ("final", "pymol", "s2s.pml"),
  792             format3 % ("final", "pymol", "amp_fast.pml"),
  793             format3 % ("final", "pymol", "amp_slow.pml"),
  794             format3 % ("final", "pymol", "te.pml"),
  795             format3 % ("final", "pymol", "tf.pml"),
  796             format3 % ("final", "pymol", "ts.pml"),
  797             format3 % ("final", "pymol", "time_fast.pml"),
  798             format3 % ("final", "pymol", "time_slow.pml"),
  799             format3 % ("final", "pymol", "rex.pml"),
  800             format3 % ("final", "molmol", "s2.mac"),
  801             format3 % ("final", "molmol", "s2f.mac"),
  802             format3 % ("final", "molmol", "s2s.mac"),
  803             format3 % ("final", "molmol", "amp_fast.mac"),
  804             format3 % ("final", "molmol", "amp_slow.mac"),
  805             format3 % ("final", "molmol", "te.mac"),
  806             format3 % ("final", "molmol", "tf.mac"),
  807             format3 % ("final", "molmol", "ts.mac"),
  808             format3 % ("final", "molmol", "time_fast.mac"),
  809             format3 % ("final", "molmol", "time_slow.mac"),
  810             format3 % ("final", "molmol", "rex.mac"),
  811         ]
  812         for root, dirs, files in walk(ds.tmpdir):
  813             for file in files:
  814                 file_path = "%s%s%s" % (root, sep, file)
  815                 print("Checking for the file '%s'." % file_path)
  816                 self.assert_(path.isfile(file_path))
  817 
  818 
  819     def test_dauvergne_protocol_sphere(self):
  820         """Catch a failure when loading relaxation data."""
  821 
  822         # The data directory.
  823         dir = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'sphere'
  824 
  825         # Reset relax.
  826         self.interpreter.reset()
  827 
  828         # Set up a data pipe and bundle.
  829         self.interpreter.pipe.create('sphere test', 'mf', bundle='sphere test')
  830 
  831         # Load the sequence.
  832         self.interpreter.sequence.read(file='noe.500.out', dir=dir, spin_id_col=None, mol_name_col=1, res_num_col=2, res_name_col=3, spin_num_col=4, spin_name_col=5, sep=None, spin_id=None)
  833 
  834         # Load the relaxation data.
  835         self.interpreter.relax_data.read(ri_id='r1.500', ri_type='R1', frq=500000000.0, file='r1.500.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  836         self.interpreter.relax_data.read(ri_id='r2.500', ri_type='R2', frq=500000000.0, file='r2.500.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  837         self.interpreter.relax_data.read(ri_id='noe.500', ri_type='NOE', frq=500000000.0, file='noe.500.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  838         self.interpreter.relax_data.read(ri_id='r1.900', ri_type='R1', frq=900000000.0, file='r1.900.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  839         self.interpreter.relax_data.read(ri_id='r2.900', ri_type='R2', frq=900000000.0, file='r2.900.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  840         self.interpreter.relax_data.read(ri_id='noe.900', ri_type='NOE', frq=900000000.0, file='noe.900.out', dir=dir, spin_id_col=None, 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, sep=None, spin_id=None)
  841         self.interpreter.relax_data.peak_intensity_type(ri_id='noe.900', type='height')
  842         self.interpreter.relax_data.peak_intensity_type(ri_id='r2.900', type='height')
  843         self.interpreter.relax_data.peak_intensity_type(ri_id='r1.900', type='height')
  844         self.interpreter.relax_data.peak_intensity_type(ri_id='noe.500', type='height')
  845         self.interpreter.relax_data.peak_intensity_type(ri_id='r2.500', type='height')
  846         self.interpreter.relax_data.peak_intensity_type(ri_id='r1.500', type='height')
  847         self.interpreter.relax_data.peak_intensity_type(ri_id='r1.500', type='height')
  848 
  849         # Set up the interatomic interactions.
  850         self.interpreter.structure.read_pdb(file='sphere.pdb', dir=dir, read_mol=None, set_mol_name=None, read_model=None, set_model_num=None, alt_loc=None, verbosity=1, merge=False)
  851         self.interpreter.structure.get_pos(spin_id=None, ave_pos=True)
  852         self.interpreter.interatom.define(spin_id1='@N*', spin_id2='@H*', direct_bond=True, spin_selection=True, pipe=None)
  853         self.interpreter.interatom.set_dist(spin_id1='@N*', spin_id2='@H*', ave_dist=1.02e-10, unit='meter')
  854         self.interpreter.interatom.unit_vectors(ave=True)
  855 
  856         # Set the CSA value.
  857         self.interpreter.value.set(val=-0.000172, param='csa', index=0, spin_id='@N*', error=False, force=True)
  858 
  859         # Set up the isotope information.
  860         self.interpreter.spin.isotope(isotope='15N', spin_id='@N*', force=True)
  861         self.interpreter.spin.isotope(isotope='1H', spin_id='@H*', force=True)
  862 
  863         # Create a temporary directory for dumping files.
  864         ds.tmpdir = mkdtemp()
  865 
  866         # The dauvergne_protocol model-free auto-analysis.
  867         dAuvergne_protocol(pipe_name='sphere test', pipe_bundle='sphere test', results_dir=ds.tmpdir, diff_model=['local_tm', 'sphere'], mf_models=['m1', 'm2'], local_tm_models=['tm0', 'tm1'], grid_inc=3, diff_tensor_grid_inc={'sphere': 5, 'prolate': 5, 'oblate': 5, 'ellipsoid': 3}, min_algor='newton', mc_sim_num=2, max_iter=1, conv_loop=True)
  868 
  869 
  870     def test_generate_ri(self):
  871         """Back-calculate relaxation data."""
  872 
  873         # Execute the script.
  874         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'generate_ri.py')
  875 
  876 
  877     def test_latex_table(self):
  878         """Test the creation of a LaTeX table of model-free results, mimicking the latex_mf_table.py sample script."""
  879 
  880         # Execute the script.
  881         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'latex_mf_table.py')
  882 
  883 
  884     def test_local_tm_10_S2_0_8_te_40(self):
  885         """Test the optimisation of the test set {tm=10, S2=0.8, te=40}."""
  886 
  887         # Setup the data pipe for optimisation.
  888         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_local_tm_10_S2_0_8_te_40.py')
  889 
  890         # The proton frequencies in MHz.
  891         frq = ['400', '500', '600', '700', '800', '900', '1000']
  892 
  893         # Load the relaxation data.
  894         for i in range(len(frq)):
  895             self.interpreter.relax_data.read('NOE_%s'%frq[i], 'NOE', float(frq[i])*1e6, 'noe.%s.out' % frq[i], dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  896             self.interpreter.relax_data.read('R1_%s'%frq[i],  'R1',  float(frq[i])*1e6, 'r1.%s.out' % frq[i],  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  897             self.interpreter.relax_data.read('R2_%s'%frq[i],  'R2',  float(frq[i])*1e6, 'r2.%s.out' % frq[i],  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  898 
  899         # Set up the initial model-free parameter values (bypass the grid search for speed).
  900         self.interpreter.value.set([15.0e-9, 1.0, 0.0], ['local_tm', 's2', 'te'])
  901 
  902         # Minimise.
  903         self.interpreter.minimise.execute('newton', 'gmw', 'back')
  904 
  905         # Alias the relevent spin container.
  906         spin = cdp.mol[0].res[0].spin[0]
  907 
  908         # Check the values.
  909         self.value_test(spin, local_tm=10, s2=0.8, te=40, chi2=0.0)
  910 
  911 
  912     def test_local_tm_10_S2_0_8_te_40_test2(self):
  913         """Test the optimisation of the test set {tm=10, S2=0.8, te=40}."""
  914 
  915         # Setup the data pipe for optimisation.
  916         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_local_tm_10_S2_0_8_te_40.py')
  917 
  918         # The proton frequencies in MHz.
  919         frq = ['400', '500', '600', '700', '800', '900', '1000']
  920 
  921         # Load the relaxation data.
  922         for i in range(len(frq)):
  923             self.interpreter.relax_data.read('NOE_%s'%frq[i], 'NOE', float(frq[i])*1e6, 'noe.%s.out' % frq[i], dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  924             self.interpreter.relax_data.read('R1_%s'%frq[i],  'R1',  float(frq[i])*1e6, 'r1.%s.out' % frq[i],  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  925             self.interpreter.relax_data.read('R2_%s'%frq[i],  'R2',  float(frq[i])*1e6, 'r2.%s.out' % frq[i],  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  926 
  927         # Set up the initial model-free parameter values (bypass the grid search for speed).
  928         self.interpreter.value.set([15.0e-9, 1.0, 0.0], ['local_tm', 's2', 'te'])
  929 
  930         # Minimise.
  931         self.interpreter.minimise.execute('newton', 'gmw', 'back')
  932 
  933         # Alias the relevent spin container.
  934         spin = cdp.mol[0].res[0].spin[0]
  935 
  936         # Check the values.
  937         self.value_test(spin, local_tm=10, s2=0.8, te=40, chi2=0.0)
  938 
  939 
  940     def test_local_tm_10_S2_0_8_te_40_test3(self):
  941         """Test the optimisation of the test set {tm=10, S2=0.8, te=40}."""
  942 
  943         # Setup the data pipe for optimisation.
  944         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_local_tm_10_S2_0_8_te_40.py')
  945 
  946         # Load the relaxation data.
  947         self.interpreter.relax_data.read('R2_700',  'R2',  700*1e6, 'r2.700.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  948         self.interpreter.relax_data.read('NOE_500', 'NOE', 500*1e6, 'noe.500.out', dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  949         self.interpreter.relax_data.read('R1_500',  'R1',  500*1e6, 'r1.500.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  950         self.interpreter.relax_data.read('R1_900',  'R1',  900*1e6, 'r1.900.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  951         self.interpreter.relax_data.read('NOE_900', 'NOE', 900*1e6, 'noe.900.out', dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  952         self.interpreter.relax_data.read('R2_900',  'R2',  900*1e6, 'r2.900.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  953         self.interpreter.relax_data.read('R1_700',  'R1',  700*1e6, 'r1.700.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  954         self.interpreter.relax_data.read('NOE_700', 'NOE', 700*1e6, 'noe.700.out', dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  955         self.interpreter.relax_data.read('R2_500',  'R2',  500*1e6, 'r2.500.out',  dir=cdp.path, res_num_col=1, res_name_col=2, data_col=3, error_col=4, spin_id='@N')
  956 
  957         # Set up the initial model-free parameter values (bypass the grid search for speed).
  958         self.interpreter.value.set([15.0e-9, 1.0, 0.0], ['local_tm', 's2', 'te'])
  959 
  960         # Minimise.
  961         self.interpreter.minimise.execute('newton', 'gmw', 'back')
  962 
  963         # Alias the relevent spin container.
  964         spin = cdp.mol[0].res[0].spin[0]
  965 
  966         # Check the values.
  967         self.value_test(spin, local_tm=10, s2=0.8, te=40, chi2=0.0)
  968 
  969 
  970     def test_m0_grid(self):
  971         """Test the optimisation of the m0 model-free model against the tm0 parameter grid."""
  972 
  973         # Initialise.
  974         cdp._model = 'm0'
  975         cdp._value_test = self.value_test
  976 
  977         # Setup the data pipe for optimisation.
  978         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
  979 
  980 
  981     def test_m0_grid_with_grid_search(self):
  982         """Test the optimisation of the m0 model-free model against the tm0 parameter grid, testing the grid search."""
  983 
  984         # Initialise.
  985         cdp._model = 'm0'
  986         cdp._value_test = self.value_test
  987         cdp._grid_search = True
  988 
  989         # Setup the data pipe for optimisation.
  990         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
  991 
  992 
  993     def test_m0_grid_vs_m1(self):
  994         """Test the optimisation of the m1 model-free model against the tm0 parameter grid."""
  995 
  996         # Initialise.
  997         cdp._model = 'm1'
  998         cdp._value_test = self.value_test
  999 
 1000         # Setup the data pipe for optimisation.
 1001         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 1002 
 1003 
 1004     def test_m0_grid_vs_m1_with_grid_search(self):
 1005         """Test the optimisation of the m1 model-free model against the tm0 parameter grid."""
 1006 
 1007         # Initialise.
 1008         cdp._model = 'm1'
 1009         cdp._value_test = self.value_test
 1010         cdp._grid_search = True
 1011 
 1012         # Setup the data pipe for optimisation.
 1013         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 1014 
 1015 
 1016     def test_m0_grid_vs_m2(self):
 1017         """Test the optimisation of the m2 model-free model against the tm0 parameter grid."""
 1018 
 1019         # Initialise.
 1020         cdp._model = 'm2'
 1021         cdp._value_test = self.value_test
 1022 
 1023         # Setup the data pipe for optimisation.
 1024         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 1025 
 1026 
 1027     def test_m0_grid_vs_m3(self):
 1028         """Test the optimisation of the m3 model-free model against the tm0 parameter grid."""
 1029 
 1030         # Initialise.
 1031         cdp._model = 'm3'
 1032         cdp._value_test = self.value_test
 1033 
 1034         # Setup the data pipe for optimisation.
 1035         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 1036 
 1037 
 1038     def test_m0_grid_vs_m4(self):
 1039         """Test the optimisation of the m4 model-free model against the tm0 parameter grid."""
 1040 
 1041         # Initialise.
 1042         cdp._model = 'm4'
 1043         cdp._value_test = self.value_test
 1044 
 1045         # Setup the data pipe for optimisation.
 1046         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 1047 
 1048 
 1049     def test_m1_grid(self):
 1050         """Test the optimisation of the m1 model-free model against the tm1 parameter grid."""
 1051 
 1052         # Initialise.
 1053         cdp._model = 'm1'
 1054         cdp._value_test = self.value_test
 1055 
 1056         # Setup the data pipe for optimisation.
 1057         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm1_grid.py')
 1058 
 1059 
 1060     def test_m2_grid(self):
 1061         """Test the optimisation of the m2 model-free model against the tm2 parameter grid."""
 1062 
 1063         # Initialise.
 1064         cdp._model = 'm2'
 1065         cdp._value_test = self.value_test
 1066 
 1067         # Setup the data pipe for optimisation.
 1068         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm2_grid.py')
 1069 
 1070 
 1071     def test_m2_grid_vs_m4(self):
 1072         """Test the optimisation of the m4 model-free model against the tm2 parameter grid."""
 1073 
 1074         # Initialise.
 1075         cdp._model = 'm4'
 1076         cdp._value_test = self.value_test
 1077 
 1078         # Setup the data pipe for optimisation.
 1079         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm2_grid.py')
 1080 
 1081 
 1082     def test_m3_grid(self):
 1083         """Test the optimisation of the m3 model-free model against the tm3 parameter grid."""
 1084 
 1085         # Initialise.
 1086         cdp._model = 'm3'
 1087         cdp._value_test = self.value_test
 1088 
 1089         # Setup the data pipe for optimisation.
 1090         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm3_grid.py')
 1091 
 1092 
 1093     def test_m4_grid(self):
 1094         """Test the optimisation of the m4 model-free model against the tm4 parameter grid."""
 1095 
 1096         # Initialise.
 1097         cdp._model = 'm4'
 1098         cdp._value_test = self.value_test
 1099 
 1100         # Setup the data pipe for optimisation.
 1101         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm4_grid.py')
 1102 
 1103 
 1104     def test_m5_grid(self):
 1105         """Test the optimisation of the m5 model-free model against the tm5 parameter grid."""
 1106 
 1107         # Initialise.
 1108         cdp._model = 'm5'
 1109         cdp._value_test = self.value_test
 1110 
 1111         # Setup the data pipe for optimisation.
 1112         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm5_grid.py')
 1113 
 1114 
 1115     def test_m6_grid(self):
 1116         """Test the optimisation of the m6 model-free model against the tm6 parameter grid."""
 1117 
 1118         # Initialise.
 1119         cdp._model = 'm6'
 1120         cdp._value_test = self.value_test
 1121 
 1122         # Setup the data pipe for optimisation.
 1123         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm6_grid.py')
 1124 
 1125 
 1126     def test_m7_grid(self):
 1127         """Test the optimisation of the m7 model-free model against the tm7 parameter grid."""
 1128 
 1129         # Initialise.
 1130         cdp._model = 'm7'
 1131         cdp._value_test = self.value_test
 1132 
 1133         # Setup the data pipe for optimisation.
 1134         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm7_grid.py')
 1135 
 1136 
 1137     def test_m8_grid(self):
 1138         """Test the optimisation of the m8 model-free model against the tm8 parameter grid."""
 1139 
 1140         # Initialise.
 1141         cdp._model = 'm8'
 1142         cdp._value_test = self.value_test
 1143 
 1144         # Setup the data pipe for optimisation.
 1145         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm8_grid.py')
 1146 
 1147 
 1148     def test_m9_grid(self):
 1149         """Test the optimisation of the m9 model-free model against the tm9 parameter grid."""
 1150 
 1151         # Initialise.
 1152         cdp._model = 'm9'
 1153         cdp._value_test = self.value_test
 1154 
 1155         # Setup the data pipe for optimisation.
 1156         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm9_grid.py')
 1157 
 1158 
 1159     def test_omp_analysis(self):
 1160         """Try a very minimal model-free analysis on the OMP relaxation data."""
 1161 
 1162         # Execute the script.
 1163         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'omp_model_free.py')
 1164 
 1165         # Alias the final data pipe.
 1166         dp = pipes.get_pipe('final')
 1167 
 1168         # Some checks.
 1169         self.assertEqual(dp.mol[0].res[0].spin[0].select_sim, [True, False, True])
 1170         self.assertEqual(dp.mol[0].res[1].spin[0].select_sim, [True, True, False])
 1171         self.assertEqual(dp.mol[0].res[2].spin[0].select_sim, [True, True, True])
 1172         self.assert_(not hasattr(dp.mol[0].res[3].spin[0], 'select_sim'))
 1173 
 1174 
 1175     def test_opendx_s2_te_rex(self):
 1176         """Mapping the {S2, te, Rex} chi2 space through the OpenDX user function dx.map()."""
 1177 
 1178         # Execute the script.
 1179         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opendx_s2_te_rex.py')
 1180 
 1181 
 1182     def test_opendx_theta_phi_da(self):
 1183         """Mapping the {theta, phi, Da} chi2 space through the OpenDX user function dx.map()."""
 1184 
 1185         # Path of the files.
 1186         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'
 1187 
 1188         # Read the PDF file and set the vectors.
 1189         self.interpreter.structure.read_pdb(file='pdb', dir=path, read_model=1)
 1190 
 1191         # Load all N spins.
 1192         self.interpreter.structure.load_spins('@N')
 1193 
 1194         # Read the relaxation data.
 1195         self.interpreter.relax_data.read('R1_600',  'R1',  600.0*1e6, 'r1.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1196         self.interpreter.relax_data.read('R2_600',  'R2',  600.0*1e6, 'r2.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1197         self.interpreter.relax_data.read('NOE_600', 'NOE', 600.0*1e6, 'noe.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1198         self.interpreter.relax_data.read('R1_500',  'R1',  500.0*1e6, 'r1.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1199         self.interpreter.relax_data.read('R2_500',  'R2',  500.0*1e6, 'r2.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1200         self.interpreter.relax_data.read('NOE_500', 'NOE', 500.0*1e6, 'noe.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1201 
 1202         # Set up the diffusion tensor.
 1203         self.interpreter.diffusion_tensor.init((1.601 * 1e7, 1.34, 72.4, 90-77.9), param_types=4)
 1204 
 1205         # Define the magnetic dipole-dipole relaxation interaction.
 1206         self.interpreter.structure.load_spins('@H')
 1207         self.interpreter.interatom.define(spin_id1='@N', spin_id2='@H', direct_bond=True)
 1208         self.interpreter.interatom.set_dist(spin_id1='@N', spin_id2='@H', ave_dist=1.02 * 1e-10)
 1209         self.interpreter.interatom.unit_vectors()
 1210 
 1211         # Set up the spin parameters.
 1212         self.interpreter.value.set(N15_CSA, 'csa')
 1213         self.interpreter.value.set([0.8, 50 * 1e-12, 0.0], ['s2', 'te', 'rex'])
 1214 
 1215         # Set the spin information.
 1216         self.interpreter.spin.isotope('15N', spin_id='@N')
 1217         self.interpreter.spin.isotope('1H', spin_id='@H')
 1218 
 1219         # Select the model.
 1220         self.interpreter.model_free.select_model(model='m4')
 1221 
 1222         # Map the space.
 1223         self.interpreter.dx.map(params=['theta', 'phi', 'Da'], spin_id='#pdb_mol1:2@N', inc=2, lower=[0, 0, -0.5*1e7], upper=[pi, 2.0*pi, 1.0*1e7], file_prefix='devnull')
 1224 
 1225 
 1226     def test_opendx_tm_s2_te(self):
 1227         """Mapping the {local_tm, S2, te} chi2 space through the OpenDX user function dx.map()."""
 1228 
 1229         # Path of the files.
 1230         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'
 1231 
 1232         # Read the sequence.
 1233         self.interpreter.sequence.read(file='noe.500.out', dir=path, res_num_col=1, res_name_col=2)
 1234 
 1235         # Read the relaxation data.
 1236         self.interpreter.relax_data.read('R1_600',  'R1',  600.0*1e6, 'r1.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1237         self.interpreter.relax_data.read('R2_600',  'R2',  600.0*1e6, 'r2.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1238         self.interpreter.relax_data.read('NOE_600', 'NOE', 600.0*1e6, 'noe.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1239         self.interpreter.relax_data.read('R1_500',  'R1',  500.0*1e6, 'r1.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1240         self.interpreter.relax_data.read('R2_500',  'R2',  500.0*1e6, 'r2.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1241         self.interpreter.relax_data.read('NOE_500', 'NOE', 500.0*1e6, 'noe.500.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 1242 
 1243         # Name the spins and set the element type.
 1244         self.interpreter.spin.name('N')
 1245         self.interpreter.spin.element('N')
 1246 
 1247         # Create all attached protons.
 1248         self.interpreter.sequence.attach_protons()
 1249 
 1250         # Define the magnetic dipole-dipole relaxation interaction.
 1251         self.interpreter.interatom.define(spin_id1='@N', spin_id2='@H', direct_bond=True)
 1252         self.interpreter.interatom.set_dist(spin_id1='@N', spin_id2='@H', ave_dist=1.02 * 1e-10)
 1253 
 1254         # Set up the CSA value.
 1255         self.interpreter.value.set(N15_CSA, 'csa')
 1256 
 1257         # Set the spin information.
 1258         self.interpreter.spin.isotope('15N', spin_id='@N')
 1259         self.interpreter.spin.isotope('1H', spin_id='@H')
 1260 
 1261         # Select the model.
 1262         self.interpreter.model_free.select_model(model='tm2')
 1263 
 1264         # Map the space.
 1265         self.interpreter.dx.map(params=['local_tm', 's2', 'te'], spin_id=':2@N', inc=2, lower=[5e-9, 0.0, 0.0], file_prefix='devnull')
 1266 
 1267 
 1268     def test_opt_constr_bfgs_back_S2_0_970_te_2048_Rex_0_149(self):
 1269         """Constrained BFGS opt, backtracking line search {S2=0.970, te=2048, Rex=0.149}
 1270 
 1271         The optimisation options are:
 1272             - BFGS optimisation.
 1273             - Backtracking line search.
 1274             - Constrained.
 1275 
 1276         The true data set is:
 1277             - S2  = 0.970
 1278             - te  = 2048 ps
 1279             - Rex = 0.149 s^-1
 1280 
 1281         Relevant links for this test are:
 1282             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-devel/2009-05/msg00003.html}
 1283             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2011-01/msg00029.html}
 1284             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573}
 1285             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html}
 1286             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14173}
 1287         """
 1288 
 1289         # Setup the data pipe for optimisation.
 1290         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 1291 
 1292         # Set up the initial model-free parameter values (bypass the grid search for speed).
 1293         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 1294 
 1295         # Minimise.
 1296         self.interpreter.minimise.execute('bfgs', 'back')
 1297 
 1298         # Alias the relevent spin container.
 1299         spin = cdp.mol[0].res[1].spin[0]
 1300 
 1301         # Optimisation differences.
 1302         ###########################
 1303 
 1304         # 32-bit Linux.
 1305         # iter: 203
 1306         # f_count: 955
 1307         # g_count: 209
 1308 
 1309         # 32-bit i686 Linux (https://web.archive.org/web/https://mail.gna.org/public/relax-devel/2009-05/msg00003.html).
 1310         # System: Linux
 1311         # Release: 2.6.28-gentoo-r5
 1312         # Version: #1 SMP Sat Apr 25 13:31:51 EDT 2009
 1313         # Win32 version:
 1314         # Distribution:
 1315         # Architecture: 32bit ELF
 1316         # Machine: i686
 1317         # Processor: Intel(R) Pentium(R) M processor 1.80GHz
 1318         # Python version: 2.5.4
 1319         # numpy version: 1.2.1
 1320         # 
 1321         # s2:       0.9700000000012307
 1322         # te:       2048.0000002299716
 1323         # rex:      0.14899999997647859
 1324         # chi2:     1.9223825944220359e-20
 1325         # iter:     157
 1326         # f_count:  722
 1327         # g_count:  164
 1328         # h_count:  0
 1329         # warning:  None
 1330 
 1331         # 32-bit i686 Linux.
 1332         # System:           Linux                    
 1333         # Release:          2.6.33.7-desktop-2mnb    
 1334         # Version:          #1 SMP Mon Sep 20 19:00:25 UTC 2010
 1335         # Win32 version:                             
 1336         # Distribution:     mandrake 2010.2 Official 
 1337         # Architecture:     32bit ELF                
 1338         # Machine:          i686                     
 1339         # Processor:        i686                     
 1340         # Python version:   2.6.5                    
 1341         # Numpy version:    1.4.1                    
 1342         # Libc version:     glibc 2.0                
 1343         # 
 1344         # s2:                         0.9700000000016741
 1345         # te (ps):                        2048.000000312
 1346         # rex:                       0.14899999996808433
 1347         # chi2:                   3.5466670276032307e-20
 1348         # iter:                                      158
 1349         # f_count:                                   744
 1350         # g_count:                                   165
 1351         # h_count:                                     0
 1352         # warning:                                  None
 1353 
 1354         # 32-bit i686 Linux.
 1355         # System:           Linux                    
 1356         # Release:          2.6.33.7-desktop-2mnb    
 1357         # Version:          #1 SMP Mon Sep 20 19:00:25 UTC 2010
 1358         # Win32 version:                             
 1359         # Distribution:     mandrake 2010.2 Official 
 1360         # Architecture:     32bit ELF                
 1361         # Machine:          i686                     
 1362         # Processor:        i686                     
 1363         # Python version:   2.6.5                    
 1364         # Numpy version:    1.4.1                    
 1365         # Libc version:     glibc 2.0                
 1366         # 
 1367         # s2:                         0.9700000000016741
 1368         # te:                             2048.000000312
 1369         # rex:                       0.14899999996808433
 1370         # chi2:                   3.5466670276032307e-20
 1371         # iter:                                      158
 1372         # f_count:                                   744
 1373         # g_count:                                   165
 1374         # h_count:                                     0
 1375         # warning:                                  None
 1376 
 1377         # 32-bit i686 Linux (https://web.archive.org/web/https://mail.gna.org/public/relax-users/2011-01/msg00029.html).
 1378         # System:           Linux
 1379         # Release:          2.6.28-17-generic
 1380         # Version:          #58-Ubuntu SMP Tue Dec 1 18:57:07 UTC 2009
 1381         # Win32 version:
 1382         # Distribution:     Ubuntu 9.04 jaunty
 1383         # Architecture:     32bit ELF
 1384         # Machine:          i686
 1385         # Processor:
 1386         # Python version:   2.6.2
 1387         # Numpy version:    1.2.1
 1388         # Libc version:     glibc 2.4
 1389         # 
 1390         # s2:                          0.970000000000951
 1391         # te (ps):                        2048.000000178
 1392         # rex:                       0.14899999998189395
 1393         # chi2:                   1.1498599057727952e-20
 1394         # iter:                                      154
 1395         # f_count:                                   598
 1396         # g_count:                                   161
 1397         # h_count:                                     0
 1398         # warning:                                  None
 1399 
 1400         # 64-bit x86_64 Linux.
 1401         # System:           Linux
 1402         # Release:          2.6.24.7-server-2mnb
 1403         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 1404         # Win32 version:
 1405         # Distribution:     mandriva 2008.1 Official
 1406         # Architecture:     64bit ELF
 1407         # Machine:          x86_64
 1408         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 1409         # Python version:   2.5.2
 1410         # Numpy version:    1.2.0
 1411         # Libc version:     glibc 2.2.5
 1412         # 
 1413         # s2:                         0.9699999999999785
 1414         # te:                         2047.9999999962433
 1415         # rex:                       0.14900000000039709
 1416         # chi2:                   5.2479491342506911e-24
 1417         # iter:                                      162
 1418         # f_count:                                   758
 1419         # g_count:                                   169
 1420         # h_count:                                     0
 1421         # warning:                                  None
 1422 
 1423         # 32-bit Windows.
 1424         # iter: 156
 1425         # f_count: 701
 1426         # g_count: 163
 1427 
 1428         # 32-bit powerpc Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573, https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html).
 1429         # System: Darwin
 1430         # Release: 9.5.0
 1431         # Version: Darwin Kernel Version 9.5.0: Wed Sep  3 11:31:44 PDT 2008; root:xnu-1228.7.58~1/RELEASE_PPC
 1432         # Win32 version:
 1433         # Distribution:
 1434         # Architecture: 32bit
 1435         # Machine: Power Macintosh
 1436         # Processor: powerpc
 1437         # Python version: 2.5.2
 1438         # numpy version: 1.1.1
 1439         # 
 1440         # s2:       0.9699999999999861
 1441         # te:       2047.9999999978033
 1442         # rex:      0.14900000000028032
 1443         # chi2:     1.8533903598853284e-24
 1444         # iter:     156
 1445         # f_count:  695
 1446         # g_count:  162
 1447         # h_count:  0
 1448         # warning:  None
 1449 
 1450         # 32-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14173).
 1451         # System: Darwin
 1452         # Release: 9.8.0
 1453         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 1454         # Win32 version:
 1455         # Distribution:
 1456         # Architecture: 32bit
 1457         # Machine: i386
 1458         # Processor: i386
 1459         # Python version: 2.6.2
 1460         # numpy version: 1.3.0
 1461         # 
 1462         # s2: 0.9700000000009170
 1463         # te: 2048.0000001751678
 1464         # rex: 0.14899999998256069
 1465         # chi2: 1.1151721805269898e-20
 1466         # iter: 175
 1467         # f_count: 735
 1468         # g_count: 182
 1469         # h_count: 0
 1470         # warning: None 
 1471 
 1472         # 64-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14173).
 1473         # System: Darwin
 1474         # Release: 9.8.0
 1475         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 1476         # Win32 version:
 1477         # Distribution:
 1478         # Architecture: 64bit
 1479         # Machine: i386
 1480         # Processor: i386
 1481         # Python version: 2.6.2
 1482         # numpy version: 1.3.0
 1483         # 
 1484         # s2: 0.9699999999999785
 1485         # te: 2047.9999999962433
 1486         # rex: 0.14900000000039709
 1487         # chi2: 5.2479491342506911e-24
 1488         # iter: 162
 1489         # f_count: 758
 1490         # g_count: 169
 1491         # h_count: 0
 1492         # warning: None
 1493 
 1494         # Optimisation values.
 1495         select = True
 1496         s2 = 0.9699999999999995
 1497         te = 2048.000000000022283
 1498         rex = 0.14900000000000566 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 1499         chi2 = 3.1024517431117421e-27
 1500         iter = [154, 156, 157, 158, 162, 175, 203]
 1501         f_count = [598, 695, 701, 722, 735, 744, 758, 955]
 1502         g_count = [161, 162, 163, 164, 165, 169, 182, 209]
 1503         h_count = 0
 1504         warning = None
 1505 
 1506         # Test the values.
 1507         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 1508         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 1509 
 1510 
 1511     def test_opt_constr_bfgs_mt_S2_0_970_te_2048_Rex_0_149(self):
 1512         """Constrained BFGS opt, More and Thuente line search {S2=0.970, te=2048, Rex=0.149}
 1513 
 1514         The optimisation options are:
 1515             - BFGS optimisation.
 1516             - More and Thuente line search.
 1517             - Constrained.
 1518 
 1519         The true data set is:
 1520             - S2  = 0.970
 1521             - te  = 2048 ps
 1522             - Rex = 0.149 s^-1
 1523 
 1524         Relevant links for this test are:
 1525             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-devel/2009-05/msg00003.html}
 1526             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2011-01/msg00029.html}
 1527             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573}
 1528             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html}
 1529             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14174}
 1530         """
 1531 
 1532         # Setup the data pipe for optimisation.
 1533         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 1534 
 1535         # Set up the initial model-free parameter values (bypass the grid search for speed).
 1536         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 1537 
 1538         # Minimise.
 1539         self.interpreter.minimise.execute('bfgs', 'mt')
 1540 
 1541         # Alias the relevent spin container.
 1542         spin = cdp.mol[0].res[1].spin[0]
 1543 
 1544         # Optimisation differences.
 1545         ###########################
 1546 
 1547         # 32-bit Linux.
 1548         # f_count: 388
 1549         # g_count: 388
 1550 
 1551         # 32-bit i686 Linux (https://web.archive.org/web/https://mail.gna.org/public/relax-devel/2009-05/msg00003.html).
 1552         # System: Linux
 1553         # Release: 2.6.28-gentoo-r5
 1554         # Version: #1 SMP Sat Apr 25 13:31:51 EDT 2009
 1555         # Win32 version:
 1556         # Distribution:
 1557         # Architecture: 32bit ELF
 1558         # Machine: i686
 1559         # Processor: Intel(R) Pentium(R) M processor 1.80GHz
 1560         # Python version: 2.5.4
 1561         # numpy version: 1.2.1
 1562         # 
 1563         # s2:       0.9700000000000604
 1564         # te:       2048.0000000114946
 1565         # rex:      0.14899999999885985
 1566         # chi2:     4.762657780645096e-23
 1567         # iter:     120
 1568         # f_count:  386
 1569         # g_count:  386
 1570         # h_count:  0
 1571         # warning:  None
 1572 
 1573         # 32-bit i686 Linux (https://web.archive.org/web/https://mail.gna.org/public/relax-users/2011-01/msg00029.html).
 1574         # System:           Linux
 1575         # Release:          2.6.28-17-generic
 1576         # Version:          #58-Ubuntu SMP Tue Dec 1 18:57:07 UTC 2009
 1577         # Win32 version:
 1578         # Distribution:     Ubuntu 9.04 jaunty
 1579         # Architecture:     32bit ELF
 1580         # Machine:          i686
 1581         # Processor:
 1582         # Python version:   2.6.2
 1583         # Numpy version:    1.2.1
 1584         # Libc version:     glibc 2.4
 1585         # 
 1586         # s2:                         0.9700000000000614
 1587         # te (ps):                        2048.000000012
 1588         # rex:                       0.14899999999883881
 1589         # chi2:                   4.9272178768519757e-23
 1590         # iter:                                      120
 1591         # f_count:                                   381
 1592         # g_count:                                   381
 1593         # h_count:                                     0
 1594         # warning:                                  None
 1595 
 1596         # 64-bit x86_64 Linux.
 1597         # System:           Linux
 1598         # Release:          2.6.24.7-server-2mnb
 1599         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 1600         # Win32 version:
 1601         # Distribution:     mandriva 2008.1 Official
 1602         # Architecture:     64bit ELF
 1603         # Machine:          x86_64
 1604         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 1605         # Python version:   2.5.2
 1606         # Numpy version:    1.2.0
 1607         # Libc version:     glibc 2.2.5
 1608         # 
 1609         # s2:                         0.9700000000000603
 1610         # te:                         2048.0000000114601
 1611         # rex:                       0.14899999999886163
 1612         # chi2:                   4.7289676642197204e-23
 1613         # iter:                                      120
 1614         # f_count:                                   384
 1615         # g_count:                                   384
 1616         # h_count:                                     0
 1617         # warning:                                  None
 1618 
 1619         # 32-bit powerpc Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573, https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html).
 1620         # System: Darwin
 1621         # Release: 9.5.0
 1622         # Version: Darwin Kernel Version 9.5.0: Wed Sep  3 11:31:44 PDT 2008; 
 1623         # root:xnu-1228.7.58~1/RELEASE_PPC
 1624         # Win32 version:
 1625         # Distribution:
 1626         # Architecture: 32bit
 1627         # Machine: Power Macintosh
 1628         # Processor: powerpc
 1629         # Python version: 2.5.2
 1630         # numpy version: 1.1.1
 1631         # 
 1632         # s2:       0.9700000000000607
 1633         # te:       2048.0000000115510
 1634         # rex:      0.14899999999885080
 1635         # chi2:     4.8056261450870388e-23
 1636         # iter:     120
 1637         # f_count:  377
 1638         # g_count:  377
 1639         # h_count:  0
 1640         # warning:  None
 1641 
 1642         # 32-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14174).
 1643         # System: Darwin
 1644         # Release: 9.8.0
 1645         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 1646         # Win32 version:
 1647         # Distribution:
 1648         # Architecture: 32bit
 1649         # Machine: i386
 1650         # Processor: i386
 1651         # Python version: 2.6.2
 1652         # numpy version: 1.3.0
 1653         # 
 1654         # s2: 0.9700000000000604
 1655         # te: 2048.0000000114997
 1656         # rex: 0.14899999999886168
 1657         # chi2: 4.7647467884964078e-23
 1658         # iter: 120
 1659         # f_count: 386
 1660         # g_count: 386
 1661         # h_count: 0
 1662         # warning: None 
 1663 
 1664         # 64-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14174).
 1665         # System: Darwin
 1666         # Release: 9.8.0
 1667         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 1668         # Win32 version:
 1669         # Distribution:
 1670         # Architecture: 64bit
 1671         # Machine: i386
 1672         # Processor: i386
 1673         # Python version: 2.6.2
 1674         # numpy version: 1.3.0
 1675         # 
 1676         # s2: 0.9700000000000603
 1677         # te: 2048.0000000114601
 1678         # rex: 0.14899999999886163
 1679         # chi2: 4.7289676642197204e-23
 1680         # iter: 120
 1681         # f_count: 384
 1682         # g_count: 384
 1683         # h_count: 0
 1684         # warning: None
 1685 
 1686         # Optimisation values.
 1687         select = True
 1688         s2 = 0.9700000000000580
 1689         te = 2048.000000011044449
 1690         rex = 0.148999999998904 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 1691         chi2 = 4.3978813282102374e-23
 1692         iter = 120
 1693         f_count = [377, 381, 384, 386, 388]
 1694         g_count = [377, 381, 384, 386, 388]
 1695         h_count = 0
 1696         warning = None
 1697 
 1698         # Test the values.
 1699         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 1700         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 1701 
 1702 
 1703     def test_opt_constr_cd_back_S2_0_970_te_2048_Rex_0_149(self):
 1704         """Constrained coordinate descent opt, backtracking line search {S2=0.970, te=2048, Rex=0.149}
 1705 
 1706         The optimisation options are:
 1707             - Coordinate descent optimisation.
 1708             - Backtracking line search.
 1709             - Constrained.
 1710 
 1711         The true data set is:
 1712             - S2  = 0.970
 1713             - te  = 2048 ps
 1714             - Rex = 0.149 s^-1
 1715         """
 1716 
 1717         # Setup the data pipe for optimisation.
 1718         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 1719 
 1720         # Set up the initial model-free parameter values (bypass the grid search for speed).
 1721         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 1722 
 1723         # Minimise.
 1724         self.interpreter.minimise.execute('cd', 'back', max_iter=50)
 1725 
 1726         # Alias the relevent spin container.
 1727         spin = cdp.mol[0].res[1].spin[0]
 1728 
 1729         # Optimisation differences.
 1730         ###########################
 1731 
 1732         # 64-bit x86_64 Linux.
 1733         # System:           Linux
 1734         # Release:          2.6.24.7-server-2mnb
 1735         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 1736         # Win32 version:
 1737         # Distribution:     mandriva 2008.1 Official
 1738         # Architecture:     64bit ELF
 1739         # Machine:          x86_64
 1740         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 1741         # Python version:   2.5.2
 1742         # Numpy version:    1.2.0
 1743         # Libc version:     glibc 2.2.5
 1744         # 
 1745         # s2:                         0.9097900390625000
 1746         # te:                           25.0000000000000
 1747         # rex:                       1.24017333984375000
 1748         # chi2:                       53.476155463267176
 1749         # iter:                                       50
 1750         # f_count:                                   131
 1751         # g_count:                                    51
 1752         # h_count:                                     0
 1753         # warning:        Maximum number of iterations reached
 1754 
 1755         # Optimisation values.
 1756         select = True
 1757         s2 = 0.9097900390625
 1758         te = 25.00000000000000
 1759         rex = 1.24017333984375 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 1760         chi2 = 53.476155463267176
 1761         iter = 50
 1762         f_count = 131
 1763         g_count = 51
 1764         h_count = 0
 1765         warning = 'Maximum number of iterations reached'
 1766 
 1767         # Test the values.
 1768         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 1769         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 1770 
 1771 
 1772     def test_opt_constr_cd_mt_S2_0_970_te_2048_Rex_0_149(self):
 1773         """Constrained coordinate descent opt, More and Thuente line search {S2=0.970, te=2048, Rex=0.149}
 1774 
 1775         The optimisation options are:
 1776             - Coordinate descent optimisation.
 1777             - More and Thuente line search.
 1778             - Constrained.
 1779 
 1780         The true data set is:
 1781             - S2  = 0.970
 1782             - te  = 2048 ps
 1783             - Rex = 0.149 s^-1
 1784 
 1785         Relevant links for this test are:
 1786             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573}
 1787             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html}
 1788             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14175}
 1789         """
 1790 
 1791         # Setup the data pipe for optimisation.
 1792         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 1793 
 1794         # Set up the initial model-free parameter values (bypass the grid search for speed).
 1795         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 1796 
 1797         # Minimise.
 1798         self.interpreter.minimise.execute('cd', 'mt')
 1799 
 1800         # Alias the relevent spin container.
 1801         spin = cdp.mol[0].res[1].spin[0]
 1802 
 1803         # Optimisation differences.
 1804         ###########################
 1805 
 1806         # 32-bit Linux.
 1807         # f_count: 738
 1808         # g_count: 738
 1809 
 1810         # 32-bit i686 Linux.
 1811         # System:           Linux                    
 1812         # Release:          2.6.33.7-desktop-2mnb    
 1813         # Version:          #1 SMP Mon Sep 20 19:00:25 UTC 2010
 1814         # Win32 version:                             
 1815         # Distribution:     mandrake 2010.2 Official 
 1816         # Architecture:     32bit ELF                
 1817         # Machine:          i686                     
 1818         # Processor:        i686                     
 1819         # Python version:   2.6.5                    
 1820         # Numpy version:    1.4.1                    
 1821         # Libc version:     glibc 2.0                
 1822         # 
 1823         # s2:                         0.9700000000219662
 1824         # te:                             2048.000001534
 1825         # rex:                       0.14899999946980566
 1826         # chi2:                   2.3474910055938013e-18
 1827         # iter:                                      200
 1828         # f_count:                                   874
 1829         # g_count:                                   874
 1830         # h_count:                                     0
 1831         # warning:                                  None
 1832 
 1833         # 64-bit x86_64 Linux.
 1834         # System:           Linux
 1835         # Release:          2.6.24.7-server-2mnb
 1836         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 1837         # Win32 version:
 1838         # Distribution:     mandriva 2008.1 Official
 1839         # Architecture:     64bit ELF
 1840         # Machine:          x86_64
 1841         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 1842         # Python version:   2.5.2
 1843         # Numpy version:    1.2.0
 1844         # Libc version:     glibc 2.2.5
 1845         #
 1846         # s2:                         0.9700000000219674
 1847         # te:                         2048.0000015341870
 1848         # rex:                       0.14899999946977982
 1849         # chi2:                   2.3477234248531005e-18
 1850         # iter:                                      198
 1851         # f_count:                                   757
 1852         # g_count:                                   757
 1853         # h_count:                                     0
 1854         # warning:                                  None
 1855 
 1856         # 32-bit powerpc Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573, https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html).
 1857         # System: Darwin
 1858         # Release: 9.5.0
 1859         # Version: Darwin Kernel Version 9.5.0: Wed Sep  3 11:31:44 PDT 2008; 
 1860         # root:xnu-1228.7.58~1/RELEASE_PPC
 1861         # Win32 version:
 1862         # Distribution:
 1863         # Architecture: 32bit
 1864         # Machine: Power Macintosh
 1865         # Processor: powerpc
 1866         # Python version: 2.5.2
 1867         # numpy version: 1.1.1
 1868         # 
 1869         # s2:       0.9700000000219674
 1870         # te:       2048.0000015341870
 1871         # rex:      0.14899999946977982
 1872         # chi2:     2.3477234248531005e-18
 1873         # iter:     198
 1874         # f_count:  757
 1875         # g_count:  757
 1876         # h_count:  0
 1877         # warning:  None
 1878 
 1879         # 64-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14175).
 1880         # System: Darwin
 1881         # Release: 9.8.0
 1882         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 1883         # Win32 version:
 1884         # Distribution:
 1885         # Architecture: 64bit
 1886         # Machine: i386
 1887         # Processor: i386
 1888         # Python version: 2.6.2
 1889         # numpy version: 1.3.0
 1890         # 
 1891         # s2: 0.9700000000219674
 1892         # te: 2048.0000015341870
 1893         # rex: 0.14899999946977982
 1894         # chi2: 2.3477234248531005e-18
 1895         # iter: 198
 1896         # f_count: 757
 1897         # g_count: 757
 1898         # h_count: 0
 1899         # warning: None 
 1900 
 1901         # Optimisation values.
 1902         select = True
 1903         s2 = 0.9700000000219674
 1904         te = 2048.000001534187049
 1905         rex = 0.14899999946977982 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 1906         chi2 = 2.3477234248531005e-18
 1907         iter = [198, 200]
 1908         f_count = [738, 757, 874]
 1909         g_count = [738, 757, 874]
 1910         h_count = 0
 1911         warning = None
 1912 
 1913         # Test the values.
 1914         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 1915         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 1916 
 1917 
 1918     def test_opt_constr_newton_gmw_back_S2_0_970_te_2048_Rex_0_149(self):
 1919         """Constrained Newton opt, GMW Hessian mod, backtracking line search {S2=0.970, te=2048, Rex=0.149}
 1920 
 1921         The optimisation options are:
 1922             - Newton optimisation.
 1923             - GMW Hessian modification.
 1924             - Backtracking line search.
 1925             - Constrained.
 1926 
 1927         The true data set is:
 1928             - S2  = 0.970
 1929             - te  = 2048 ps
 1930             - Rex = 0.149 s^-1
 1931 
 1932         Relevant links for this test are:
 1933             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573}
 1934             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html}
 1935             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14177}
 1936         """
 1937 
 1938         # Setup the data pipe for optimisation.
 1939         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 1940 
 1941         # Set up the initial model-free parameter values (bypass the grid search for speed).
 1942         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 1943 
 1944         # Minimise.
 1945         self.interpreter.minimise.execute('newton', 'gmw', 'back')
 1946 
 1947         # Alias the relevent spin container.
 1948         spin = cdp.mol[0].res[1].spin[0]
 1949 
 1950         # Optimisation differences.
 1951         ###########################
 1952 
 1953         # 32-bit Linux.
 1954         # f_count: 55
 1955         # g_count: 23
 1956 
 1957         # 32-bit i686 Linux.
 1958         # System:           Linux                    
 1959         # Release:          2.6.33.7-desktop-2mnb    
 1960         # Version:          #1 SMP Mon Sep 20 19:00:25 UTC 2010
 1961         # Win32 version:                             
 1962         # Distribution:     mandrake 2010.2 Official 
 1963         # Architecture:     32bit ELF                
 1964         # Machine:          i686                     
 1965         # Processor:        i686                     
 1966         # Python version:   2.6.5                    
 1967         # Numpy version:    1.4.1                    
 1968         # Libc version:     glibc 2.0                
 1969         # 
 1970         # s2:                         0.9699999999999992
 1971         # te:                                       2048
 1972         # rex:                       0.14900000000002034
 1973         # chi2:                   1.1701970207791308e-27
 1974         # iter:                                       18
 1975         # f_count:                                    57
 1976         # g_count:                                    23
 1977         # h_count:                                    18
 1978         # warning:                                  None
 1979 
 1980         # 64-bit x86_64 Linux.
 1981         # System:           Linux
 1982         # Release:          2.6.24.7-server-2mnb
 1983         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 1984         # Win32 version:
 1985         # Distribution:     mandriva 2008.1 Official
 1986         # Architecture:     64bit ELF
 1987         # Machine:          x86_64
 1988         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 1989         # Python version:   2.5.2
 1990         # Numpy version:    1.2.0
 1991         # Libc version:     glibc 2.2.5
 1992         #
 1993         # s2:                         0.9699999999999995
 1994         # te:                         2048.0000000000473
 1995         # rex:                       0.14900000000001926
 1996         # chi2:                   7.9357208397255696e-28
 1997         # iter:                                       18
 1998         # f_count:                                    55
 1999         # g_count:                                    23
 2000         # h_count:                                    18
 2001         # warning:                                  None
 2002         
 2003         # 32-bit powerpc Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573, https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html).
 2004         # System: Darwin
 2005         # Release: 9.5.0
 2006         # Version: Darwin Kernel Version 9.5.0: Wed Sep  3 11:31:44 PDT 2008; 
 2007         # root:xnu-1228.7.58~1/RELEASE_PPC
 2008         # Win32 version:
 2009         # Distribution:
 2010         # Architecture: 32bit
 2011         # Machine: Power Macintosh
 2012         # Processor: powerpc
 2013         # Python version: 2.5.2
 2014         # numpy version: 1.1.1
 2015         # 
 2016         # s2:       0.9699999999999993
 2017         # te:       2048.0000000000427
 2018         # rex:      0.14900000000002098
 2019         # chi2:     5.7085251917483392e-28
 2020         # iter:     18
 2021         # f_count:  94
 2022         # g_count:  23
 2023         # h_count:  18
 2024         # warning:  None
 2025 
 2026         # 64-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14177).
 2027         # System: Darwin
 2028         # Release: 9.8.0
 2029         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 2030         # Win32 version:
 2031         # Distribution:
 2032         # Architecture: 32bit
 2033         # Machine: i386
 2034         # Processor: i386
 2035         # Python version: 2.6.2
 2036         # numpy version: 1.3.0
 2037         # 
 2038         # s2: 0.9699999999999994
 2039         # te: 2048.0000000000455
 2040         # rex: 0.14900000000001823
 2041         # chi2: 7.3040158179665562e-28
 2042         # iter: 18
 2043         # f_count: 55
 2044         # g_count: 23
 2045         # h_count: 18
 2046         # warning: None 
 2047 
 2048         # Optimisation values.
 2049         select = True
 2050         s2 = 0.9699999999999994
 2051         te = 2048.000000000045020
 2052         rex = 0.14900000000001817 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 2053         chi2 = 7.3040158179665562e-28
 2054         iter = 18
 2055         f_count = [55, 57, 94]
 2056         g_count = [23]
 2057         h_count = 18
 2058         warning = None
 2059 
 2060         # Test the values.
 2061         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 2062         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 2063 
 2064 
 2065     def test_opt_constr_newton_gmw_mt_S2_0_970_te_2048_Rex_0_149(self):
 2066         """Constrained Newton opt, GMW Hessian mod, More and Thuente line search {S2=0.970, te=2048, Rex=0.149}
 2067 
 2068         The optimisation options are:
 2069             - Newton optimisation.
 2070             - GMW Hessian modification.
 2071             - More and Thuente line search.
 2072             - Constrained.
 2073 
 2074         The true data set is:
 2075             - S2  = 0.970
 2076             - te  = 2048 ps
 2077             - Rex = 0.149 s^-1
 2078 
 2079         Relevant links for this test are:
 2080             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573}
 2081             - U{https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html}
 2082             - U{https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14176}
 2083         """
 2084 
 2085         # Setup the data pipe for optimisation.
 2086         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 2087 
 2088         # Set up the initial model-free parameter values (bypass the grid search for speed).
 2089         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 2090 
 2091         # Minimise.
 2092         self.interpreter.minimise.execute('newton', 'gmw', 'mt')
 2093 
 2094         # Monte Carlo simulations.
 2095         self.monte_carlo()
 2096 
 2097         # Alias the relevent spin container.
 2098         spin = cdp.mol[0].res[1].spin[0]
 2099 
 2100         # Optimisation differences.
 2101         ###########################
 2102 
 2103         # 32-bit Linux.
 2104         # f_count: 159, 95
 2105         # g_count: 159
 2106 
 2107         # 32-bit i686 Linux.
 2108         # System:           Linux                    
 2109         # Release:          2.6.33.7-desktop-2mnb    
 2110         # Version:          #1 SMP Mon Sep 20 19:00:25 UTC 2010
 2111         # Win32 version:                             
 2112         # Distribution:     mandrake 2010.2 Official 
 2113         # Architecture:     32bit ELF                
 2114         # Machine:          i686                     
 2115         # Processor:        i686                     
 2116         # Python version:   2.6.5                    
 2117         # Numpy version:    1.4.1                    
 2118         # Libc version:     glibc 2.0                
 2119         # 
 2120         # s2:                         0.9699999999999994
 2121         # te:                                       2048
 2122         # rex:                       0.14900000000002014
 2123         # chi2:                   7.9326439528899843e-28
 2124         # iter:                                       22
 2125         # f_count:                                    95
 2126         # g_count:                                    95
 2127         # h_count:                                    22
 2128         # warning:                                  None
 2129 
 2130         # 64-bit x86_64 Linux.
 2131         # System:           Linux
 2132         # Release:          2.6.24.7-server-2mnb
 2133         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 2134         # Win32 version:
 2135         # Distribution:     mandriva 2008.1 Official
 2136         # Architecture:     64bit ELF
 2137         # Machine:          x86_64
 2138         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 2139         # Python version:   2.5.2
 2140         # Numpy version:    1.2.0
 2141         # Libc version:     glibc 2.2.5
 2142         #
 2143         # s2:                         0.9699999999999994
 2144         # te:                         2048.0000000000446
 2145         # rex:                       0.14900000000001615
 2146         # chi2:                   8.3312601381368332e-28
 2147         # iter:                                       22
 2148         # f_count:                                    91
 2149         # g_count:                                    91
 2150         # h_count:                                    22
 2151         # warning:                                  None
 2152         
 2153         # 64-bit x86_64 Linux (Not sure why there is a difference here, maybe this is gcc or blas/lapack - Python and numpy versions are identical).
 2154         # f_count: 153
 2155         # g_count: 153
 2156 
 2157         # 32-bit powerpc Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?12573, https://web.archive.org/web/https://mail.gna.org/public/relax-users/2008-10/msg00089.html).
 2158         # System: Darwin
 2159         # Release: 9.5.0
 2160         # Version: Darwin Kernel Version 9.5.0: Wed Sep  3 11:31:44 PDT 2008; 
 2161         # root:xnu-1228.7.58~1/RELEASE_PPC
 2162         # Win32 version:
 2163         # Distribution:
 2164         # Architecture: 32bit
 2165         # Machine: Power Macintosh
 2166         # Processor: powerpc
 2167         # Python version: 2.5.2
 2168         # numpy version: 1.1.1
 2169         # 
 2170         # s2:       0.9699999999999993
 2171         # te:       2048.0000000000409
 2172         # rex:      0.14900000000002178
 2173         # chi2:     6.8756889983348349e-28
 2174         # iter:     22
 2175         # f_count:  160
 2176         # g_count:  160
 2177         # h_count:  22
 2178         # warning:  None
 2179 
 2180         # 32-bit Windows.
 2181         # f_count: 165
 2182         # g_count: 165
 2183 
 2184         # 32-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14176).
 2185         # System: Darwin
 2186         # Release: 9.8.0
 2187         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 2188         # Win32 version:
 2189         # Distribution:
 2190         # Architecture: 32bit
 2191         # Machine: i386
 2192         # Processor: i386
 2193         # Python version: 2.6.2
 2194         # numpy version: 1.3.0
 2195         # 
 2196         # s2: 0.9699999999999994
 2197         # te: 2048.0000000000446
 2198         # rex: 0.14900000000001609
 2199         # chi2: 8.3312601381368332e-28
 2200         # iter: 22
 2201         # f_count: 91
 2202         # g_count: 91
 2203         # h_count: 22
 2204         # warning: None 
 2205 
 2206         # 64-bit i386 Darwin (https://web.archive.org/web/https://web.archive.org/web/https://gna.org/bugs/?14176).
 2207         # System: Darwin
 2208         # Release: 9.8.0
 2209         # Version: Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386
 2210         # Win32 version:
 2211         # Distribution:
 2212         # Architecture: 64bit
 2213         # Machine: i386
 2214         # Processor: i386
 2215         # Python version: 2.6.2
 2216         # numpy version: 1.3.0
 2217         # 
 2218         # s2: 0.9699999999999994
 2219         # te: 2048.0000000000446
 2220         # rex: 0.14900000000001609
 2221         # chi2: 8.3312601381368332e-28
 2222         # iter: 22
 2223         # f_count: 91
 2224         # g_count: 91
 2225         # h_count: 22
 2226         # warning: None 
 2227 
 2228         # Optimisation values.
 2229         select = True
 2230         s2 = 0.9699999999999993
 2231         te = 2048.000000000041837
 2232         rex = 0.14900000000002225 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 2233         chi2 = 6.8756889983348349e-28
 2234         iter = 22
 2235         f_count = [91, 95, 153, 159, 160, 165]
 2236         g_count = [91, 95, 153, 159, 160, 165]
 2237         h_count = 22
 2238         warning = None
 2239 
 2240         # Test the values.
 2241         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 2242         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 2243 
 2244 
 2245     def test_opt_constr_sd_back_S2_0_970_te_2048_Rex_0_149(self):
 2246         """Constrained steepest descent opt, backtracking line search {S2=0.970, te=2048, Rex=0.149}
 2247 
 2248         The optimisation options are:
 2249             - Steepest descent optimisation.
 2250             - Backtracking line search.
 2251             - Constrained.
 2252 
 2253         The true data set is:
 2254             - S2  = 0.970
 2255             - te  = 2048 ps
 2256             - Rex = 0.149 s^-1
 2257         """
 2258 
 2259         # Setup the data pipe for optimisation.
 2260         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 2261 
 2262         # Set up the initial model-free parameter values (bypass the grid search for speed).
 2263         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 2264 
 2265         # Minimise.
 2266         self.interpreter.minimise.execute('sd', 'back', max_iter=50)
 2267 
 2268         # Alias the relevent spin container.
 2269         spin = cdp.mol[0].res[1].spin[0]
 2270 
 2271         # Optimisation differences.
 2272         ###########################
 2273 
 2274         # 64-bit x86_64 Linux.
 2275         # System:           Linux
 2276         # Release:          2.6.24.7-server-2mnb
 2277         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 2278         # Win32 version:
 2279         # Distribution:     mandriva 2008.1 Official
 2280         # Architecture:     64bit ELF
 2281         # Machine:          x86_64
 2282         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 2283         # Python version:   2.5.2
 2284         # Numpy version:    1.2.0
 2285         # Libc version:     glibc 2.2.5
 2286         #
 2287         # s2:                         0.9157922083468916
 2288         # te:                            0.3056865872253
 2289         # rex:                       0.34008409798064831
 2290         # chi2:                       68.321956795340569
 2291         # iter:                                       50
 2292         # f_count:                                   134
 2293         # g_count:                                    51
 2294         # h_count:                                     0
 2295         # warning:        Maximum number of iterations reached
 2296         
 2297         # Optimisation values.
 2298         select = True
 2299         s2 = 0.91579220834688024
 2300         te = 0.30568658722531733
 2301         rex = 0.34008409798366124 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 2302         chi2 = 68.321956795264342
 2303         iter = 50
 2304         f_count = 134
 2305         g_count = 51
 2306         h_count = 0
 2307         warning = 'Maximum number of iterations reached'
 2308 
 2309         # Test the values.
 2310         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 2311         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 2312 
 2313 
 2314     def test_opt_constr_sd_mt_S2_0_970_te_2048_Rex_0_149(self):
 2315         """Constrained steepest descent opt, More and Thuente line search {S2=0.970, te=2048, Rex=0.149}
 2316 
 2317         The optimisation options are:
 2318             - Steepest descent optimisation.
 2319             - More and Thuente line search.
 2320             - Constrained.
 2321 
 2322         The true data set is:
 2323             - S2  = 0.970
 2324             - te  = 2048 ps
 2325             - Rex = 0.149 s^-1
 2326         """
 2327 
 2328         # Setup the data pipe for optimisation.
 2329         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 2330 
 2331         # Set up the initial model-free parameter values (bypass the grid search for speed).
 2332         self.interpreter.value.set([1.0, 0.0, 0.0], ['s2', 'te', 'rex'])
 2333 
 2334         # Minimise.
 2335         self.interpreter.minimise.execute('sd', 'mt', max_iter=50)
 2336 
 2337         # Alias the relevent spin container.
 2338         spin = cdp.mol[0].res[1].spin[0]
 2339 
 2340         # Optimisation differences.
 2341         ###########################
 2342 
 2343         # 64-bit x86_64 Linux.
 2344         # System:           Linux
 2345         # Release:          2.6.24.7-server-2mnb
 2346         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 2347         # Win32 version:
 2348         # Distribution:     mandriva 2008.1 Official
 2349         # Architecture:     64bit ELF
 2350         # Machine:          x86_64
 2351         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 2352         # Python version:   2.5.2
 2353         # Numpy version:    1.2.0
 2354         # Libc version:     glibc 2.2.5
 2355         #
 2356         # s2:                         0.9161999495781851
 2357         # te:                            0.1231968757090
 2358         # rex:                       0.16249110939079675
 2359         # chi2:                       73.843613548025075
 2360         # iter:                                       50
 2361         # f_count:                                   108
 2362         # g_count:                                   108
 2363         # h_count:                                     0
 2364         # warning:        Maximum number of iterations reached
 2365         
 2366         # Optimisation values.
 2367         select = True
 2368         s2 = 0.91619994957822126
 2369         te = 0.12319687570987945
 2370         rex = 0.16249110942961512 / (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2
 2371         chi2 = 73.843613546506191
 2372         iter = 50
 2373         f_count = 108
 2374         g_count = 108
 2375         h_count = 0
 2376         warning = 'Maximum number of iterations reached'
 2377 
 2378         # Test the values.
 2379         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 2380         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 2381 
 2382 
 2383     def test_opt_grid_search_S2_0_970_te_2048_Rex_0_149(self):
 2384         """Constrained grid search {S2=0.970, te=2048, Rex=0.149}.
 2385 
 2386         The optimisation options are:
 2387             - Constrained grid search.
 2388 
 2389         The true data set is:
 2390             - S2  = 0.970
 2391             - te  = 2048 ps
 2392             - Rex = 0.149 s^-1
 2393         """
 2394 
 2395         # Setup the data pipe for optimisation.
 2396         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_setup_S2_0_970_te_2048_Rex_0_149.py')
 2397 
 2398         # Grid search.
 2399         self.interpreter.minimise.grid_search(inc=11)
 2400 
 2401         # Alias the relevent spin container.
 2402         spin = cdp.mol[0].res[1].spin[0]
 2403 
 2404         # Optimisation differences.
 2405         ###########################
 2406 
 2407         # 64-bit x86_64 Linux.
 2408         # System:           Linux
 2409         # Release:          2.6.24.7-server-2mnb
 2410         # Version:          #1 SMP Thu Oct 30 14:50:37 EDT 2008
 2411         # Win32 version:
 2412         # Distribution:     mandriva 2008.1 Official
 2413         # Architecture:     64bit ELF
 2414         # Machine:          x86_64
 2415         # Processor:        Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
 2416         # Python version:   2.5.2
 2417         # Numpy version:    1.2.0
 2418         # Libc version:     glibc 2.2.5
 2419         #
 2420         # s2:                                          1
 2421         # te:                                          0
 2422         # rex:                                         0
 2423         # chi2:                       3.9844117908982288
 2424         # iter:                                     1331
 2425         # f_count:                                  1331
 2426         # g_count:                                     0
 2427         # h_count:                                     0
 2428         # warning:                                  None
 2429 
 2430         # Optimisation values.
 2431         select = True
 2432         s2 = 1.0
 2433         te = 0.0
 2434         rex = 0.0
 2435         chi2 = 3.9844117908982288
 2436         iter = 1331
 2437         f_count = 1331
 2438         g_count = 0
 2439         h_count = 0
 2440         warning = None
 2441 
 2442         # Test the values.
 2443         self.assertEqual(cdp.mol[0].res[0].spin[0].select, False)
 2444         self.value_test(spin, select=select, s2=s2, te=te, rex=rex, chi2=chi2)
 2445 
 2446 
 2447     def test_read_relax_data(self):
 2448         """Reading of relaxation data using the user function relax_data.read()."""
 2449 
 2450         # Path of the files.
 2451         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'
 2452 
 2453         # Read the sequence.
 2454         self.interpreter.sequence.read(file='noe.500.out', dir=path, res_num_col=1, res_name_col=2)
 2455 
 2456         # Read the relaxation data.
 2457         self.interpreter.relax_data.read(ri_id='R1_600', ri_type='R1', frq=600.0 * 1e6, file='r1.600.out', dir=path, res_num_col=1, res_name_col=2, data_col=3, error_col=4)
 2458 
 2459         # Test the data and error.
 2460         self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data['R1_600'], 1.3874977659397683)
 2461         self.assertEqual(cdp.mol[0].res[1].spin[0].ri_data_err['R1_600'], 0.027749955318795365)
 2462 
 2463 
 2464     def test_read_results_1_2(self):
 2465         """Read a relax 1.2 model-free results file using the user function results.read()."""
 2466 
 2467         # Read the results.
 2468         self.interpreter.results.read(file='results_1.2', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free')
 2469 
 2470         # Debugging printout.
 2471         print(cdp)
 2472 
 2473         # The spin specific data.
 2474         num = [3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35]
 2475         select = [False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]
 2476         model = ['m6', 'm8', 'm6', 'm6', 'm5', 'm5', 'm6', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm5', 'm8']
 2477         params = [['s2f', 'tf', 's2', 'ts'], ['s2f', 'tf', 's2', 'ts', 'rex'], ['s2f', 'tf', 's2', 'ts'], ['s2f', 'tf', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 'tf', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 's2', 'ts'], ['s2f', 'tf', 's2', 'ts', 'rex']]
 2478         s2 = [0.36670427146403667, 0.29007016882193892, 0.32969827132809559, 0.32795333510352148, 0.48713005133752196, 0.40269538236298569, 0.40700811448591556, 0.4283551026406261, 0.51176783207279875, 0.40593664887508263, 0.39437732735324443, 0.51457448574034614, 0.3946900969237977, 0.44740698217286901, 0.48527716982891644, 0.40845486062540021, 0.45839900995265137, 0.52650140958170921, 0.4293599736020427, 0.4057313062564018, 0.49877862202992485, 0.2592017578673716]
 2479         s2f = [0.74487419686217116, 0.75358958979175727, 0.77751085082436211, 0.79095600331751026, 0.81059857999556584, 0.83190224667917501, 0.80119109731193627, 0.83083248649122576, 0.86030420847112021, 0.84853537580616367, 0.82378413185968968, 0.82419108009774422, 0.85121172821954216, 0.8736616181472916, 0.84117641395909415, 0.82881488883235521, 0.82697284935760407, 0.85172375147802715, 0.81366357660551614, 0.80525752789388483, 0.87016608774434312, 0.72732036363757913]
 2480         s2s = [0.49230363061145249, 0.38491796164819009, 0.4240433056059994, 0.41462904855388333, 0.60095102971952741, 0.48406574687168274, 0.50800379067049317, 0.51557336720143987, 0.59486845122178478, 0.47839684761453399, 0.47873867934666214, 0.62433881919629686, 0.46368028522041266, 0.51210557140148982, 0.57690296800513374, 0.49281795745831319, 0.55430962492751434, 0.61815983018913379, 0.5276873464009153, 0.50385285725620466, 0.57319933407525203, 0.35637907423767778]
 2481         tf = [51.972302580836775, 40.664901270582988, 28.130299965023671, 33.804249387275249, None, None, 39.01236115991609, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 44.039078787981225]
 2482         ts = [4485.91415175767, 4102.7781982031429, 3569.2837792404325, 6879.5308400989479, 3372.9879908647699, 4029.0617588044606, 4335.5290462417324, 4609.1336532777468, 2628.5638771308277, 3618.1332115807745, 6208.3028336637644, 3763.0843884066526, 3847.9994107906346, 2215.2061317769703, 2936.1282626562524, 3647.0715185456729, 3803.6990762708042, 2277.5259401416288, 3448.4496004396187, 3884.6917561878495, 1959.3267951363712, 4100.8496898773756]
 2483         rex = [None, 0.37670424516405815, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 0.71472288436387088]
 2484 
 2485         # Relaxation data.
 2486         ri_ids = ['R1_500', 'R2_500', 'NOE_500', 'R1_600', 'R2_600', 'NOE_600', 'R1_750', 'R2_750', 'NOE_750']
 2487         types_list = ['R1', 'R2', 'NOE', 'R1', 'R2', 'NOE', 'R1', 'R2', 'NOE']
 2488         frqs_list = [500000000.0] * 3 + [600000000.0] * 3 + [750000000.0] * 3
 2489         ri_type = {}
 2490         frqs = {}
 2491         for i in range(len(ri_ids)):
 2492             ri_type[ri_ids[i]] = types_list[i]
 2493             frqs[ri_ids[i]] = frqs_list[i]
 2494 
 2495         ri_data = {}
 2496         ri_data['R1_500'] = [2.2480000000000002, 2.2679999999999998, 2.2309999999999999, 2.383, 2.1960000000000002, 2.3570000000000002, 2.3340000000000001, 2.3999999999999999, 2.2839999999999998, 2.3889999999999998, 2.375, 2.274, 2.407, 2.3220000000000001, 2.2130000000000001, 2.351, 2.3260000000000001, 2.2949999999999999, 2.2829999999999999, 2.302, 2.2719999999999998, 2.2280000000000002]
 2497         ri_data['R2_500'] = [5.3419999999999996, 5.3730000000000002, 5.1280000000000001, 5.6749999999999998, 5.9669999999999996, 5.8410000000000002, 5.774, 6.0419999999999998, 6.3129999999999997, 5.9210000000000003, 6.1269999999999998, 6.1120000000000001, 6.0570000000000004, 5.6399999999999997, 6.2809999999999997, 5.8890000000000002, 5.875, 6.1429999999999998, 5.7370000000000001, 5.5490000000000004, 5.7110000000000003, 5.4020000000000001]
 2498         ri_data['NOE_500'] = [0.4617, 0.46560000000000001, 0.61670000000000003, 0.60860000000000003, 0.68869999999999998, 0.6663, 0.58620000000000005, 0.64939999999999998, 0.61070000000000002, 0.61180000000000001, 0.73129999999999995, 0.69650000000000001, 0.65139999999999998, 0.4929, 0.65920000000000001, 0.63029999999999997, 0.64380000000000004, 0.53500000000000003, 0.63839999999999997, 0.65000000000000002, 0.49909999999999999, 0.45979999999999999]
 2499         ri_data['R1_600'] = [1.8879999999999999, 1.992, 2.0270000000000001, 1.9790000000000001, 1.9399999999999999, 2.0550000000000002, 2.0030000000000001, 2.0139999999999998, 1.982, 2.1000000000000001, 2.008, 1.927, 2.1019999999999999, 2.0830000000000002, 1.9910000000000001, 2.036, 1.9990000000000001, 1.9490000000000001, 1.976, 1.9870000000000001, 2.0, 1.9379999999999999]
 2500         ri_data['R2_600'] = [5.6100000000000003, 5.7869999999999999, 5.4029999999999996, 6.1849999999999996, 6.3150000000000004, 5.9809999999999999, 6.1600000000000001, 6.2460000000000004, 6.4340000000000002, 6.0069999999999997, 6.399, 6.6799999999999997, 6.1369999999999996, 5.952, 6.3239999999999998, 5.9699999999999998, 6.3979999999999997, 6.4379999999999997, 6.1139999999999999, 6.0960000000000001, 6.3250000000000002, 6.1050000000000004]
 2501         ri_data['NOE_600'] = [0.62929999999999997, 0.64429999999999998, 0.5393, 0.71509999999999996, 0.73870000000000002, 0.75580000000000003, 0.64239999999999997, 0.74429999999999996, 0.69440000000000002, 0.73140000000000005, 0.7681, 0.73399999999999999, 0.75680000000000003, 0.62470000000000003, 0.73529999999999995, 0.73740000000000006, 0.73080000000000001, 0.6603, 0.70899999999999996, 0.69040000000000001, 0.59199999999999997, 0.56830000000000003]
 2502         ri_data['R1_750'] = [1.6220000000000001, 1.706, 1.73, 1.665, 1.627, 1.768, 1.706, 1.7030000000000001, 1.7649999999999999, 1.8129999999999999, 1.675, 1.6339999999999999, 1.845, 1.7829999999999999, 1.764, 1.7470000000000001, 1.681, 1.647, 1.6850000000000001, 1.667, 1.7010000000000001, 1.6850000000000001]
 2503         ri_data['R2_750'] = [6.2619999999999996, 6.5359999999999996, 5.8959999999999999, 6.6840000000000002, 6.8819999999999997, 6.7569999999999997, 6.5620000000000003, 7.0030000000000001, 6.9740000000000002, 6.649, 6.9829999999999997, 7.2309999999999999, 6.4429999999999996, 6.6840000000000002, 6.8070000000000004, 6.4850000000000003, 6.9400000000000004, 6.944, 6.4640000000000004, 6.4889999999999999, 6.9009999999999998, 6.9539999999999997]
 2504         ri_data['NOE_750'] = [0.61909999999999998, 0.65890000000000004, 0.72009999999999996, 0.71009999999999995, 0.75219999999999998, 0.80420000000000003, 0.70020000000000004, 0.81999999999999995, 0.81040000000000001, 0.83409999999999995, 0.81299999999999994, 0.81910000000000005, 0.7782, 0.74760000000000004, 0.8115, 0.7379, 0.81100000000000005, 0.78249999999999997, 0.75729999999999997, 0.78259999999999996, 0.75139999999999996, 0.65210000000000001]
 2505 
 2506         ri_data_err = {}
 2507         ri_data_err['R1_500'] = [0.044999999999999998, 0.044999999999999998, 0.044499999999999998, 0.048000000000000001, 0.043999999999999997, 0.047, 0.0465, 0.048000000000000001, 0.045499999999999999, 0.048000000000000001, 0.047500000000000001, 0.045499999999999999, 0.048000000000000001, 0.0465, 0.044499999999999998, 0.047, 0.0465, 0.045499999999999999, 0.045499999999999999, 0.045999999999999999, 0.045499999999999999, 0.044499999999999998]
 2508         ri_data_err['R2_500'] = [0.107, 0.1075, 0.10249999999999999, 0.1135, 0.11899999999999999, 0.11650000000000001, 0.11600000000000001, 0.121, 0.1265, 0.11799999999999999, 0.123, 0.122, 0.1215, 0.1125, 0.17599999999999999, 0.11749999999999999, 0.11749999999999999, 0.123, 0.1145, 0.111, 0.1145, 0.108]
 2509         ri_data_err['NOE_500'] = [0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003]
 2510         ri_data_err['R1_600'] = [0.037999999999999999, 0.040000000000000001, 0.040500000000000001, 0.0395, 0.0385, 0.041000000000000002, 0.040000000000000001, 0.040500000000000001, 0.040000000000000001, 0.042000000000000003, 0.041500000000000002, 0.039, 0.042000000000000003, 0.042000000000000003, 0.0395, 0.040500000000000001, 0.040000000000000001, 0.039, 0.0395, 0.040000000000000001, 0.040500000000000001, 0.039]
 2511         ri_data_err['R2_600'] = [0.1125, 0.11550000000000001, 0.108, 0.1235, 0.1265, 0.1275, 0.123, 0.125, 0.1285, 0.12, 0.128, 0.13350000000000001, 0.1225, 0.11899999999999999, 0.1265, 0.1195, 0.128, 0.129, 0.1225, 0.122, 0.1265, 0.1225]
 2512         ri_data_err['NOE_600'] = [0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003]
 2513         ri_data_err['R1_750'] = [0.032500000000000001, 0.034000000000000002, 0.035000000000000003, 0.033500000000000002, 0.032500000000000001, 0.035499999999999997, 0.034000000000000002, 0.034000000000000002, 0.035499999999999997, 0.036499999999999998, 0.033500000000000002, 0.032500000000000001, 0.036999999999999998, 0.035499999999999997, 0.035499999999999997, 0.035000000000000003, 0.033500000000000002, 0.033000000000000002, 0.034000000000000002, 0.033000000000000002, 0.034000000000000002, 0.033500000000000002]
 2514         ri_data_err['R2_750'] = [0.1255, 0.1305, 0.11799999999999999, 0.13400000000000001, 0.13800000000000001, 0.13550000000000001, 0.13150000000000001, 0.14050000000000001, 0.13950000000000001, 0.13300000000000001, 0.14000000000000001, 0.14449999999999999, 0.129, 0.13400000000000001, 0.13600000000000001, 0.1295, 0.13850000000000001, 0.13900000000000001, 0.1295, 0.13, 0.13800000000000001, 0.13900000000000001]
 2515         ri_data_err['NOE_750'] = [0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003, 0.050000000000000003]
 2516 
 2517         # Misc tests.
 2518         self.assertEqual(cdp.pipe_type, 'mf')
 2519         self.assertEqual(cdp.hybrid_pipes, [])
 2520 
 2521         # Diffusion tensor tests.
 2522         self.assertEqual(cdp.diff_tensor.type, 'sphere')
 2523         self.assertEqual(cdp.diff_tensor.tm, 6.2029050826362826e-09)
 2524 
 2525         # Global minimisation statistic tests.
 2526         self.assertEqual(cdp.chi2, 88.0888600975)
 2527         self.assertEqual(cdp.iter, 1)
 2528         self.assertEqual(cdp.f_count, 20)
 2529         self.assertEqual(cdp.g_count, 2)
 2530         self.assertEqual(cdp.h_count, 1)
 2531         self.assertEqual(cdp.warning, None)
 2532 
 2533         # Global relaxation data tests.
 2534         self.assertEqual(cdp.ri_ids, ri_ids)
 2535         for ri_id in ri_ids:
 2536             self.assertEqual(cdp.ri_type[ri_id], ri_type[ri_id])
 2537             self.assertEqual(cdp.spectrometer_frq[ri_id], frqs[ri_id])
 2538 
 2539         # Loop over the residues of the original data.
 2540         j = 0
 2541         for i in range(len(cdp.mol[0].res)):
 2542             # Aliases
 2543             res = cdp.mol[0].res[i]
 2544             spin = cdp.mol[0].res[i].spin[0]
 2545             h_spin = None
 2546             if len(cdp.mol[0].res[i].spin) > 1:
 2547                 h_spin = cdp.mol[0].res[i].spin[1]
 2548 
 2549             # Debugging printout.
 2550             print(res)
 2551             print(spin)
 2552 
 2553             # Spin info tests.
 2554             self.assertEqual(res.num, num[i])
 2555             self.assertEqual(res.name, 'XXX')
 2556             self.assertEqual(spin.num, None)
 2557             if select[i]:
 2558                 self.assertEqual(spin.name, 'N')
 2559                 self.assertEqual(spin.fixed, False)
 2560             else:
 2561                 self.assertEqual(spin.name, None)
 2562             self.assertEqual(spin.select, select[i])
 2563             if h_spin:
 2564                 self.assertEqual(h_spin.num, None)
 2565                 self.assertEqual(h_spin.name, 'H')
 2566                 self.assertEqual(h_spin.select, False)
 2567 
 2568             # Skip deselected spins.
 2569             if not select[i]:
 2570                 continue
 2571 
 2572             # Nuclear isotope info.
 2573             self.assertEqual(spin.isotope, '15N')
 2574             self.assertEqual(h_spin.isotope, '1H')
 2575 
 2576             # Model-free tests.
 2577             self.assertEqual(spin.model, model[j])
 2578             self.assertEqual(spin.equation, 'mf_ext')
 2579             self.assertEqual(spin.params, params[j])
 2580             self.assertEqual(spin.s2, s2[j])
 2581             self.assertEqual(spin.s2f, s2f[j])
 2582             self.assertEqual(spin.s2s, s2s[j])
 2583             self.assertEqual(spin.local_tm, None)
 2584             self.assertEqual(spin.te, None)
 2585             if tf[j] != None:
 2586                 tf[j] = tf[j]*1e-12
 2587             self.assertEqual(spin.tf, tf[j])
 2588             self.assertEqual(spin.ts, ts[j]*1e-12)
 2589             if rex[j] != None:
 2590                 rex[j] = rex[j]/(2.0*pi*500000000.0)**2
 2591             self.assertEqual(spin.rex, rex[j])
 2592             self.assertEqual(spin.csa, -0.00016999999999999999)
 2593 
 2594             # Minimisation statistic tests.
 2595             self.assertEqual(spin.chi2, None)
 2596             self.assertEqual(spin.iter, None)
 2597             self.assertEqual(spin.f_count, None)
 2598             self.assertEqual(spin.g_count, None)
 2599             self.assertEqual(spin.h_count, None)
 2600             self.assertEqual(spin.warning, None)
 2601 
 2602             # Relaxation data tests.
 2603             for ri_id in cdp.ri_ids:
 2604                 print(ri_id)
 2605                 self.assertEqual(spin.ri_data[ri_id], ri_data[ri_id][j])
 2606                 self.assertEqual(spin.ri_data_err[ri_id], ri_data_err[ri_id][j])
 2607 
 2608             # Secondary index.
 2609             j = j + 1
 2610 
 2611         # The interatomic data tests.
 2612         for i in range(len(cdp.interatomic)):
 2613             self.assertEqual(cdp.interatomic[i].r, 1.0200000000000001e-10)
 2614 
 2615 
 2616     def test_read_results_1_2_pse4(self):
 2617         """Read the truncated relax 1.2 model-free results file for PSE-4."""
 2618 
 2619         # Read the results.
 2620         self.interpreter.results.read(file='pse4_trunc', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free')
 2621 
 2622         # Debugging printout.
 2623         print(cdp)
 2624 
 2625         # The spin specific data.
 2626         num = [24, 27]
 2627         name = ['ser', 'gln']
 2628         eqi = [None, 'mf_ext']
 2629         select = [False, True]
 2630         model = [None, 'm5']
 2631         params = [[], ['s2f', 's2', 'ts']]
 2632         s2 = [None, 0.86578779694713515]
 2633         s2f = [None, 0.88618694421409949]
 2634         s2s = [None, 0.97698098871784322]
 2635         s2s_sim = [[None, None, None],
 2636                 [0.95852080081635382, 0.97574415413309512, 0.97293450506144197]]
 2637         tf = [None, None]
 2638         ts = [None, 598.8142249659868e-12]
 2639         rex = [None, None]
 2640         csa = [None, -0.00017199999999999998]
 2641         ri_ids = ['R1_800', 'NOE_800', 'R1_600', 'R2_600', 'NOE_600', 'R1_500', 'R2_500', 'NOE_500']
 2642         ri_type_list = ['R1', 'NOE', 'R1', 'R2', 'NOE', 'R1', 'R2', 'NOE']
 2643         frq_list = [799744000.0]*2 + [599737000.0]*3 + [499719000.0]*3
 2644         ri_data_list = [[],
 2645                 [0.6835, 0.81850000000000001, 0.98409999999999997, 16.5107, 0.79796699999999998, 1.3174999999999999, 15.381500000000001, 0.73046900000000003]]
 2646         ri_data_err_list = [[],
 2647                 [0.026957200000000001, 0.025881000000000001, 0.0243073, 0.497137, 0.028663000000000001, 0.038550000000000001, 0.40883999999999998, 0.022016299999999999]]
 2648         ri_type = {}
 2649         frq = {}
 2650         ri_data = [{}, {}]
 2651         ri_data_err = [{}, {}]
 2652         for i in range(len(ri_ids)):
 2653             ri_type[ri_ids[i]] = ri_type_list[i]
 2654             frq[ri_ids[i]] = frq_list[i]
 2655             ri_data[1][ri_ids[i]] = ri_data_list[1][i]
 2656             ri_data_err[1][ri_ids[i]] = ri_data_err_list[1][i]
 2657 
 2658         # The interatomic data.
 2659         r = [None, 1.0200000000000001e-10]
 2660 
 2661         # Misc tests.
 2662         self.assertEqual(cdp.pipe_type, 'mf')
 2663         self.assertEqual(cdp.hybrid_pipes, [])
 2664 
 2665         # Diffusion tensor tests.
 2666         self.assertEqual(cdp.diff_tensor.type, 'ellipsoid')
 2667         self.assertEqual(cdp.diff_tensor.tm, 1.2682770910095516e-08)
 2668         self.assertEqual(cdp.diff_tensor.tm_err, 2.4053909822304126e-11)
 2669         self.assertEqual(cdp.diff_tensor.tm_sim[0], 1.2666656725867738e-08)
 2670         self.assertEqual(cdp.diff_tensor.tm_sim[1], 1.2689812011679408e-08)
 2671         self.assertEqual(cdp.diff_tensor.tm_sim[2], 1.2698266641804573e-08)
 2672 
 2673         # Global minimisation statistic tests.
 2674         self.assertEqual(cdp.chi2, 935.13348627485448)
 2675         self.assertEqual(cdp.chi2_sim[0], 898.0981500197106)
 2676         self.assertEqual(cdp.chi2_sim[1], 904.11113814725172)
 2677         self.assertEqual(cdp.chi2_sim[2], 902.03890817023728)
 2678         self.assertEqual(cdp.iter, 1)
 2679         self.assertEqual(cdp.iter_sim[0], 23)
 2680         self.assertEqual(cdp.iter_sim[1], 30)
 2681         self.assertEqual(cdp.iter_sim[2], 16)
 2682         self.assertEqual(cdp.f_count, 21)
 2683         self.assertEqual(cdp.f_count_sim[0], 61)
 2684         self.assertEqual(cdp.f_count_sim[1], 501)
 2685         self.assertEqual(cdp.f_count_sim[2], 59)
 2686         self.assertEqual(cdp.g_count, 2)
 2687         self.assertEqual(cdp.g_count_sim[0], 27)
 2688         self.assertEqual(cdp.g_count_sim[1], 34)
 2689         self.assertEqual(cdp.g_count_sim[2], 20)
 2690         self.assertEqual(cdp.h_count, 1)
 2691         self.assertEqual(cdp.h_count_sim[0], 23)
 2692         self.assertEqual(cdp.h_count_sim[1], 30)
 2693         self.assertEqual(cdp.h_count_sim[2], 16)
 2694         self.assertEqual(cdp.warning, None)
 2695         self.assertEqual(cdp.warning_sim[0], None)
 2696         self.assertEqual(cdp.warning_sim[1], None)
 2697         self.assertEqual(cdp.warning_sim[2], None)
 2698 
 2699         # Global relaxation data tests.
 2700         self.assertEqual(cdp.ri_ids, ri_ids)
 2701         for ri_id in ri_ids:
 2702             self.assertEqual(cdp.ri_type[ri_id], ri_type[ri_id])
 2703             self.assertEqual(cdp.spectrometer_frq[ri_id], frq[ri_id])
 2704 
 2705         # Loop over the residues of the original data.
 2706         for i in range(len(cdp.mol[0].res)):
 2707             # Aliases
 2708             res = cdp.mol[0].res[i]
 2709             spin = cdp.mol[0].res[i].spin[0]
 2710             h_spin = cdp.mol[0].res[i].spin[1]
 2711 
 2712             # Debugging printout.
 2713             print(res)
 2714             print(spin)
 2715 
 2716             # Spin info tests.
 2717             self.assertEqual(res.num, num[i])
 2718             self.assertEqual(res.name, name[i])
 2719             self.assertEqual(spin.num, None)
 2720             self.assertEqual(spin.name, 'N')
 2721             self.assertEqual(spin.select, select[i])
 2722             self.assertEqual(spin.fixed, False)
 2723             self.assertEqual(h_spin.num, None)
 2724             self.assertEqual(h_spin.name, 'H')
 2725             self.assertEqual(h_spin.select, False)
 2726 
 2727             # Nuclear isotope info.
 2728             self.assertEqual(spin.isotope, '15N')
 2729             self.assertEqual(h_spin.isotope, '1H')
 2730 
 2731             # Model-free tests.
 2732             self.assertEqual(spin.model, model[i])
 2733             self.assertEqual(spin.equation, eqi[i])
 2734             self.assertEqual(spin.params, params[i])
 2735             self.assertEqual(spin.s2, s2[i])
 2736             self.assertEqual(spin.s2f, s2f[i])
 2737             self.assertEqual(spin.s2s, s2s[i])
 2738             self.assertEqual(spin.local_tm, None)
 2739             self.assertEqual(spin.te, None)
 2740             self.assertEqual(spin.tf, tf[i])
 2741             self.assertEqual(spin.ts, ts[i])
 2742             self.assertEqual(spin.rex, rex[i])
 2743             self.assertEqual(spin.csa, csa[i])
 2744             for j in range(3):
 2745                 self.assertEqual(spin.s2s_sim[j], s2s_sim[i][j])
 2746 
 2747             # Minimisation statistic tests.
 2748             self.assertEqual(spin.chi2, None)
 2749             self.assertEqual(spin.iter, None)
 2750             self.assertEqual(spin.f_count, None)
 2751             self.assertEqual(spin.g_count, None)
 2752             self.assertEqual(spin.h_count, None)
 2753             self.assertEqual(spin.warning, None)
 2754 
 2755             # Relaxation data tests.
 2756             if i == 0:
 2757                 self.assertEqual(spin.ri_data, {})
 2758                 self.assertEqual(spin.ri_data_err, {})
 2759             else:
 2760                 for ri_id in ri_ids:
 2761                     self.assertEqual(spin.ri_data[ri_id], ri_data[i][ri_id])
 2762                     self.assertEqual(spin.ri_data_err[ri_id], ri_data_err[i][ri_id])
 2763 
 2764         # The interatomic data tests.
 2765         for i in range(len(cdp.interatomic)):
 2766             self.assertEqual(cdp.interatomic[i].r, r[i])
 2767 
 2768 
 2769     def test_read_results_1_2_tem1(self):
 2770         """Read the truncated relax 1.2 model-free results file for TEM-1."""
 2771 
 2772         # Read the results.
 2773         self.interpreter.results.read(file='tem1_trunc', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free')
 2774 
 2775         # Debugging printout.
 2776         print(cdp)
 2777 
 2778         # The spin specific data.
 2779         num = [26, 27, 29, 30, 31, 32, 33, 34]
 2780         name = ['His', 'Pro', 'Thr', 'Leu', 'Val', 'Lys', 'Val', 'Lys']
 2781         eqi = [None, None, None, 'mf_ext', 'mf_orig', 'mf_orig', None, 'mf_orig']
 2782         select = [False, False, False, True, True, True, False, True]
 2783         model = [None, None, None, 'm5', 'm2', 'm1', None, 'm1']
 2784         params = [None, None, None, ['s2f', 's2', 'ts'], ['s2', 'te'], ['s2'], None, ['s2']]
 2785         s2 = [None, None, None, 0.85674161305142216, 0.89462664243726608, 0.90201790111143165, None, 0.92099297347361675]
 2786         s2f = [None, None, None, 0.88220054271390302, None, None, None, None]
 2787         s2s = [None, None, None, 0.97114156200339452, None, None, None, None]
 2788         te = [None, None, None, None, 43.262426916926735*1e-12, None, None, None]
 2789         tf = [None, None, None, None, None, None, None, None]
 2790         ts = [None, None, None, 2385.912514843546*1e-12, None, None, None, None]
 2791         rex = [None, None, None, None, None, None, None, None]
 2792         csa = [None, None, None, -0.00017199999999999998, -0.00017199999999999998, -0.00017199999999999998, None, -0.00017199999999999998]
 2793         ri_ids = ['R1_800', 'R2_800', 'R1_600', 'R2_600', 'NOE_600', 'R1_500', 'R2_500', 'NOE_500']
 2794         ri_type_list = ['R1', 'R2', 'R1', 'R2', 'NOE', 'R1', 'R2', 'NOE']
 2795         frq_list = [799812000.0]*2 + [599739000.0]*3 + [499827000.0]*3
 2796         ri_data_list = [[],
 2797                         [],
 2798                         [],
 2799                         [0.75680000000000003, 18.797999999999998, 1.0747, 16.477, 0.86873100000000003, 1.2625999999999999, 15.3367, 0.77803197999999996],
 2800                         [0.75019999999999998, 19.201599999999999, 1.0617000000000001, 17.652899999999999, 0.73757200000000001, 1.3165, 15.949, 0.72442474000000001],
 2801                         [0.75860000000000005, 19.303799999999999, 1.0605, 16.593699999999998, 0.79137500000000005, 1.3425, 15.327199999999999, 0.83449132000000004],
 2802                         [],
 2803                         [0.71919999999999995, 20.165400000000002, 1.0729, 17.291899999999998, 0.80444599999999999, 1.2971999999999999, 15.9963, 0.73164684999999996]]
 2804         ri_data_err_list = [[],
 2805                             [],
 2806                             [],
 2807                             [0.028001600000000001, 0.21729999999999999, 0.031166300000000001, 0.44487900000000002, 0.043210699999999998, 0.054291800000000001, 0.69015199999999999, 0.038901600000000001],
 2808                             [0.028899999999999999, 0.25640000000000002, 0.030789299999999999, 0.476628, 0.036686799999999999, 0.0566095, 0.71770500000000004, 0.036221200000000002],
 2809                             [0.033399999999999999, 0.2233, 0.030754500000000001, 0.44802999999999998, 0.039363000000000002, 0.057727500000000001, 0.689724, 0.041724600000000001],
 2810                             [],
 2811                             [0.027699999999999999, 0.52810000000000001, 0.031399999999999997, 0.46688099999999999, 0.040013100000000003, 0.055779599999999999, 0.71983399999999997, 0.036582299999999998]]
 2812         ri_type = {}
 2813         frq = {}
 2814         ri_data = []
 2815         ri_data_err = []
 2816         for i in range(len(ri_data_list)):
 2817             ri_data.append({})
 2818             ri_data_err.append({})
 2819 
 2820         for i in range(len(ri_ids)):
 2821             ri_type[ri_ids[i]] = ri_type_list[i]
 2822             frq[ri_ids[i]] = frq_list[i]
 2823             for j in range(len(ri_data_list)):
 2824                 if len(ri_data_list[j]):
 2825                     ri_data[j][ri_ids[i]] = ri_data_list[j][i]
 2826                     ri_data_err[j][ri_ids[i]] = ri_data_err_list[j][i]
 2827 
 2828         chi2 = [None, None, None, 7.9383923597292441, 10.93852890925343, 3.1931459495488084, None, 8.3598891989018611]
 2829         iter = [None, None, None, 55, 10, 3, None, 3]
 2830         f_count = [None, None, None, 170, 148, 10, None, 10]
 2831         g_count = [None, None, None, 60, 14, 6, None, 6]
 2832         h_count = [None, None, None, 55, 10, 3, None, 3]
 2833 
 2834         # The interatomic data.
 2835         r = [None, None, None, 1.0200000000000001e-10, 1.0200000000000001e-10, 1.0200000000000001e-10, None, 1.0200000000000001e-10]
 2836 
 2837         # Misc tests.
 2838         self.assertEqual(cdp.pipe_type, 'mf')
 2839         self.assertEqual(cdp.hybrid_pipes, [])
 2840 
 2841         # Diffusion tensor tests.
 2842         self.assertEqual(cdp.diff_tensor.type, 'ellipsoid')
 2843         self.assertEqual(cdp.diff_tensor.tm, 1.2526607261882971e-08)
 2844         self.assertEqual(cdp.diff_tensor.Da, 2784606.8835473624)
 2845         self.assertEqual(cdp.diff_tensor.Dr, 0.097243698709517518)
 2846         self.assertEqual(cdp.diff_tensor.alpha, 48.852555276419558 / 360.0 * 2.0 * pi)
 2847         self.assertEqual(cdp.diff_tensor.beta, 9.7876096346750447 / 360.0 * 2.0 * pi)
 2848         self.assertEqual(cdp.diff_tensor.gamma, 42.15815798778408 / 360.0 * 2.0 * pi)
 2849 
 2850         # Global relaxation data tests.
 2851         self.assertEqual(cdp.ri_ids, ri_ids)
 2852         for ri_id in ri_ids:
 2853             self.assertEqual(cdp.ri_type[ri_id], ri_type[ri_id])
 2854             self.assertEqual(cdp.spectrometer_frq[ri_id], frq[ri_id])
 2855 
 2856         # Loop over the residues of the original data.
 2857         for i in range(len(cdp.mol[0].res)):
 2858             # Aliases
 2859             res = cdp.mol[0].res[i]
 2860             spin = cdp.mol[0].res[i].spin[0]
 2861             h_spin = cdp.mol[0].res[i].spin[1]
 2862 
 2863             # Debugging printout.
 2864             print(res)
 2865             print(spin)
 2866 
 2867             # Spin info tests.
 2868             self.assertEqual(res.num, num[i])
 2869             self.assertEqual(res.name, name[i])
 2870             self.assertEqual(spin.num, None)
 2871             self.assertEqual(spin.name, 'N')
 2872             self.assertEqual(spin.select, select[i])
 2873             self.assertEqual(spin.fixed, False)
 2874             self.assertEqual(h_spin.num, None)
 2875             self.assertEqual(h_spin.name, 'H')
 2876             self.assertEqual(h_spin.select, False)
 2877 
 2878             # Nuclear isotope info.
 2879             self.assertEqual(spin.isotope, '15N')
 2880             self.assertEqual(h_spin.isotope, '1H')
 2881 
 2882             # Model-free tests.
 2883             self.assertEqual(spin.model, model[i])
 2884             self.assertEqual(spin.equation, eqi[i])
 2885             self.assertEqual(spin.params, params[i])
 2886             self.assertEqual(spin.s2, s2[i])
 2887             self.assertEqual(spin.s2f, s2f[i])
 2888             self.assertEqual(spin.s2s, s2s[i])
 2889             self.assertEqual(spin.local_tm, None)
 2890             self.assertEqual(spin.te, te[i])
 2891             self.assertEqual(spin.tf, tf[i])
 2892             self.assertEqual(spin.ts, ts[i])
 2893             self.assertEqual(spin.rex, rex[i])
 2894             self.assertEqual(spin.csa, csa[i])
 2895 
 2896             # Minimisation statistic tests.
 2897             self.assertEqual(spin.chi2, chi2[i])
 2898             self.assertEqual(spin.iter, iter[i])
 2899             self.assertEqual(spin.f_count, f_count[i])
 2900             self.assertEqual(spin.g_count, g_count[i])
 2901             self.assertEqual(spin.h_count, h_count[i])
 2902             self.assertEqual(spin.warning, None)
 2903 
 2904             # Relaxation data tests.
 2905             if not len(ri_data[i]):
 2906                 self.assertEqual(spin.ri_data, {})
 2907                 self.assertEqual(spin.ri_data_err, {})
 2908             else:
 2909                 for ri_id in ri_ids:
 2910                     self.assertEqual(spin.ri_data[ri_id], ri_data[i][ri_id])
 2911                     self.assertEqual(spin.ri_data_err[ri_id], ri_data_err[i][ri_id])
 2912 
 2913         # The interatomic data tests.
 2914         for i in range(len(cdp.interatomic)):
 2915             self.assertEqual(cdp.interatomic[i].r, r[i])
 2916 
 2917 
 2918     def test_read_results_1_3_v1(self):
 2919         """Read a 1.3 model-free results file (relax XML version 1)."""
 2920 
 2921         # Path of the files.
 2922         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 2923 
 2924         # Read the results file.
 2925         self.interpreter.pipe.create('1.3', 'mf')
 2926         self.interpreter.results.read(file='final_results_trunc2_1.3_v1', dir=path)
 2927 
 2928         # The shared part of the test.
 2929         self.check_read_results_1_3()
 2930 
 2931 
 2932     def test_read_results_1_3_pre_py273_v1(self):
 2933         """Read a 1.3 model-free results file (pre-Python 2.7.3, relax XML version 1)."""
 2934 
 2935         # Path of the files.
 2936         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 2937 
 2938         # Read the results file.
 2939         self.interpreter.pipe.create('1.3', 'mf')
 2940         self.interpreter.results.read(file='final_results_trunc2_1.3_pre_py2.7.3_v1', dir=path)
 2941 
 2942         # The shared part of the test.
 2943         self.check_read_results_1_3()
 2944 
 2945 
 2946     def test_read_results_1_3_v2(self):
 2947         """Read a 1.3 model-free results file (relax XML version 2)."""
 2948 
 2949         # Path of the files.
 2950         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 2951 
 2952         # Read the results file.
 2953         self.interpreter.pipe.create('1.3', 'mf')
 2954         self.interpreter.results.read(file='final_results_trunc2_1.3_v2', dir=path)
 2955 
 2956         # The shared part of the test.
 2957         self.check_read_results_1_3()
 2958 
 2959 
 2960     def test_read_results_1_3_v2_broken(self):
 2961         """Read a 1.3 model-free results file (relax XML version 2) with corrupted floats.
 2962 
 2963         The floats are deliberately mangled to test the IEEE-754 reading.
 2964         """
 2965 
 2966         # Path of the files.
 2967         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 2968 
 2969         # Read the results file.
 2970         self.interpreter.pipe.create('1.3', 'mf')
 2971         self.interpreter.results.read(file='final_results_trunc2_1.3_v2_broken', dir=path)
 2972 
 2973         # The shared part of the test.
 2974         self.check_read_results_1_3()
 2975 
 2976 
 2977     def test_read_results_1_3_pre_py273_v2(self):
 2978         """Read a 1.3 model-free results file (pre-Python 2.7.3, relax XML version 2)."""
 2979 
 2980         # Path of the files.
 2981         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 2982 
 2983         # Read the results file.
 2984         self.interpreter.pipe.create('1.3', 'mf')
 2985         self.interpreter.results.read(file='final_results_trunc2_1.3_pre_py2.7.3_v2', dir=path)
 2986 
 2987         # The shared part of the test.
 2988         self.check_read_results_1_3()
 2989 
 2990 
 2991     def test_select_m4(self):
 2992         """Selecting model m4 with parameters {S2, te, Rex} using model_free.select_model()."""
 2993 
 2994         # Path of the files.
 2995         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'
 2996 
 2997         # Read the sequence.
 2998         self.interpreter.sequence.read(file='noe.500.out', dir=path, res_num_col=1, res_name_col=2)
 2999 
 3000         # Select the model.
 3001         self.interpreter.model_free.select_model(model='m4')
 3002 
 3003         # Test the model.
 3004         self.assertEqual(cdp.mol[0].res[1].spin[0].model, 'm4')
 3005         self.assertEqual(cdp.mol[0].res[1].spin[0].params, ['s2', 'te', 'rex'])
 3006 
 3007 
 3008     def test_set_csa(self):
 3009         """Setting the CSA value through the user function value.set()."""
 3010 
 3011         # Path of the files.
 3012         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'S2_0.970_te_2048_Rex_0.149'
 3013 
 3014         # Read the sequence.
 3015         self.interpreter.sequence.read(file='noe.500.out', dir=path, res_num_col=1, res_name_col=2)
 3016 
 3017         # Set the CSA value.
 3018         self.interpreter.value.set(N15_CSA, 'csa')
 3019 
 3020         # Test the value.
 3021         self.assertEqual(cdp.mol[0].res[1].spin[0].csa, N15_CSA)
 3022 
 3023 
 3024     def test_tm0_grid(self):
 3025         """Test the optimisation of the tm0 model-free parameter grid."""
 3026 
 3027         # Initialise.
 3028         cdp._model = 'tm0'
 3029         cdp._value_test = self.value_test
 3030 
 3031         # Setup the data pipe for optimisation.
 3032         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm0_grid.py')
 3033 
 3034 
 3035     def test_tm1_grid(self):
 3036         """Test the optimisation of the tm1 model-free parameter grid."""
 3037 
 3038         # Initialise.
 3039         cdp._model = 'tm1'
 3040         cdp._value_test = self.value_test
 3041 
 3042         # Setup the data pipe for optimisation.
 3043         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm1_grid.py')
 3044 
 3045 
 3046     def test_tm2_grid(self):
 3047         """Test the optimisation of the tm2 model-free parameter grid."""
 3048 
 3049         # Initialise.
 3050         cdp._model = 'tm2'
 3051         cdp._value_test = self.value_test
 3052 
 3053         # Setup the data pipe for optimisation.
 3054         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm2_grid.py')
 3055 
 3056 
 3057     def test_tm3_grid(self):
 3058         """Test the optimisation of the tm3 model-free parameter grid."""
 3059 
 3060         # Initialise.
 3061         cdp._model = 'tm3'
 3062         cdp._value_test = self.value_test
 3063 
 3064         # Setup the data pipe for optimisation.
 3065         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm3_grid.py')
 3066 
 3067 
 3068     def test_tm4_grid(self):
 3069         """Test the optimisation of the tm4 model-free parameter grid."""
 3070 
 3071         # Initialise.
 3072         cdp._model = 'tm4'
 3073         cdp._value_test = self.value_test
 3074 
 3075         # Setup the data pipe for optimisation.
 3076         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm4_grid.py')
 3077 
 3078 
 3079     def test_tm5_grid(self):
 3080         """Test the optimisation of the tm5 model-free parameter grid."""
 3081 
 3082         # Initialise.
 3083         cdp._model = 'tm5'
 3084         cdp._value_test = self.value_test
 3085 
 3086         # Setup the data pipe for optimisation.
 3087         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm5_grid.py')
 3088 
 3089 
 3090     def test_tm6_grid(self):
 3091         """Test the optimisation of the tm6 model-free parameter grid."""
 3092 
 3093         # Initialise.
 3094         cdp._model = 'tm6'
 3095         cdp._value_test = self.value_test
 3096 
 3097         # Setup the data pipe for optimisation.
 3098         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm6_grid.py')
 3099 
 3100 
 3101     def test_tm7_grid(self):
 3102         """Test the optimisation of the tm7 model-free parameter grid."""
 3103 
 3104         # Initialise.
 3105         cdp._model = 'tm7'
 3106         cdp._value_test = self.value_test
 3107 
 3108         # Setup the data pipe for optimisation.
 3109         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm7_grid.py')
 3110 
 3111 
 3112     def test_tm8_grid(self):
 3113         """Test the optimisation of the tm8 model-free parameter grid."""
 3114 
 3115         # Initialise.
 3116         cdp._model = 'tm8'
 3117         cdp._value_test = self.value_test
 3118 
 3119         # Setup the data pipe for optimisation.
 3120         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm8_grid.py')
 3121 
 3122 
 3123     def test_tm9_grid(self):
 3124         """Test the optimisation of the tm9 model-free parameter grid."""
 3125 
 3126         # Initialise.
 3127         cdp._model = 'tm9'
 3128         cdp._value_test = self.value_test
 3129 
 3130         # Setup the data pipe for optimisation.
 3131         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'opt_tm9_grid.py')
 3132 
 3133 
 3134     def test_tylers_peptide(self):
 3135         """Try a component of model-free analysis on Tyler Reddy's peptide data (truncated)."""
 3136 
 3137         # Execute the script.
 3138         self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'model_free'+sep+'tylers_peptide.py')
 3139 
 3140 
 3141     def test_write_results(self):
 3142         """Writing of model-free results using the user function results.write()."""
 3143 
 3144         # Path of the files.
 3145         path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP'
 3146 
 3147         # Read the results file.
 3148         self.interpreter.results.read(file='final_results_trunc2_1.2', dir=path)
 3149 
 3150         # A dummy file object for catching the results.write() output.
 3151         file = DummyFileObject()
 3152 
 3153         # Write the results file into a dummy file.
 3154         self.interpreter.results.write(file=file, dir=path)
 3155 
 3156         # Now, get the contents of that file, and then 'close' that file.
 3157         test_lines = file.readlines()
 3158         file.close()
 3159 
 3160         # Read the results file for Python 3.2+.
 3161         if sys.version_info[0] >= 3 and sys.version_info[1] >= 2:
 3162             file = open_read_file(file_name='final_results_trunc2_3.0', dir=path)
 3163 
 3164         # Read the results file for Python 3.1.
 3165         elif sys.version_info[0] >= 3 and sys.version_info[1] == 1:
 3166             file = open_read_file(file_name='final_results_trunc2_3.0_oldxml', dir=path)
 3167 
 3168         # Read the results file for Python 2.7.3+ (excluding Python 3).
 3169         elif dep_check.xml_type == 'internal' and sys.version_info[0] >= 2 and sys.version_info[1] >= 7 and sys.version_info[2] >= 3:
 3170             file = open_read_file(file_name='final_results_trunc2_3.0', dir=path)
 3171 
 3172         # Read the results file for pre Python 2.7.3 versions.
 3173         else:
 3174             file = open_read_file(file_name='final_results_trunc2_3.0_oldxml', dir=path)
 3175 
 3176         # Extract the data, then close the results file.
 3177         true_lines = file.readlines()
 3178         file.close()
 3179 
 3180         # Test the rest of the lines.
 3181         for i in range(len(test_lines)):
 3182             # Skip the second line, as it contains the date and hence should not be the same.
 3183             # Also skip the third line, as the pipe names are different.
 3184             if i == 1 or i == 2:
 3185                 continue
 3186 
 3187             # Alias the lines.
 3188             test = test_lines[i]
 3189             true = true_lines[i]
 3190 
 3191             # Try to convert the test line into a python object (for cross-platform support).
 3192             try:
 3193                 # Process the post 2.7.3 Python XML.
 3194                 if search('<value>', test):
 3195                     test = test.lstrip()
 3196                     test = test.replace('<value>', '')
 3197                     test = test.replace('</value>', '')
 3198                 if search('<ieee_754_byte_array>', test):
 3199                     test = test.lstrip()
 3200                     test = test.replace('<ieee_754_byte_array>', '')
 3201                     test = test.replace('</ieee_754_byte_array>', '')
 3202 
 3203                 test = eval(test)
 3204             except:
 3205                 pass
 3206 
 3207             # Try to convert the true line into a python object (for cross-platform support).
 3208             try:
 3209                 # Process the post 2.7.3 Python XML.
 3210                 if search('<value>', true):
 3211                     true = true.lstrip()
 3212                     true = true.replace('<value>', '')
 3213                     true = true.replace('</value>', '')
 3214                 if search('<ieee_754_byte_array>', true):
 3215                     true = true.lstrip()
 3216                     true = true.replace('<ieee_754_byte_array>', '')
 3217                     true = true.replace('</ieee_754_byte_array>', '')
 3218 
 3219                 true = eval(true)
 3220             except:
 3221                 pass
 3222 
 3223             # Test that the line is the same.
 3224             self.assertEqual(test, true)
 3225 
 3226 
 3227     def value_test(self, spin, select=True, local_tm=None, s2=None, s2f=None, s2s=None, te=None, tf=None, ts=None, rex=None, chi2=None, iter=None, f_count=None, g_count=None, h_count=None, warning=None):
 3228         """Test the optimisation values."""
 3229 
 3230         # Get the debugging message.
 3231         mesg = self.mesg_opt_debug(spin)
 3232 
 3233         # Convert to lists.
 3234         if iter != None and not isinstance(iter, list):
 3235             iter = [iter]
 3236         if f_count != None and not isinstance(f_count, list):
 3237             f_count = [f_count]
 3238         if g_count != None and not isinstance(g_count, list):
 3239             g_count = [g_count]
 3240         if h_count != None and not isinstance(h_count, list):
 3241             h_count = [h_count]
 3242 
 3243         # Test all the values.
 3244         ######################
 3245 
 3246         # Spin selection.
 3247         self.assertEqual(spin.select, select, msg=mesg)
 3248 
 3249         # The local tm correlation time.
 3250         if local_tm != None:
 3251             self.assertAlmostEqual(spin.local_tm / 1e-9, local_tm, msg=mesg)
 3252         else:
 3253             self.assertEqual(spin.local_tm, None, msg=mesg)
 3254 
 3255         # S2 order parameter.
 3256         if s2 != None:
 3257             self.assertAlmostEqual(spin.s2, s2, msg=mesg)
 3258         else:
 3259             self.assertEqual(spin.s2, None, msg=mesg)
 3260 
 3261         # S2f order parameter.
 3262         if s2f != None:
 3263             self.assertAlmostEqual(spin.s2f, s2f, 5, msg=mesg)
 3264         else:
 3265             self.assertEqual(spin.s2f, None, msg=mesg)
 3266 
 3267         # S2s order parameter.
 3268         if s2s != None:
 3269             self.assertAlmostEqual(spin.s2s, s2s, 5, msg=mesg)
 3270         else:
 3271             self.assertEqual(spin.s2s, None, msg=mesg)
 3272 
 3273         # te correlation time.
 3274         if isinstance(te, float):
 3275             self.assertAlmostEqual(spin.te / 1e-12, te, 5, msg=mesg)
 3276         elif te == None:
 3277             self.assertEqual(spin.te, None, msg=mesg)
 3278 
 3279         # tf correlation time.
 3280         if isinstance(tf, float):
 3281             self.assertAlmostEqual(spin.tf / 1e-12, tf, 4, msg=mesg)
 3282         elif tf == None:
 3283             self.assertEqual(spin.tf, None, msg=mesg)
 3284 
 3285         # ts correlation time.
 3286         if isinstance(ts, float):
 3287             self.assertAlmostEqual(spin.ts / 1e-12, ts, 4, msg=mesg)
 3288         elif ts == None:
 3289             self.assertEqual(spin.ts, None, msg=mesg)
 3290 
 3291         # Chemical exchange.
 3292         if isinstance(rex, float):
 3293             self.assertAlmostEqual(spin.rex * (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2, rex * (2.0 * pi * cdp.spectrometer_frq[cdp.ri_ids[0]])**2, msg=mesg)
 3294         elif rex == None:
 3295             self.assertEqual(spin.rex, None, msg=mesg)
 3296 
 3297         # The optimisation stats.
 3298         if chi2 != None:
 3299             self.assertAlmostEqual(spin.chi2, chi2, msg=mesg)
 3300         if iter != None:
 3301             self.assert_(spin.iter in iter, msg=mesg)
 3302         if f_count != None:
 3303             self.assert_(spin.f_count in f_count, msg=mesg)
 3304         if g_count != None:
 3305             self.assert_(spin.g_count in g_count, msg=mesg)
 3306         if h_count != None:
 3307             self.assert_(spin.h_count in h_count, msg=mesg)
 3308         if warning != None:
 3309             self.assertEqual(spin.warning, warning, msg=mesg)