Author: bugman
Date: Wed Feb 11 09:55:57 2015
New Revision: 27622
URL: http://svn.gna.org/viewcvs/relax?rev=27622&view=rev
Log:
Created the Test_object.test_add_atom_sort unit test.
This is from the _lib._structure._internal.test_object unit test module. The
test will be used to
implement the sorting of input data by residue number in the add_atom()
internal structural object
method. This will mean that added atoms will be placed in residue sequence
order, so that output
PDB files are correctly ordered.
Modified:
trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
Modified: trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py?rev=27622&r1=27621&r2=27622&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
(original)
+++ trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
Wed Feb 11 09:55:57 2015
@@ -26,3 +26,55 @@
class Test_object(UnitTestCase):
"""Unit tests for the lib.structure.internal.object internal structural
object module."""
+
+ def test_add_atom_sort(self):
+ """Test for automated atom sequence sorting of the add_atom()
method."""
+
+ # Initialise a structural object and add some atoms.
+ struct = object.Internal()
+
+ # Create three molecules 'X', 'Y', and 'Z' with some atoms.
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=1,
mol_name='X', pos=[1., 0., -1.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=1,
mol_name='Y', pos=[0., 0., 0.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=1,
mol_name='Z', pos=[-1., 0., 1.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=3,
mol_name='X', pos=[1., 2., -1.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=3,
mol_name='Y', pos=[0., 2., 0.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=3,
mol_name='Z', pos=[-1., 2., 1.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=2,
mol_name='X', pos=[1., 20., -1.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=2,
mol_name='Y', pos=[0., 20., 0.], element='S')
+ struct.add_atom(atom_name='A', res_name='UNK', res_num=2,
mol_name='Z', pos=[-1., 20., 1.], element='S')
+
+ # The sorted data.
+ data = [[
+ ['A', 'UNK', 1, [1., 0., -1.], 'S'],
+ ['A', 'UNK', 2, [1., 20., -1.], 'S'],
+ ['A', 'UNK', 3, [1., 2., -1.], 'S']
+ ], [
+ ['A', 'UNK', 1, [0., 0., 0.], 'S'],
+ ['A', 'UNK', 2, [0., 20., 0.], 'S'],
+ ['A', 'UNK', 3, [0., 2., 0.], 'S']
+ ], [
+ ['A', 'UNK', 1, [-1., 0., 1.], 'S'],
+ ['A', 'UNK', 2, [-1., 20., 1.], 'S'],
+ ['A', 'UNK', 3, [-1., 2., 1.], 'S']
+ ]]
+ mol_names = ['X', 'Y', 'Z']
+
+ # Test the object.
+ self.assertEqual(len(struct.structural_data), 1)
+ for i in range(len(struct.structural_data[0].mol)):
+ # Alias.
+ mol = struct.structural_data[0].mol[i]
+
+ # Check the molecule data.
+ self.assertEqual(mol.mol_name, mol_names[i])
+
+ # Loop over the atoms.
+ for j in range(len(mol.atom_name)):
+ self.assertEqual(mol.atom_name[j], data[i][j][0])
+ self.assertEqual(mol.res_name[j], data[i][j][1])
+ self.assertEqual(mol.res_num[j], data[i][j][2])
+ self.assertEqual(mol.x[j], data[i][j][3][0])
+ self.assertEqual(mol.y[j], data[i][j][3][1])
+ self.assertEqual(mol.z[j], data[i][j][3][2])
+ self.assertEqual(mol.element[j], data[i][j][4])
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits