6
|
1 import unittest
|
|
2 from SMART.Java.Python.structure.Interval import Interval
|
|
3 from SMART.Java.Python.structure.SubMapping import SubMapping
|
|
4 from SMART.Java.Python.structure.Mapping import Mapping
|
|
5
|
|
6 class Test_Mapping(unittest.TestCase):
|
|
7
|
|
8 def test__getTranscript(self):
|
|
9 queryInterval1 = Interval()
|
|
10 queryInterval1.setName("read1_1")
|
|
11 queryInterval1.setStart(1)
|
|
12 queryInterval1.setEnd(10)
|
|
13 queryInterval1.setDirection(1)
|
|
14
|
|
15 targetInterval1 = Interval()
|
|
16 targetInterval1.setChromosome("chr1")
|
|
17 targetInterval1.setStart(100)
|
|
18 targetInterval1.setEnd(110)
|
|
19 targetInterval1.setDirection(1)
|
|
20
|
|
21 subMapping1 = SubMapping()
|
|
22 subMapping1.setQueryInterval(queryInterval1)
|
|
23 subMapping1.setTargetInterval(targetInterval1)
|
|
24
|
|
25 queryInterval2 = Interval()
|
|
26 queryInterval2.setName("read1_2")
|
|
27 queryInterval2.setStart(11)
|
|
28 queryInterval2.setEnd(20)
|
|
29 queryInterval2.setDirection(1)
|
|
30
|
|
31 targetInterval2 = Interval()
|
|
32 targetInterval2.setChromosome("chr1")
|
|
33 targetInterval2.setStart(200)
|
|
34 targetInterval2.setEnd(210)
|
|
35 targetInterval2.setDirection(1)
|
|
36
|
|
37 subMapping2 = SubMapping()
|
|
38 subMapping2.setQueryInterval(queryInterval2)
|
|
39 subMapping2.setTargetInterval(targetInterval2)
|
|
40
|
|
41 mapping = Mapping()
|
|
42 mapping.addSubMapping(subMapping1)
|
|
43 mapping.addSubMapping(subMapping2)
|
|
44
|
|
45 transcript = mapping.getTranscript()
|
|
46 self.assertEqual(transcript.getStart(), 100)
|
|
47 self.assertEqual(transcript.getEnd(), 210)
|
|
48 self.assertEqual(transcript.getChromosome(), "chr1")
|
|
49 exons = transcript.getExons()
|
|
50 self.assertEqual(len(exons), 2)
|
|
51 exon1, exon2 = exons
|
|
52 self.assertEqual(exon1.getStart(), 100)
|
|
53 self.assertEqual(exon1.getEnd(), 110)
|
|
54 self.assertEqual(exon2.getStart(), 200)
|
|
55 self.assertEqual(exon2.getEnd(), 210)
|
|
56
|
|
57
|
|
58 if __name__ == '__main__':
|
|
59 unittest.main()
|