1+ from test_common import test_ensembl_releases
2+ from pyensembl import EnsemblRelease , find_nearest_locus
3+ from nose .tools import eq_
4+
5+ @test_ensembl_releases
6+ def test_find_nearest_BRAF_exon (ensembl ):
7+ braf = ensembl .genes_by_name ("BRAF" )[0 ]
8+ braf_transcripts = braf .transcripts
9+ for exon in braf_transcripts [0 ].exons :
10+ # immediately before exon
11+ result = find_nearest_locus (
12+ start = exon .start - 2 ,
13+ end = exon .end - 1 ,
14+ loci = exons )
15+ eq_ (result , (1 , exon ))
16+
17+ # overlapping with exon
18+ result = find_nearest_locus (
19+ start = exon .start - 2 ,
20+ end = exon .start + 1 ,
21+ loci = exons )
22+ eq_ (result , (0 , exon ))
23+
24+ # immediately after exon
25+ result = find_nearest_locus (
26+ start = exon .end + 1 ,
27+ end = exon .end + 2 ,
28+ loci = exons )
29+ eq_ (result , (1 , exon ))
30+
31+ @test_ensembl_releases
32+ def test_find_nearest_BRAF_transcript (ensembl ):
33+ braf = ensembl .genes_by_name ("BRAF" )[0 ]
34+ braf_transcripts = braf .transcripts
35+ for transcript in braf_transcripts :
36+ # immediately before transcript
37+ result = find_nearest_locus (
38+ start = transcript .start - 2 ,
39+ end = transcript .end - 1 ,
40+ loci = braf_transcripts )
41+ eq_ (result , (1 , transcript ))
42+
43+ # overlapping with transcript
44+ result = find_nearest_locus (
45+ start = transcript .start - 2 ,
46+ end = transcript .start + 1 ,
47+ exons = braf_transcripts )
48+ eq_ (result , (0 , transcript ))
49+
50+ # immediately after transcript
51+ result = find_nearest_locus (
52+ start = transcript .end + 1 ,
53+ end = transcript .end + 2 ,
54+ exons = braf_transcripts )
55+ eq_ (result , (1 , transcript ))
0 commit comments