Author: bugman Date: Sun Apr 13 23:25:59 2008 New Revision: 5660 URL: http://svn.gna.org/viewcvs/relax?rev=5660&view=rev Log: Created the same_sequence() function to test if two pipes have the same sequence. Modified: 1.3/generic_fns/selection.py Modified: 1.3/generic_fns/selection.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/selection.py?rev=5660&r1=5659&r2=5660&view=diff ============================================================================== --- 1.3/generic_fns/selection.py (original) +++ 1.3/generic_fns/selection.py Sun Apr 13 23:25:59 2008 @@ -908,6 +908,51 @@ spin.select = 1 +def same_sequence(pipe1, pipe2): + """Test if the sequence data in both pipes are the same. + + @param pipe1: The first data pipe. + @type pipe1: str + @param pipe2: The second data pipe. + @type pipe2: str + @return: True if the sequence data matches, False otherwise. + @rtype: bool + """ + + # Test the data pipes. + pipes.test(pipe1) + pipes.test(pipe2) + + # Different number of molecules. + if len(relax_data_store[pipe1].mol) != len(relax_data_store[pipe2].mol): + return False + + # Loop over the molecules. + for i in xrange(len(relax_data_store[pipe1].mol)): + # Different number of residues. + if len(relax_data_store[pipe1].mol[i].res) != len(relax_data_store[pipe2].mol[i].res): + return False + + # Loop over the residues. + for j in xrange(len(relax_data_store[pipe1].mol[i].res)): + # Different number of spins. + if len(relax_data_store[pipe1].mol[i].res[j].spins) != len(relax_data_store[pipe2].mol[i].res[j].spins): + return False + + # Loop over the spins. + for k in xrange(len(relax_data_store[pipe1].mol[i].res[j].spins)): + # Different spin numbers. + if relax_data_store[pipe1].mol[i].res[j].spins[k].num != relax_data_store[pipe2].mol[i].res[j].spins[k].num: + return False + + # Different spin names. + if relax_data_store[pipe1].mol[i].res[j].spins[k].name != relax_data_store[pipe2].mol[i].res[j].spins[k].name: + return False + + # The sequence is the same. + return True + + def sel_all(self, run=None): """Function for selecting all residues."""