mailr22053 - in /trunk/lib/structure/internal: models.py object.py


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

Header


Content

Posted by edward on January 27, 2014 - 21:49:
Author: bugman
Date: Mon Jan 27 21:49:32 2014
New Revision: 22053

URL: http://svn.gna.org/viewcvs/relax?rev=22053&view=rev
Log:
Yet more optimisation for handling large quantities of models in the internal 
structural model.

Now when adding new models to the object, the model_indices and model_list 
objects are no longer
created.  This saves much time as the large model_list is now not sorted.  A 
number of structural
object methods have been updated to handle the change by switching to the 
model_loop() method for
looping over the models, rather than using the model_indices and model_list 
objects.


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

Modified: trunk/lib/structure/internal/models.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/models.py?rev=22053&r1=22052&r2=22053&view=diff
==============================================================================
--- trunk/lib/structure/internal/models.py (original)
+++ trunk/lib/structure/internal/models.py Mon Jan 27 21:49:32 2014
@@ -83,15 +83,6 @@
 
         # Update the current model list.
         self.current_models.append(model_num)
-
-        # Store the model indices.
-        if not hasattr(self, 'model_indices'):
-            self.model_indices = {}
-        self.model_indices[model_num] = len(self) - 1
-
-        # The sorted model numbers.
-        self.model_list = list(self.model_indices.keys())
-        self.model_list.sort()
 
 
     def is_empty(self):

Modified: trunk/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/object.py?rev=22053&r1=22052&r2=22053&view=diff
==============================================================================
--- trunk/lib/structure/internal/object.py (original)
+++ trunk/lib/structure/internal/object.py Mon Jan 27 21:49:32 2014
@@ -1261,14 +1261,9 @@
                         pos = zeros(3, float64)
 
                         # Loop over the models.
-                        for j in range(len(self.structural_data)):
-                            # A single model.
-                            if model_num != None and 
self.structural_data[j].num != model_num:
-                                continue
-
+                        for model in self.model_loop(model=model_num):
                             # Alias.
-                            model_index = 
self.structural_data.model_indices[self.structural_data.model_list[j]]
-                            mol2 = 
self.structural_data[model_index].mol[mol_index]
+                            mol2 = model.mol[mol_index]
 
                             # Some sanity checks.
                             if mol2.atom_num[i] != atom_num:
@@ -1286,14 +1281,9 @@
                         pos = []
 
                         # Loop over the models.
-                        for j in range(len(self.structural_data)):
-                            # A single model.
-                            if model_num != None and 
self.structural_data[j].num != model_num:
-                                continue
-
+                        for model in self.model_loop(model=model_num):
                             # Alias.
-                            model_index = 
self.structural_data.model_indices[self.structural_data.model_list[j]]
-                            mol2 = 
self.structural_data[model_index].mol[mol_index]
+                            mol2 = model.mol[mol_index]
 
                             # Append the position.
                             pos.append([mol2.x[i], mol2.y[i], mol2.z[i]])
@@ -1389,14 +1379,9 @@
             # Found the atom.
             if index != None:
                 # Loop over the models.
-                for j in range(len(self.structural_data)):
-                    # A single model.
-                    if model_num != None and self.structural_data[j].num != 
model_num:
-                        continue
-
-                    # Alias the molecule.
-                    model_index = 
self.structural_data.model_indices[self.structural_data.model_list[j]]
-                    mol = self.structural_data[model_index].mol[mol_index]
+                for model in self.model_loop(model=model_num):
+                    # Alias.
+                    mol = model.mol[mol_index]
 
                     # Get the atom bonded to this 
model/molecule/residue/atom.
                     bonded_num, bonded_name, element, pos, attached_name, 
warnings = self._bonded_atom(attached_atom, index, mol)




Related Messages


Powered by MHonArc, Updated Mon Jan 27 22:20:01 2014