Mercurial > repos > yufei-luo > s_mart
comparison commons/core/writer/test/Test_MapWriter.py @ 6:769e306b7933
Change the repository level.
author | yufei-luo |
---|---|
date | Fri, 18 Jan 2013 04:54:14 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:ea3082881bf8 | 6:769e306b7933 |
---|---|
1 from SMART.Java.Python.structure.Transcript import Transcript | |
2 from SMART.Java.Python.structure.Interval import Interval | |
3 import unittest | |
4 import os | |
5 from SMART.Java.Python.misc import Utils | |
6 from commons.core.writer.MapWriter import MapWriter | |
7 from commons.core.utils.FileUtils import FileUtils | |
8 | |
9 class Test_MapWriter(unittest.TestCase): | |
10 | |
11 def setUp(self): | |
12 self.expFileName = "expMapWriter.map" | |
13 self.obsFileName = "testMapWriter1.map" | |
14 | |
15 def tearDown(self): | |
16 os.remove(self.expFileName) | |
17 os.remove(self.obsFileName) | |
18 | |
19 def test_writer(self): | |
20 self.write_ExpMapFileName() | |
21 writer = MapWriter(self.obsFileName) | |
22 | |
23 transcript = Transcript() | |
24 transcript.setName("test1.1") | |
25 transcript.setChromosome("arm_X") | |
26 transcript.setStart(1000) | |
27 transcript.setEnd(4000) | |
28 transcript.setDirection("+") | |
29 transcript.setTagValue("ID", "test1.1-1") | |
30 transcript.setTagValue("occurrence", 1) | |
31 transcript.setTagValue("nbOccurrences", 2) | |
32 | |
33 exon1 = Interval() | |
34 exon1.setChromosome("arm_X") | |
35 exon1.setStart(1000) | |
36 exon1.setEnd(2000) | |
37 exon1.setDirection("+") | |
38 | |
39 exon2 = Interval() | |
40 exon2.setChromosome("arm_X") | |
41 exon2.setStart(3000) | |
42 exon2.setEnd(4000) | |
43 exon2.setDirection("+") | |
44 | |
45 transcript.addExon(exon1) | |
46 transcript.addExon(exon2) | |
47 | |
48 writer.addTranscript(transcript) | |
49 writer.write() | |
50 writer.close() | |
51 | |
52 self.assertTrue(FileUtils.are2FilesIdentical(self.expFileName, self.obsFileName)) | |
53 | |
54 | |
55 def write_ExpMapFileName(self): | |
56 f = open(self.expFileName, "w") | |
57 f.write("test1.1\tarm_X\t1000\t4001\n") | |
58 f.close() | |
59 | |
60 if __name__ == '__main__': | |
61 unittest.main() |