def test_filter_results(self): """ Tests filter results good for regression tests, need to do better verification... """ peak1 = Peak("chr15", 1, 10, "ENSG1", .04 , "-", 50, 60, 1, 52, .04, 32, 0) peak2 = Peak("chr15", 200, 300, "ENSG2", .06 , "-", 140, 160, 2, 239, .06, 45, 0) results = [{'loc': ['chr15', 'ENSG00000198901', 91509274, 91537804, '-'], 'Nclusters': 24, 'nreads': 2086, 'threshold': 32, 'clusters': [peak1, peak2]}] transcriptome_size = 10000 transcriptome_reads = 100000 result = filter_results(results, .07, transcriptome_size, transcriptome_reads, False, False, "foo") self.assertSetEqual(set(['chr15\t1\t10\tENSG1_1_52\t0.04\t-\t50\t60', 'chr15\t200\t300\tENSG2_2_239\t0.06\t-\t140\t160']), result) result = filter_results(results, .05, transcriptome_size, transcriptome_reads, False, False) self.assertSetEqual(set(['chr15\t1\t10\tENSG1_1_52\t0.04\t-\t50\t60']), result)
def test_broken_filter_results(self): """ Tests filter results, expects no output, even from transcriptome wide estimations """ peak1 = Peak("chr15", 1, 10, "ENSG1", .04, "-", 50, 60, 1, 52, .04, 32, 0) peak2 = Peak("chr15", 200, 300, "ENSG2", .06, "-", 140, 160, 2, 239, .06, 45, 0) results = [{ 'loc': ['chr15', 'ENSG00000198901', 91509274, 91537804, '-'], 'Nclusters': 24, 'nreads': 2086, 'threshold': 32, 'clusters': [peak1, peak2] }] transcriptome_size = 10000 transcriptome_reads = 100000 #I had my mental model of how the global cutoff was should have worked wrong the entire time... result = filter_results(results, .07, transcriptome_size, transcriptome_reads, True, False, "foo") self.assertSetEqual( set([ 'chr15\t1\t10\tENSG1_1_52\t0.04\t-\t50\t60', 'chr15\t200\t300\tENSG2_2_239\t0.06\t-\t140\t160' ]), result)
def test_bonferroni_correct_filter_results(self): """ Tests to make sure bonferroni correction works """ transcriptome_size = 10000 transcriptome_reads = 100000 peak1 = Peak("chr15", 1, 10, "ENSG1", .04, "-", 50, 60, 1, 52, .04, 32, 0) peak2 = Peak("chr15", 200, 300, "ENSG2", .06, "-", 140, 160, 2, 239, .06, 45, 0) results = [{ 'loc': ['chr15', 'ENSG00000198901', 91509274, 91537804, '-'], 'Nclusters': 24, 'nreads': 2086, 'threshold': 32, 'clusters': [peak1, peak2] }] result = filter_results(results, .09, transcriptome_size, transcriptome_reads, False, True) self.assertSetEqual(set(['chr15\t1\t10\tENSG1_1_52\t0.08\t-\t50\t60']), result)
def test_transcriptome_filter(self): """ Tests transcriptome filter not great tests, but good enough to make sure we don't have regressions """ cluster = Peak(0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 0, 0, 0, 0) #cluster = {'Nreads' : 5, "size" : 10} transcriptome_size = 1000 transcriptome_reads = 10000 poisson_cutoff = .05 result = transcriptome_filter(poisson_cutoff, transcriptome_size, transcriptome_reads, cluster) self.assertEqual(result, 1) #cluster = {'Nreads' : 10000, "size" : 100} cluster = Peak(0, 0, 0, 0, 0, 0, 0, 0, 0, 10000, 0, 100, 0, 0, 0, 0) transcriptome_size = 1000 transcriptome_reads = 10000 poisson_cutoff = .05 result = transcriptome_filter(poisson_cutoff, transcriptome_size, transcriptome_reads, cluster) self.assertEqual(result, 0.0) #cluster = {'Nreads' : 0, "size" : 0} cluster = Peak(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) transcriptome_size = 0 transcriptome_reads = 10000 poisson_cutoff = .05 result = transcriptome_filter(poisson_cutoff, transcriptome_size, transcriptome_reads, cluster) self.assertEqual(result, 1)