Author: bugman Date: Tue Apr 8 17:19:34 2008 New Revision: 5443 URL: http://svn.gna.org/viewcvs/relax?rev=5443&view=rev Log: Code shift. Shifted the residue number check (cannot have 2 residues with the same number) and 1st element replacement (if that ResidueContainer is empty) code from generic_fns.residue.create() to the relax data storage object (the ResidueContainer.add_item() method). Modified: 1.3/data/mol_res_spin.py 1.3/generic_fns/residue.py Modified: 1.3/data/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=5443&r1=5442&r2=5443&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Tue Apr 8 17:19:34 2008 @@ -187,9 +187,21 @@ def add_item(self, res_name=None, res_num=None, select=True): - """Function for appending an empty container to the list.""" - - self.append(ResidueContainer(res_name, res_num, select)) + """Append an empty ResidueContainer to the ResidueList.""" + + # Test if the residue number already exists. + for i in xrange(len(self)): + if self[i].num == res_num: + raise RelaxError, "The residue number '" + `res_num` + "' already exists in the sequence." + + # If no residue data exists, replace the empty first residue with this residue. + if self[0].num == None and self[0].name == None and len(self) == 1: + self[0].num = res_num + self[0].name = res_name + + # Append a new ResidueContainer. + else: + self.append(ResidueContainer(res_name, res_num, select)) Modified: 1.3/generic_fns/residue.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/residue.py?rev=5443&r1=5442&r2=5443&view=diff ============================================================================== --- 1.3/generic_fns/residue.py (original) +++ 1.3/generic_fns/residue.py Tue Apr 8 17:19:34 2008 @@ -134,19 +134,8 @@ else: mol_to_cont = relax_data_store[relax_data_store.current_pipe].mol[0] - # Test if the residue number already exists. - for i in xrange(len(mol_to_cont.res)): - if mol_to_cont.res[i].num == res_num: - raise RelaxError, "The residue number '" + `res_num` + "' already exists in the sequence." - - # If no residue data exists, replace the empty first residue with this residue. - if mol_to_cont.res[0].num == None and mol_to_cont.res[0].name == None and len(mol_to_cont.res) == 1: - mol_to_cont.res[0].num = res_num - mol_to_cont.res[0].name = res_name - - # Append the residue. - else: - mol_to_cont.res.add_item(res_num=res_num, res_name=res_name) + # Add the residue. + mol_to_cont.res.add_item(res_num=res_num, res_name=res_name) def delete(res_id=None):