Author: bugman Date: Thu May 22 17:21:05 2014 New Revision: 23340 URL: http://svn.gna.org/viewcvs/relax?rev=23340&view=rev Log: Important bug fix for the structure.delete user function when multiple models are present. This is to fix bug #22070 (https://gna.org/bugs/index.php?22070), the failure of the structure.superimpose user function after deleting atoms with structure.delete. The problem is that structure.delete was removing the atoms from the first model but none of the others. This is because it was using the structural object atom_loop() method to find the atoms to be deleted, but this method operates on the first model. So when the second model is reached, the atoms are already gone. 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=23340&r1=23339&r2=23340&view=diff ============================================================================== --- trunk/lib/structure/internal/object.py (original) +++ trunk/lib/structure/internal/object.py Thu May 22 17:21:05 2014 @@ -1532,6 +1532,12 @@ if atom_id: sel_obj = Selection(atom_id) + # Loop over the atoms and find the indices of the atoms to delete. + indices = [] + for i in self.atom_loop(atom_id=atom_id, index_flag=True): + indices.append(i) + indices.reverse() + # Loop over the models. del_res_nums = [] for model in self.model_loop(): @@ -1543,16 +1549,10 @@ if sel_obj and not sel_obj.contains_mol(mol.mol_name): continue - # Loop over the atoms. - indices = [] - for i in self.atom_loop(atom_id=atom_id, model_num=model.num, index_flag=True): - indices.append(i) - # Generate a residue data dictionary for the metadata trimming (prior to atom deletion). res_data = self._residue_data(res_nums=mol.res_num, res_names=mol.res_name) # Loop over the reverse indices and pop out the data. - indices.reverse() for i in indices: mol.atom_num.pop(i) mol.atom_name.pop(i)