annotate SMART/Java/Python/structure/test/Test_Mapping.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents 769e306b7933
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
1 import unittest
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
2 from SMART.Java.Python.structure.Interval import Interval
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
3 from SMART.Java.Python.structure.SubMapping import SubMapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
4 from SMART.Java.Python.structure.Mapping import Mapping
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
5
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
6 class Test_Mapping(unittest.TestCase):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
7
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
8 def test__getTranscript(self):
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
9 queryInterval1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
10 queryInterval1.setName("read1_1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
11 queryInterval1.setStart(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
12 queryInterval1.setEnd(10)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
13 queryInterval1.setDirection(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
14
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
15 targetInterval1 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
16 targetInterval1.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
17 targetInterval1.setStart(100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
18 targetInterval1.setEnd(110)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
19 targetInterval1.setDirection(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
20
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
21 subMapping1 = SubMapping()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
22 subMapping1.setQueryInterval(queryInterval1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
23 subMapping1.setTargetInterval(targetInterval1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
24
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
25 queryInterval2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
26 queryInterval2.setName("read1_2")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
27 queryInterval2.setStart(11)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
28 queryInterval2.setEnd(20)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
29 queryInterval2.setDirection(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
30
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
31 targetInterval2 = Interval()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
32 targetInterval2.setChromosome("chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
33 targetInterval2.setStart(200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
34 targetInterval2.setEnd(210)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
35 targetInterval2.setDirection(1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
36
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
37 subMapping2 = SubMapping()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
38 subMapping2.setQueryInterval(queryInterval2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
39 subMapping2.setTargetInterval(targetInterval2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
40
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
41 mapping = Mapping()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
42 mapping.addSubMapping(subMapping1)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
43 mapping.addSubMapping(subMapping2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
44
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
45 transcript = mapping.getTranscript()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
46 self.assertEqual(transcript.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
47 self.assertEqual(transcript.getEnd(), 210)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
48 self.assertEqual(transcript.getChromosome(), "chr1")
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
49 exons = transcript.getExons()
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
50 self.assertEqual(len(exons), 2)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
51 exon1, exon2 = exons
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
52 self.assertEqual(exon1.getStart(), 100)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
53 self.assertEqual(exon1.getEnd(), 110)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
54 self.assertEqual(exon2.getStart(), 200)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
55 self.assertEqual(exon2.getEnd(), 210)
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
56
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
57
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
58 if __name__ == '__main__':
769e306b7933 Change the repository level.
yufei-luo
parents:
diff changeset
59 unittest.main()