Author: bugman Date: Mon Sep 22 10:30:44 2014 New Revision: 25946 URL: http://svn.gna.org/viewcvs/relax?rev=25946&view=rev Log: Merged revisions 25942-25945 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r25942 | bugman | 2014-09-22 09:59:35 +0200 (Mon, 22 Sep 2014) | 6 lines Created the Structure.test_collapse_ensemble system test. This is used to test a planned feature of the internal structural object. The collapse_ensemble() method will be created to remove all but one model in the structural ensemble. ........ r25943 | bugman | 2014-09-22 10:14:25 +0200 (Mon, 22 Sep 2014) | 5 lines Fixes for the structure.add_atom user function to allow for list of lists for the atomic position. This allows different coordinates to be supplied for each model. ........ r25944 | bugman | 2014-09-22 10:16:35 +0200 (Mon, 22 Sep 2014) | 5 lines Modified the Structure.test_collapse_ensemble system test to check the initial values. This is for sanity reasons as the test coverage of the structure.add_atom user function is poor. ........ r25945 | bugman | 2014-09-22 10:29:55 +0200 (Mon, 22 Sep 2014) | 5 lines Implemented the internal structural object collapse_ensemble() method. This allows the Structure.test_collapse_ensemble system test to pass. ........ Modified: branches/frame_order_cleanup/ (props changed) branches/frame_order_cleanup/lib/structure/internal/object.py branches/frame_order_cleanup/test_suite/system_tests/structure.py branches/frame_order_cleanup/user_functions/structure.py Propchange: branches/frame_order_cleanup/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Mon Sep 22 10:30:44 2014 @@ -1 +1 @@ -/trunk:1-25940 +/trunk:1-25945 Modified: branches/frame_order_cleanup/lib/structure/internal/object.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/structure/internal/object.py?rev=25946&r1=25945&r2=25946&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/structure/internal/object.py (original) +++ branches/frame_order_cleanup/lib/structure/internal/object.py Mon Sep 22 10:30:44 2014 @@ -1488,6 +1488,29 @@ return data + def collapse_ensemble(self, model_num=None, model_to=1): + """Collapse the ensemble into a single model. + + @keyword model_num: The number of the model to keep. All other models will be removed. + @type model_num: int + @keyword model_to: The model number for the sole remaining model. + @type model_to: int + """ + + # Store all the model numbers. + models = [] + for model_cont in self.model_loop(): + if model_cont.num != model_num: + models.append(model_cont.num) + + # Delete all models. + for model in models: + self.delete(model) + + # Renumber the remaining model. + self.set_model(model_orig=model_num, model_new=model_to) + + def connect_atom(self, mol_name=None, index1=None, index2=None): """Connect two atoms in the structural data object. Modified: branches/frame_order_cleanup/test_suite/system_tests/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/system_tests/structure.py?rev=25946&r1=25945&r2=25946&view=diff ============================================================================== --- branches/frame_order_cleanup/test_suite/system_tests/structure.py (original) +++ branches/frame_order_cleanup/test_suite/system_tests/structure.py Mon Sep 22 10:30:44 2014 @@ -243,6 +243,41 @@ # Superimpose. self.interpreter.structure.superimpose(method='fit to first', centre_type='CoM') + + + def test_collapse_ensemble(self): + """Test the collapse_ensemble() method of the internal structural object.""" + + # Create 2 models. + self.interpreter.structure.add_model(model_num=1) + self.interpreter.structure.add_model(model_num=2) + + # Add an atom. + self.interpreter.structure.add_atom(atom_name='H', res_name='Gly', res_num=1, pos=[[0.0, 1.0, 2.0], [1.0, 2.0, 3.0]], element='H') + + # Check the atomic data. + for i in range(2): + mol = cdp.structure.structural_data[i].mol[0] + self.assertEqual(len(mol.atom_name), 1) + self.assertEqual(mol.x[0], 0.0+i) + self.assertEqual(mol.y[0], 1.0+i) + self.assertEqual(mol.z[0], 2.0+i) + + # Collapse the ensemble to the 2nd model. + cdp.structure.collapse_ensemble(model_num=2, model_to=1) + + # Check the collapsed ensemble. + self.assert_(hasattr(cdp, 'structure')) + self.assertEqual(len(cdp.structure.structural_data), 1) + self.assertEqual(cdp.structure.structural_data[0].num, 1) + self.assertEqual(len(cdp.structure.structural_data[0].mol), 1) + + # Check the atomic data. + mol = cdp.structure.structural_data[0].mol[0] + self.assertEqual(len(mol.atom_name), 1) + self.assertEqual(mol.x[0], 1.0) + self.assertEqual(mol.y[0], 2.0) + self.assertEqual(mol.z[0], 3.0) def test_create_diff_tensor_pdb(self): Modified: branches/frame_order_cleanup/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/structure.py?rev=25946&r1=25945&r2=25946&view=diff ============================================================================== --- branches/frame_order_cleanup/user_functions/structure.py (original) +++ branches/frame_order_cleanup/user_functions/structure.py Mon Sep 22 10:30:44 2014 @@ -76,9 +76,8 @@ uf.add_keyarg( name = "pos", py_type = "float_object", - dim = 3, desc_short = "atomic position", - desc = "The atomic coordinates.", + desc = "The atomic coordinates. For specifying different coordinates for each model of the ensemble, a list of lists can be supplied.", list_titles = ['X coordinate', 'Y coordinate', 'Z coordinate'] ) uf.add_keyarg(