Package test_suite :: Package unit_tests :: Package _lib :: Package _spectrum :: Module test_sparky
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib._spectrum.test_sparky

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 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  # Python module imports. 
23  from unittest import TestCase 
24   
25  # relax module imports. 
26  from lib.io import DummyFileObject 
27  from lib.spectrum.sparky import write_list 
28   
29   
30 -class Test_sparky(TestCase):
31 """Unit tests for the lib.software.sparky relax module.""" 32
33 - def test_write_list(self):
34 """Test the lib.software.sparky.write_list() function.""" 35 36 # The data. 37 res_names = ['LEU', 'GLY', 'SER', 'MET', 'TRP', 'TRP', 'ASN'] 38 res_nums = [3, 4, 5, 6, 40, 40, 55] 39 atom1_names = ['N', 'N', 'N', 'N', 'N', 'NE1', 'N'] 40 atom2_names = ['HN', 'HN', 'HN', 'HN', 'HN', 'HE1', 'HN'] 41 w1 = [122.454, 111.978, 115.069, 120.910, 123.335, 130.204, 116.896] 42 w2 = [8.397, 8.720, 8.177, 8.813, 8.005, 10.294, 7.468] 43 heights = [2535, 5050, 51643, 53663, -65111, -181131, -105322] 44 45 # The result. 46 file_data = [ 47 ' Assignment w1 w2 Data Height\n', 48 '\n', 49 ' LEU3N-HN 122.454 8.397 2535\n', 50 ' GLY4N-HN 111.978 8.720 5050\n', 51 ' SER5N-HN 115.069 8.177 51643\n', 52 ' MET6N-HN 120.910 8.813 53663\n', 53 ' TRP40N-HN 123.335 8.005 -65111\n', 54 ' TRP40NE1-HE1 130.204 10.294 -181131\n', 55 ' ASN55N-HN 116.896 7.468 -105322\n' 56 ] 57 58 # Write the data out. 59 file = DummyFileObject() 60 write_list(file_prefix=file, res_names=res_names, res_nums=res_nums, atom1_names=atom1_names, atom2_names=atom2_names, w1=w1, w2=w2, data_height=heights) 61 62 # Check the file data. 63 lines = file.readlines() 64 self.assertEqual(len(lines), len(file_data)) 65 for i in range(len(lines)): 66 self.assertEqual(lines[i], file_data[i])
67