mailr27630 - in /branches/frame_order_cleanup: ./ lib/structure/internal/ test_suite/system_tests/ test_suite/unit_tests/_lib/_s...


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on February 11, 2015 - 11:32:
Author: bugman
Date: Wed Feb 11 11:32:28 2015
New Revision: 27630

URL: http://svn.gna.org/viewcvs/relax?rev=27630&view=rev
Log:
Merged revisions 27620-27629 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r27620 | bugman | 2015-02-10 13:24:55 +0100 (Tue, 10 Feb 2015) | 6 lines
  
  Fix for the Structure.test_atomic_fluctuations_no_match system test.
  
  The structure.atomic_fluctuations user function will now raise a RelaxError 
when no data
  corresponding to the atom ID can be found, so the test now checks for this.
........
  r27621 | bugman | 2015-02-11 09:25:58 +0100 (Wed, 11 Feb 2015) | 3 lines
  
  Created the unit test infrastructure for the lib.structure.internal.object 
module.
........
  r27622 | bugman | 2015-02-11 09:55:57 +0100 (Wed, 11 Feb 2015) | 8 lines
  
  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.
........
  r27623 | bugman | 2015-02-11 10:17:07 +0100 (Wed, 11 Feb 2015) | 9 lines
  
  Implementation of methods for sorting sequence data in the internal 
structural object.
  
  The information is sorted in the molecule container level using the new 
MolContainer._sort() private
  method.  This uses the _sort_key() helper method which determines what the 
new order should be.
  This is used as the 'key' argument for the Python sort() method.  Instead 
of list shuffling, new
  lists in the correct order are created.  Although not memory efficient, 
this might be faster than
  shuffling.
........
  r27624 | bugman | 2015-02-11 10:23:45 +0100 (Wed, 11 Feb 2015) | 6 lines
  
  The loading of structural data now sorts the data if the merge flag is True.
  
  The pack_structs() method for sorting the data will now call the new 
MolContainer._sort() function
  is the data is being merged.  This is to ensure that the final structural 
data is correctly ordered.
........
  r27625 | bugman | 2015-02-11 10:29:27 +0100 (Wed, 11 Feb 2015) | 3 lines
  
  Fixes for a number of Structure system tests for the sorted structural data 
changes.
........
  r27626 | bugman | 2015-02-11 10:48:24 +0100 (Wed, 11 Feb 2015) | 7 lines
  
  Modified the structure.read_pdb user function backend to skip water 
molecules.
  
  All residues with the name 'HOH' are now skipped when loading PDB files.  
This is implemented in the
  MolContainer.fill_object_from_pdb() method, and a RelaxWarning is printed 
listing the residue
  numbers of all skipped waters.
........
  r27627 | bugman | 2015-02-11 10:49:57 +0100 (Wed, 11 Feb 2015) | 6 lines
  
  Modified the Structure.test_read_pdb_1UBQ system test for the new water 
skipping feature.
  
  As the structure.read_pdb user function will now skip waters, the last atom 
in the structural object
  will now be the last ubiquitin atom and not the last water atom.
........
  r27628 | bugman | 2015-02-11 11:25:41 +0100 (Wed, 11 Feb 2015) | 7 lines
  
  Modified the Test_object.test_add_atom_sort unit test to check atom 
connectivities.
  
  This is from the _lib._structure._internal.test_object unit test module.  
The problem is that the
  MolContainer._sort() method for sorting the structural data currently does 
not correctly update the
  bonded data structure.
........
  r27629 | bugman | 2015-02-11 11:28:15 +0100 (Wed, 11 Feb 2015) | 6 lines
  
  Completed the implementation of the sorting of structural data in the 
internal structural object.
  
  The MolContainer._sort() private method now changes the connect atom 
indices in the bonded data
  structure to the new sorted indices.
........

Added:
    
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
      - copied unchanged from r27629, 
trunk/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/lib/structure/internal/molecules.py
    branches/frame_order_cleanup/lib/structure/internal/object.py
    branches/frame_order_cleanup/test_suite/system_tests/structure.py
    
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/__init__.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Feb 11 11:32:28 2015
@@ -1 +1 @@
-/trunk:1-27618
+/trunk:1-27629

Modified: branches/frame_order_cleanup/lib/structure/internal/molecules.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/structure/internal/molecules.py?rev=27630&r1=27629&r2=27630&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/structure/internal/molecules.py    
(original)
+++ branches/frame_order_cleanup/lib/structure/internal/molecules.py    Wed 
Feb 11 11:32:28 2015
@@ -258,6 +258,40 @@
         return fields
 
 
+    def _sort(self):
+        """Sort all structural data."""
+
+        # Create an index list for sorting the structural data.
+        indices = range(len(self.atom_name))
+        indices.sort(key=self._sort_key)
+
+        # Sort all lists.
+        self.atom_num = [self.atom_num[i] for i in indices]
+        self.atom_name = [self.atom_name[i] for i in indices]
+        self.bonded = [self.bonded[i] for i in indices]
+        self.chain_id = [self.chain_id[i] for i in indices]
+        self.element = [self.element[i] for i in indices]
+        self.pdb_record = [self.pdb_record[i] for i in indices]
+        self.res_name = [self.res_name[i] for i in indices]
+        self.res_num = [self.res_num[i] for i in indices]
+        self.seg_id = [self.seg_id[i] for i in indices]
+        self.x = [self.x[i] for i in indices]
+        self.y = [self.y[i] for i in indices]
+        self.z = [self.z[i] for i in indices]
+
+        # Change the bonded numbers, as the indices are now different.
+        for i in range(len(self.bonded)):
+            for j in range(len(self.bonded[i])):
+                self.bonded[i][j] = indices.index(self.bonded[i][j])
+
+
+    def _sort_key(self, i):
+        """Return the information for sorting the sequence data."""
+
+        # Sort based on residue number.
+        return self.res_num[i]
+
+
     def atom_add(self, atom_name=None, res_name=None, res_num=None, 
pos=[None, None, None], element=None, atom_num=None, chain_id=None, 
segment_id=None, pdb_record=None):
         """Method for adding an atom to the structural data object.
 
@@ -359,6 +393,7 @@
         """
 
         # Loop over the records.
+        water = []
         for record in records:
             # Nothing to do.
             if not record or record == '\n':
@@ -372,6 +407,11 @@
                 if record[:6] == 'HETATM':
                     record_type, serial, name, alt_loc, res_name, chain_id, 
res_seq, icode, x, y, z, occupancy, temp_factor, element, charge = 
pdb_read.hetatm(record)
 
+                # Skip waters.
+                if res_name == 'HOH':
+                    water.append(res_seq)
+                    continue
+
                 # Handle the alternate locations.
                 if alt_loc != None:
                     # Don't know what to do.
@@ -406,6 +446,9 @@
 
                     # Make the connection.
                     self.atom_connect(index1=self._atom_index(serial), 
index2=self._atom_index(bonded))
+
+        if len(water):
+            warn(RelaxWarning("Skipping the water molecules HOH %s." % 
water))
 
 
     def fill_object_from_xyz(self, records):

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=27630&r1=27629&r2=27630&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/structure/internal/object.py       
(original)
+++ branches/frame_order_cleanup/lib/structure/internal/object.py       Wed 
Feb 11 11:32:28 2015
@@ -1162,6 +1162,9 @@
 
             # Add the atom.
             mol.atom_add(atom_name=atom_name, res_name=res_name, 
res_num=res_num, pos=model_pos, element=element, atom_num=atom_num, 
chain_id=chain_id, segment_id=segment_id, pdb_record=pdb_record)
+
+            # Sort.
+            mol._sort()
 
 
     def add_model(self, model=None, coords_from=None):
@@ -2455,6 +2458,9 @@
                 mol.file_mol_num = orig_mol_num[j]
                 mol.file_model = orig_model_num[i]
 
+                # Sort the structural data if a merge occurred.
+                mol._sort()
+
 
     def rotate(self, R=None, origin=None, model=None, selection=None):
         """Rotate the structural information about the given origin.

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=27630&r1=27629&r2=27630&view=diff
==============================================================================
--- branches/frame_order_cleanup/test_suite/system_tests/structure.py   
(original)
+++ branches/frame_order_cleanup/test_suite/system_tests/structure.py   Wed 
Feb 11 11:32:28 2015
@@ -104,7 +104,7 @@
         self.interpreter.structure.translate(T=[0., 0., 1.], model=2)
 
         # Add some atoms that should not be aligned.
-        self.interpreter.structure.add_atom(mol_name='uniform_mol1', 
atom_name='Ti', res_name='TST', res_num=1, pos=[[1.0, 2.0, 3.0], [1.0, 2.0, 
3.0]], element='Ti', pdb_record='HETATM')
+        self.interpreter.structure.add_atom(mol_name='uniform_mol1', 
atom_name='Ti', res_name='TST', res_num=100, pos=[[1.0, 2.0, 3.0], [1.0, 2.0, 
3.0]], element='Ti', pdb_record='HETATM')
 
         # The alignment.
         self.interpreter.structure.superimpose(pipes=['ref', 'align'], 
method='fit to first', atom_id='@N,H', displace_id='@N,H')
@@ -174,7 +174,7 @@
             ["H", "HIS", 29,    4.107,  -7.113,   7.347],
             ["N", "ALA", 30,    0.000,  -0.000,  10.000],
             ["H", "ALA", 30,    0.000,  -0.000,  11.020],
-            ["Ti", "TST", 1,  1.000,  2.000,  3.000]
+            ["Ti", "TST", 100,  1.000,   2.000,   3.000]
         ]
 
         # The selection object.
@@ -253,8 +253,8 @@
         self.interpreter.structure.translate(T=[0., 0., 1.], atom_id='#2')
 
         # Add some atoms that should not be aligned.
-        self.interpreter.structure.add_atom(mol_name='1', atom_name='Ti', 
res_name='TST', res_num=1, pos=[1.0, 2.0, 3.0], element='Ti', 
pdb_record='HETATM')
-        self.interpreter.structure.add_atom(mol_name='2', atom_name='Ti', 
res_name='TST', res_num=1, pos=[1.0, 2.0, 3.0], element='Ti', 
pdb_record='HETATM')
+        self.interpreter.structure.add_atom(mol_name='1', atom_name='Ti', 
res_name='TST', res_num=100, pos=[1.0, 2.0, 3.0], element='Ti', 
pdb_record='HETATM')
+        self.interpreter.structure.add_atom(mol_name='2', atom_name='Ti', 
res_name='TST', res_num=100, pos=[1.0, 2.0, 3.0], element='Ti', 
pdb_record='HETATM')
 
         # The alignment.
         self.interpreter.structure.superimpose(pipes=['ref', 'align'], 
molecules=[['ref'], ['1', '2']], method='fit to first', atom_id='@N,H', 
displace_id='@N,H')
@@ -324,7 +324,7 @@
             ["H", "HIS", 29,    4.107,  -7.113,   7.347],
             ["N", "ALA", 30,    0.000,  -0.000,  10.000],
             ["H", "ALA", 30,    0.000,  -0.000,  11.020],
-            ["Ti", "TST", 1,  1.000,  2.000,  3.000]
+            ["Ti", "TST", 100,  1.000,   2.000,   3.000]
         ]
 
         # The selection object.
@@ -375,10 +375,10 @@
             self.assertAlmostEqual(mol1.y[i], mol2.y[i], 2)
             self.assertAlmostEqual(mol1.z[i], mol2.z[i], 2)
 
-        # The last atom must be different - it is not displaced.
-        self.assertAlmostEqual(mol1.x[-1] - mol2.x[-1], -1.0, 2)
-        self.assertAlmostEqual(mol1.y[-1] - mol2.y[-1], -1.0, 2)
-        self.assertAlmostEqual(mol1.z[-1] - mol2.z[-1], -1.0, 2)
+        # The first 'Ti' atom must be different - it is not displaced.
+        self.assertAlmostEqual(mol1.x[0] - mol2.x[0], -1.0, 2)
+        self.assertAlmostEqual(mol1.y[0] - mol2.y[0], -1.0, 2)
+        self.assertAlmostEqual(mol1.z[0] - mol2.z[0], -1.0, 2)
 
 
     def test_align_molecules_end_truncation(self):
@@ -573,11 +573,7 @@
 
         # Run the structure.atomic_fluctuations user function and collect 
the results in a dummy file object.
         file = DummyFileObject()
-        self.interpreter.structure.atomic_fluctuations(atom_id='@X', 
file=file, format='text')
-
-        # Check the file.
-        lines = file.readlines()
-        self.assertEqual(len(lines), 0)
+        self.assertRaises(RelaxError, 
self.interpreter.structure.atomic_fluctuations, atom_id='@X', file=file, 
format='text')
 
 
     def test_atomic_fluctuations_parallax(self):
@@ -3943,15 +3939,15 @@
         self.assertEqual(cdp.structure.structural_data[0].mol[0].z[0], 2.614)
         self.assertEqual(cdp.structure.structural_data[0].mol[0].element[0], 
'N')
 
-        # Check the last atom (from the last water HETATM record).
-        
self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_num[-1], 661)
-        
self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_name[-1], 'O')
-        
self.assertEqual(cdp.structure.structural_data[0].mol[0].chain_id[-1], None)
-        
self.assertEqual(cdp.structure.structural_data[0].mol[0].res_name[-1], 'HOH')
-        
self.assertEqual(cdp.structure.structural_data[0].mol[0].res_num[-1], 58)
-        self.assertEqual(cdp.structure.structural_data[0].mol[0].x[-1], 
37.667)
-        self.assertEqual(cdp.structure.structural_data[0].mol[0].y[-1], 
43.421)
-        self.assertEqual(cdp.structure.structural_data[0].mol[0].z[-1], 
17.000)
+        # Check the last atom (from the last ATOM record, as water HETATM 
records are skipped).
+        
self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_num[-1], 602)
+        
self.assertEqual(cdp.structure.structural_data[0].mol[0].atom_name[-1], 'OXT')
+        
self.assertEqual(cdp.structure.structural_data[0].mol[0].chain_id[-1], 'A')
+        
self.assertEqual(cdp.structure.structural_data[0].mol[0].res_name[-1], 'GLY')
+        
self.assertEqual(cdp.structure.structural_data[0].mol[0].res_num[-1], 76)
+        self.assertEqual(cdp.structure.structural_data[0].mol[0].x[-1], 
40.862)
+        self.assertEqual(cdp.structure.structural_data[0].mol[0].y[-1], 
39.575)
+        self.assertEqual(cdp.structure.structural_data[0].mol[0].z[-1], 
36.251)
         
self.assertEqual(cdp.structure.structural_data[0].mol[0].element[-1], 'O')
 
 
@@ -4871,10 +4867,10 @@
             self.assertAlmostEqual(model1.y[i], model2.y[i], 2)
             self.assertAlmostEqual(model1.z[i], model2.z[i], 2)
 
-        # The last atom must be different - it is not displaced.
-        self.assertAlmostEqual(model1.x[-1] - model2.x[-1], -1.0, 2)
-        self.assertAlmostEqual(model1.y[-1] - model2.y[-1], -1.0, 2)
-        self.assertAlmostEqual(model1.z[-1] - model2.z[-1], -1.0, 2)
+        # The first 'Ti' atom must be different - it is not displaced.
+        self.assertAlmostEqual(model1.x[0] - model2.x[0], -1.0, 2)
+        self.assertAlmostEqual(model1.y[0] - model2.y[0], -1.0, 2)
+        self.assertAlmostEqual(model1.z[0] - model2.z[0], -1.0, 2)
 
 
     def test_superimpose_fit_to_mean2(self):

Modified: 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/__init__.py?rev=27630&r1=27629&r2=27630&view=diff
==============================================================================
--- 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/__init__.py
    (original)
+++ 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/__init__.py
    Wed Feb 11 11:32:28 2015
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2013 Edward d'Auvergne                                       
 #
+# Copyright (C) 2013-2015 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -21,6 +21,7 @@
 
 
 __all__ = [
-    'test___init__'
-    'test_coordinates'
+    'test___init__',
+    'test_coordinates',
+    'test_object'
 ]




Related Messages


Powered by MHonArc, Updated Thu Feb 12 19:00:03 2015