def test_genes_within_iterable(testRefGen): random_gene = testRefGen.random_gene() bigger_locus = Locus(random_gene.chrom, start=random_gene.start - 100, end=random_gene.end + 100) genes = testRefGen.genes_within([bigger_locus, bigger_locus], chain=True) assert random_gene in genes
def test_genes_within(testRefGen): random_gene = testRefGen.random_gene() bigger_locus = Locus(random_gene.chrom, start=random_gene.start - 100, end=random_gene.end + 100) genes = testRefGen.genes_within(bigger_locus) assert random_gene in genes
def testTerm(): loci = [ # Overlapping Loci, No windows Locus(1, 100, 500, score=0), Locus(1, 400, 700, score=5), # Loci with Overlapping windows Locus(2, 100, 200, window=100, score=0), Locus(2, 300, 500, window=100, score=5), # SNPs with overlapping windows Locus(3, 100, window=50, score=5), Locus(3, 200, window=50, score=0), # Three overlapping loci, one not Locus(4, 100, window=80, score=1), Locus(4, 200, window=80, score=2), Locus(4, 300, window=80, score=3), Locus(4, 400, window=10, score=4) # <- one not ] return Term('test', desc='hello', loci=loci, attr1=True, attr2=False)
def test_flank_limit_for_candidate_genes_from_SNP(testRefGen): random_gene = testRefGen.random_gene() downstream = testRefGen.downstream_genes( random_gene,gene_limit=10,window_size=50e6 ) test_snp = Locus(downstream[5].chrom,downstream[5].start,window=50e6) # Create a Locus that is on gene 5 candidates = testRefGen.candidate_genes( test_snp,flank_limit=5,window_size=50e6 ) assert len(candidates) == 11
def test_candidate_genes_from_SNP(testRefGen): random_gene = testRefGen.random_gene() # grab a bunch of downstream genes down1,down2 = testRefGen.downstream_genes( random_gene,gene_limit=2,window_size=50e6 ) # Create a Locus that is on gene 5 test_snp = Locus( down1.chrom, down1.start-50, end=down2.end+50, window=50e6 ) candidates = testRefGen.candidate_genes( test_snp,flank_limit=5,chain=False ) assert len(candidates) == 12
def test_candidate_genes_from_SNP(testRefGen): random_gene = testRefGen.random_gene() # grab a bunch of downstream genes down1,down2 = testRefGen.downstream_genes( random_gene,gene_limit=2,window_size=50e6 ) # Create a Locus that is on gene 5 test_snp = Locus( down1.chrom, down1.start-50, end=down2.end+50, window=50e6 ) candidates = testRefGen.candidate_genes( test_snp,flank_limit=5,chain=False, include_rank_intervening=True, include_parent_locus=True, include_parent_attrs='all', include_num_intervening=True, include_num_siblings=True, include_SNP_distance=True ) assert len(candidates) == 12
def test_add_Locus(testTerm): new_locus = Locus(6, 100) testTerm.add_locus(new_locus) assert new_locus in testTerm.loci testTerm.loci.remove(new_locus)
def test_flanking_genes_includes_within_genes_for_SNPS(testRefGen): random_gene = testRefGen.random_gene() # test snp test_snp = Locus(random_gene.chrom,random_gene.start,window=50e5) flanking = testRefGen.flanking_genes(test_snp) assert random_gene not in flanking
def test_bootstrap_candidate_length_equal_from_SNP(testRefGen): random_gene = testRefGen.random_gene() test_snp = Locus(random_gene.chrom,random_gene.start,window=50e6) candidates = testRefGen.candidate_genes(test_snp) bootstraps = testRefGen.bootstrap_candidate_genes(test_snp) assert len(candidates) == len(bootstraps)
def LocusX(): return Locus(1, 100, 200)
def test_encompassing_genes(testRefGen): rg = testRefGen.random_gene() middle = int((rg.start+rg.end)/2) assert rg in testRefGen.encompassing_genes(Locus(rg.chrom,middle))
def LocusY(): return Locus(1, 300, 400)
def test_flanking_loci(testTerm): assert len(testTerm.flanking_loci(Locus(4, 250), window_size=100)) == 2 assert len(testTerm.flanking_loci(Locus(4, 250), window_size=400)) == 4
def test_distance_between_loci(): x = Locus(1, 100, 200) y = Locus(1, 300, 400) assert x - y == 99
def test_init(): x = Term('testTerm', desc='for testing', loci=[Locus(1, 2), Locus(1, 3)], foo='bar')
def test_init(): x = Term("testTerm", desc="for testing", loci=[Locus(1, 2), Locus(1, 3)], foo="bar")
def simple_Locus(): return Locus(1, 100, 200)