Example #1
0
    def test_getOverlap_self(self): 
        '''test_getOverlap_self: the overlap between the same set of sequences must be 100%'''
        reads1, reads2, clones1, clones2, stats1, stats2 = tcrRepSim.getOverlap(self.samseqs, self.samseqs, [0, 0.01, 10, 20, 100])
        
        self.assertTrue( clones1[0] == len(self.samseqs) ) #number of clones/ uniq sequences 
        for i, c1 in enumerate( clones1 ): #each cutoff
            #every stats of sample 2 is exactly the same with sample 1
            self.assertTrue( c1 == clones2[i] ) 
            self.assertTrue( reads1[i] == reads2[i] )
            for k in stats1:
                self.assertTrue( stats1[k][i] == stats2[k][i] )
            
            #The overlaping stats is equal the the original stats:
            self.assertTrue( stats1["oclones"][i] == c1 )
            self.assertTrue( stats1["oreads"][i] == reads1[i] )

            #Number of reads must be >= number of clones
            self.assertTrue( reads1[i] >= clones1[i] )
            self.assertTrue( stats1["oreads"][i] >= stats1["oclones"][i] )

        #at 100% cutoff, numClones must be 0 if total numClones > 1
        if clones1[0] > 1:
            self.assertTrue( clones1[4] == 0 )

        #Number of clones decreases as the cutoff increases
        for i in xrange( 4 ):
            self.assertTrue( clones1[i] >= clones1[i + 1] )
Example #2
0
 def test_getOverlap_zeroOverlap(self):
     '''Two repertoires with zero overlap should return zero overlap'''
     samseqs1 = self.samseqs
     
     #create another repertoire with totally different length
     seqs2 = tcrRepSim.getUniqSeqRep(10, self.aaUsage[11], self.codonUsage)
     tcrRepSim.getRep( seqs2, 50, None )
     samseqs2 = tcrRepSim.sampling( seqs2, 20 )
     reads1, reads2, clones1, clones2, stats1, stats2 = tcrRepSim.getOverlap(samseqs1, samseqs2, [0, 0.01, 10, 20, 100])
     for i in xrange(5):
         self.assertTrue( stats1["oclones"][i] == 0 )
         self.assertTrue( stats2["oclones"][i] == 0 )
         self.assertTrue( stats1["oreads"][i] == 0 )
         self.assertTrue( stats2["oreads"][i] == 0 )