Package test_suite :: Package system_tests :: Module interatomic
[hide private]
[frames] | no frames]

Source Code for Module test_suite.system_tests.interatomic

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2012-2013 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  # Module docstring. 
 23  """System tests of the interatomic data container operations.""" 
 24   
 25   
 26  # Python module imports. 
 27  from os import sep 
 28   
 29  # relax module imports. 
 30  from data_store import Relax_data_store; ds = Relax_data_store() 
 31  from lib.errors import RelaxNoSpinError 
 32  from status import Status; status = Status() 
 33  from test_suite.system_tests.base_classes import SystemTestCase 
 34   
 35   
36 -class Interatomic(SystemTestCase):
37 """Class for testing the interatomic functions.""" 38
39 - def test_copy(self):
40 """Test the operation of the interatom.copy user function.""" 41 42 # Create an initial data pipe. 43 self.interpreter.pipe.create(pipe_name="orig", pipe_type='N-state') 44 45 # Create some sequence data. 46 self.interpreter.molecule.create(mol_name='Test mol') 47 self.interpreter.residue.create(mol_name='Test mol', res_name='His', res_num=1) 48 self.interpreter.residue.create(mol_name='Test mol', res_name='His', res_num=2) 49 self.interpreter.spin.create(res_num=1, spin_name='N') 50 self.interpreter.spin.create(res_num=1, spin_name='H') 51 self.interpreter.spin.create(res_num=2, spin_name='N') 52 self.interpreter.spin.create(res_num=2, spin_name='H') 53 54 # Define the interatomic interaction. 55 self.interpreter.interatom.define(spin_id1=':1@N', spin_id2=':1@H', direct_bond=False) 56 self.interpreter.interatom.define(spin_id1=':2@N', spin_id2=':2@H', direct_bond=False) 57 58 # Add some test data. 59 cdp.interatomic[0].x = 1 60 cdp.interatomic[1].y = 2 61 62 # Create a new data pipe to copy the data to. 63 self.interpreter.pipe.create(pipe_name="new", pipe_type='N-state') 64 65 # Copy the data. 66 self.interpreter.sequence.copy(pipe_from='orig') 67 self.interpreter.interatom.copy(pipe_from='orig', spin_id1=':2@N', spin_id2=':2@H') 68 self.interpreter.interatom.copy(pipe_from='orig', spin_id1=':1@H', spin_id2=':1@N') 69 70 # Create a new data pipe to copy the data to. 71 self.interpreter.pipe.create(pipe_name="new 2", pipe_type='N-state') 72 73 # Copy the data. 74 try: 75 self.interpreter.interatom.copy(pipe_from='orig') 76 except RelaxNoSpinError: 77 print("Correct RelaxError encountered.") 78 self.interpreter.sequence.copy(pipe_from='orig') 79 self.interpreter.interatom.copy(pipe_from='orig') 80 81 # Loop over the two new pipes. 82 interatom_index = [[0, 1], [1, 0]] 83 pipes = ['new', 'new 2'] 84 for i in range(len(pipes)): 85 # Switch pipes. 86 self.interpreter.pipe.switch(pipes[i]) 87 88 # Check the sequence data. 89 self.assertEqual(cdp.mol[0].name, 'Test mol') 90 self.assertEqual(cdp.mol[0].res[0].name, 'His') 91 self.assertEqual(cdp.mol[0].res[0].spin[0].name, 'N') 92 self.assertEqual(cdp.mol[0].res[0].spin[1].name, 'H') 93 self.assertEqual(cdp.mol[0].res[1].name, 'His') 94 self.assertEqual(cdp.mol[0].res[1].spin[0].name, 'N') 95 self.assertEqual(cdp.mol[0].res[1].spin[1].name, 'H') 96 97 # Check the interatomic data. 98 self.assertEqual(cdp.interatomic[interatom_index[i][0]].spin_id1, '#Test mol:2@N') 99 self.assertEqual(cdp.interatomic[interatom_index[i][0]].spin_id2, '#Test mol:2@H') 100 self.assertEqual(cdp.interatomic[interatom_index[i][0]].y, 2) 101 self.assertEqual(cdp.interatomic[interatom_index[i][1]].spin_id1, '#Test mol:1@N') 102 self.assertEqual(cdp.interatomic[interatom_index[i][1]].spin_id2, '#Test mol:1@H') 103 self.assertEqual(cdp.interatomic[interatom_index[i][1]].x, 1)
104 105
106 - def test_manipulation(self):
107 """Test the manipulation of interatomic data containers.""" 108 109 # Execute the script. 110 self.script_exec(status.install_path + sep+'test_suite'+sep+'system_tests'+sep+'scripts'+sep+'interatomic_tests.py') 111 112 # The data. 113 select = [True, False] + [True]*3 + [False]*2 + [True]*5 + [False]*2 + [True, False] 114 115 # Check the data. 116 self.assertEqual(len(cdp.interatomic), 16) 117 for i in range(len(cdp.interatomic)): 118 # A printout to know where the problem is. 119 print("Checking container: %-30s %-30s" % (cdp.interatomic[i].spin_id1, cdp.interatomic[i].spin_id2)) 120 121 # The container checks. 122 self.assertEqual(cdp.interatomic[i].select, select[i])
123