Author: bugman
Date: Wed Feb 11 10:17:07 2015
New Revision: 27623

URL: http://svn.gna.org/viewcvs/relax?rev=27623&view=rev
Log:
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.


Modified:
    trunk/lib/structure/internal/molecules.py
    trunk/lib/structure/internal/object.py

Modified: trunk/lib/structure/internal/molecules.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/molecules.py?rev=27623&r1=27622&r2=27623&view=diff
==============================================================================
--- trunk/lib/structure/internal/molecules.py   (original)
+++ trunk/lib/structure/internal/molecules.py   Wed Feb 11 10:17:07 2015
@@ -258,6 +258,35 @@
         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]
+
+
+    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.
 

Modified: trunk/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/object.py?rev=27623&r1=27622&r2=27623&view=diff
==============================================================================
--- trunk/lib/structure/internal/object.py      (original)
+++ trunk/lib/structure/internal/object.py      Wed Feb 11 10:17:07 2015
@@ -1159,6 +1159,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):


_______________________________________________
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

Reply via email to