Author: bugman
Date: Tue Sep 23 21:36:33 2014
New Revision: 25985

URL: http://svn.gna.org/viewcvs/relax?rev=25985&view=rev
Log:
Massive speed up of the internal structural object add_model() method.

This speeds up the structure.add_model user function, as well as many internal 
relax operations on
the structural object.  Instead of using the copy.deepcopy() function to 
duplicate an already
existing structural model, now new molecule container objects are created and 
then the individual
elements of the original molecule container data lists are copied one by one.  
This avoids copying a
lot of internal Python junk and hence the copying operation is now orders of 
magnitude faster.


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

Modified: trunk/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/object.py?rev=25985&r1=25984&r2=25985&view=diff
==============================================================================
--- trunk/lib/structure/internal/object.py      (original)
+++ trunk/lib/structure/internal/object.py      Tue Sep 23 21:36:33 2014
@@ -1138,7 +1138,26 @@
                     break
 
         # Duplicate all data from the MolList object down.
-        model.mol = deepcopy(model_from.mol)
+        for mol_index in range(len(model_from.mol)):
+            # Create a new molecule container.
+            model.mol.add_item(mol_name=model_from.mol[mol_index].mol_name, 
mol_cont=MolContainer())
+            mol = model.mol[mol_index]
+            mol_from = model_from.mol[mol_index]
+
+            # Loop over the atomic data.
+            for i in range(len(mol_from.atom_num)):
+                mol.atom_num.append(mol_from.atom_num[i])
+                mol.atom_name.append(mol_from.atom_name[i])
+                mol.bonded.append(mol_from.bonded[i])
+                mol.chain_id.append(mol_from.chain_id[i])
+                mol.element.append(mol_from.element[i])
+                mol.pdb_record.append(mol_from.pdb_record[i])
+                mol.res_name.append(mol_from.res_name[i])
+                mol.res_num.append(mol_from.res_num[i])
+                mol.seg_id.append(mol_from.seg_id[i])
+                mol.x.append(mol_from.x[i])
+                mol.y.append(mol_from.y[i])
+                mol.z.append(mol_from.z[i])
 
         # Return the model.
         return self.structural_data[-1]


_______________________________________________
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