mailr25773 - 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 September 12, 2014 - 11:22:
Author: bugman
Date: Fri Sep 12 11:22:42 2014
New Revision: 25773

URL: http://svn.gna.org/viewcvs/relax?rev=25773&view=rev
Log:
The model argument in the structure.delete user function is now operational.

In the internal object, it has two functions.  When the atom_id argument is 
none, then new
ModelList.delete_model() function is being called to remove the entire model 
from the list of
structural models.  When the atom_id argument is supplied, then only the 
corresponding atoms in the
given model will be deleted.


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=25773&r1=25772&r2=25773&view=diff
==============================================================================
--- trunk/lib/structure/internal/models.py      (original)
+++ trunk/lib/structure/internal/models.py      Fri Sep 12 11:22:42 2014
@@ -88,6 +88,23 @@
 
         # Return the model container.
         return self[-1]
+
+
+    def delete_model(self, model_num=None):
+        """Delete the given model from the list.
+
+        @keyword model_num: The model to delete.
+        @type model_num:    int
+        """
+
+        # Sanity check.
+        if model_num not in self.current_models:
+            raise RelaxError("The model %s does not exist." % model_num)
+
+        # Remove the model from the lists (self and the current models).
+        index = self.current_models.index(model_num)
+        self.pop(index)
+        self.current_models.pop(index)
 
 
     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=25773&r1=25772&r2=25773&view=diff
==============================================================================
--- trunk/lib/structure/internal/object.py      (original)
+++ trunk/lib/structure/internal/object.py      Fri Sep 12 11:22:42 2014
@@ -1521,7 +1521,7 @@
         """
 
         # All data.
-        if atom_id == None:
+        if model == None and atom_id == None:
             # Printout.
             if verbosity:
                 print("Deleting the following structural data:\n")
@@ -1532,6 +1532,10 @@
 
             # Initialise the empty model list.
             self.structural_data = ModelList()
+
+        # Delete a whole model.
+        elif atom_id == None:
+            self.structural_data.delete_model(model_num=model)
 
         # Atom subset deletion.
         else:
@@ -1548,10 +1552,14 @@
 
             # Loop over the models.
             del_res_nums = []
-            for model in self.model_loop():
+            for model_cont in self.model_loop():
+                # Skip models.
+                if model != None and model_cont.num == model:
+                    continue
+
                 # Loop over the molecules.
-                for mol_index in range(len(model.mol)):
-                    mol = model.mol[mol_index]
+                for mol_index in range(len(model_cont.mol)):
+                    mol = model_cont.mol[mol_index]
 
                     # Skip non-matching molecules.
                     if sel_obj and not sel_obj.contains_mol(mol.mol_name):
@@ -1581,6 +1589,8 @@
 
             # Nothing more to do.
             if not len(del_res_nums):
+                return
+            if model != None and len(self.structural_data) > 1:
                 return
 
             # Fix the deleted residue number order.




Related Messages


Powered by MHonArc, Updated Fri Sep 12 11:40:02 2014