def test_set_type_of_5_prime_tss(self): self.tss_gene_mapper.genes_and_5_prime_tss = {} self.tss_gene_mapper.tss_and_hit_genes = {} tss_primary = TSS("genomeX", 40, "+") tss_secondary = TSS("genomeX", 30, "+") gene = Gene("genomeX", "g", "g", 50, 100, "+") self.tss_gene_mapper.genes_and_5_prime_tss[gene] = [[10, tss_primary], [ 20, tss_secondary ]] self.tss_gene_mapper.tss_and_hit_genes[tss_primary] = {} self.tss_gene_mapper.tss_and_hit_genes[tss_secondary] = {} self.tss_gene_mapper.tss_and_hit_genes[tss_primary][gene] = { "location": tssgenemapper.loc_5_prime_str, "orientation": tssgenemapper.sense_str, "distance": 10, "tss_type": None } self.tss_gene_mapper.tss_and_hit_genes[tss_secondary][gene] = { "location": tssgenemapper.loc_5_prime_str, "orientation": tssgenemapper.sense_str, "distance": 20, "tss_type": None } self.tss_gene_mapper._set_type_of_5_prime_tss() self.assertEqual( self.tss_gene_mapper.tss_and_hit_genes[tss_primary][gene] ["tss_type"], tssgenemapper.primary_str) self.assertEqual( self.tss_gene_mapper.tss_and_hit_genes[tss_secondary][gene] ["tss_type"], tssgenemapper.secondary_str)
def create_tss_list(self): self.tss_list = [] for row in csv.reader(self.tss_list_fh, delimiter="\t"): seq_id = None if len(row) == 3: seq_id == row[2] try: self.tss_list.append(TSS(seq_id, row[0], row[1])) except: sys.stderr.write("Skipping TSS table line: \"%s\"\n" % ("\t".join(row)))
def test_has_5_prime_association_9(self): """True - In 5' region""" tss = TSS("genomeX", 105, "-") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual( self.tss_gene_mapper._has_5_prime_association(tss, gene), True)
def test_has_5_prime_association_8(self): """None - antisense""" tss = TSS("genomeX", 600, "+") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual( self.tss_gene_mapper._has_5_prime_association(tss, gene), None)
def test_has_5_prime_association_4(self): """None - in 5' but too far away """ tss = TSS("genomeX", 10, "+") gene = Gene("genomeX", "g", "g", 1000, 1100, "+") self.assertEqual( self.tss_gene_mapper._has_5_prime_association(tss, gene), None)
def test_has_5_prime_association_3(self): """True - Leaderless TSS""" tss = TSS("genomeX", 10, "+") gene = Gene("genomeX", "g", "g", 10, 100, "+") self.assertEqual( self.tss_gene_mapper._has_5_prime_association(tss, gene), True)
def test_5_prime_dist_4(self): tss = TSS("genomeX", 120, "-") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual(self.tss_gene_mapper._5_prime_dist(tss, gene), 20)
def test_init_without_extra(self): tss = TSS("plasmidX", "20", "-") self.assertEqual(tss.seq_id, "plasmidX") self.assertEqual(tss.pos, 20) self.assertEqual(tss.strand, "-") self.assertFalse(hasattr(tss, "extra"))
def test_has_internal_association_7(self): """True - on the last base """ tss = TSS("genomeX", 10, "-") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual( self.tss_gene_mapper._has_internal_association(tss, gene), True)
def test_has_internal_association_3(self): """None - 3' region """ tss = TSS("genomeX", 150, "+") gene = Gene("genomeX", "g", "g", 10, 100, "+") self.assertEqual( self.tss_gene_mapper._has_internal_association(tss, gene), None)
def test_has_internal_association_1(self): """True - internal""" tss = TSS("genomeX", 20, "+") gene = Gene("genomeX", "g", "g", 10, 100, "+") self.assertEqual( self.tss_gene_mapper._has_internal_association(tss, gene), True)
def test_has_antisense_association_10(self): """None - out of range""" tss = TSS("genomeX", 201, "-") gene = Gene("genomeX", "g", "g", 10, 100, "+") self.assertEqual( self.tss_gene_mapper._has_antisense_association(tss, gene), None)
def test_has_antisense_association_8(self): """True - antisense""" tss = TSS("genomeX", 200, "-") gene = Gene("genomeX", "g", "g", 10, 100, "+") self.assertEqual( self.tss_gene_mapper._has_antisense_association(tss, gene), True)
def test_has_antisense_association_7(self): """True - antisense and inside the range""" tss = TSS("genomeX", 900, "-") gene = Gene("genomeX", "g", "g", 1000, 1100, "+") self.assertEqual( self.tss_gene_mapper._has_antisense_association(tss, gene), True)
def test_has_5_prime_association_10(self): """None - in 3' region""" tss = TSS("genomeX", 5, "-") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual( self.tss_gene_mapper._has_5_prime_association(tss, gene), None)
def test_has_internal_association_8(self): """None - on the first base => 5' leaderless """ tss = TSS("genomeX", 100, "-") gene = Gene("genomeX", "g", "g", 10, 100, "-") self.assertEqual( self.tss_gene_mapper._has_internal_association(tss, gene), None)
def test_init_with_extra(self): tss = TSS("plasmidY", "30", "+", extra="weak") self.assertEqual(tss.seq_id, "plasmidY") self.assertEqual(tss.pos, 30) self.assertEqual(tss.strand, "+") self.assertEqual(tss.extra, "weak")