Author: bugman Date: Fri Jan 23 11:03:35 2015 New Revision: 27288 URL: http://svn.gna.org/viewcvs/relax?rev=27288&view=rev Log: Implemented the internal structural object MolContainer.loop_residues() method.
This generator method is used to quickly loop over all residues of the molecule. Modified: trunk/lib/structure/internal/molecules.py Modified: trunk/lib/structure/internal/molecules.py URL: http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/molecules.py?rev=27288&r1=27287&r2=27288&view=diff ============================================================================== --- trunk/lib/structure/internal/molecules.py (original) +++ trunk/lib/structure/internal/molecules.py Fri Jan 23 11:03:35 2015 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2008-2014 Edward d'Auvergne # +# Copyright (C) 2008-2015 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -491,6 +491,22 @@ return self.res_num[-1] + def loop_residues(self): + """Generator method for looping over the individual residues of the molecule. + + @return: The residue name and number. + @rtype: str, int + """ + + # Loop over the atoms. + last_res = None + for i in range(len(self.atom_num)): + # A new residue. + if self.res_num[i] != last_res: + last_res = self.res_num[i] + yield self.res_name[i], self.res_num[i] + + def merge(self, mol_cont=None): """Merge the contents of the given molecule container into here. _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org 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