annotate commons/tools/tests/Test_F_GameXmlMaker.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 import unittest
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 import os
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 import glob
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from commons.core.utils.FileUtils import FileUtils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 from commons.core.sql.DbFactory import DbFactory
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 from commons.tools.GameXmlMaker import GameXmlMaker
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 class Test_F_GameXmlMaker(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 FileUtils.removeFilesByPattern("*gamexml")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 def test_run_as_script_step1(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 fastaFileName = "input.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 self._writeFastaFile(fastaFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 cmd = "GameXmlMaker.py -f %s " % fastaFileName
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 lObsGameXmlNew = glob.glob("*.gamexml")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self._writeStep1ExpectedXmls()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 self.assertTrue(len(lObsGameXmlNew) > 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 for obsGameXmlNew in lObsGameXmlNew:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 expGameXmlNew = "exp_%s" % obsGameXmlNew
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 self.assertTrue(FileUtils.are2FilesIdentical(expGameXmlNew,obsGameXmlNew))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 os.remove(fastaFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 def test_run_as_script_step2(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 self._tableFileName = "annotation_tables.txt"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 self._writeStep2InputTableFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 self._writeStep2InputXmls()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 self._writeStep2InputPathFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 self._writeStep2InputSetFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 self._writeStep2InputMapFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 self._createStep2Tables()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 lObsGameXmlNew = glob.glob("*.gamexml")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 cmd = "GameXmlMaker.py -t %s " % self._tableFileName
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 self._writeStep2ExpXmls()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 self.assertTrue(len(lObsGameXmlNew) > 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 for obsGameXmlNew in lObsGameXmlNew:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 expGameXmlNew = "exp_%s" % obsGameXmlNew
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 self.assertTrue(FileUtils.are2FilesIdentical(expGameXmlNew,obsGameXmlNew))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 os.remove("Test_F_GameXmlMaker_path.path")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 os.remove("Test_F_GameXmlMaker_set.set")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 os.remove("Test_F_GameXmlMaker_chk_map.map")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 os.remove(self._tableFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 os.system("ListAndDropTables.py -d Test_F_GameXmlMaker")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 def test_run_step2(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 self._tableFileName = "annotation_tables.txt"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 self._writeStep2InputTableFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 self._writeStep2InputXmls()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 self._writeStep2InputPathFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 self._writeStep2InputSetFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 self._writeStep2InputMapFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 self._createStep2Tables()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 lObsGameXmlNew = glob.glob("*.gamexml")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 iGameXmlMaker = GameXmlMaker(tablesFileName = self._tableFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 iGameXmlMaker.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 self._writeStep2ExpXmls()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 self.assertTrue(len(lObsGameXmlNew) > 0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 for obsGameXmlNew in lObsGameXmlNew:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 expGameXmlNew = "exp_%s" % obsGameXmlNew
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82 self.assertTrue(FileUtils.are2FilesIdentical(expGameXmlNew,obsGameXmlNew))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 os.remove("Test_F_GameXmlMaker_path.path")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 os.remove("Test_F_GameXmlMaker_set.set")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
86 os.remove("Test_F_GameXmlMaker_chk_map.map")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
87
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
88 os.remove(self._tableFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
89 os.system("ListAndDropTables.py -d Test_F_GameXmlMaker")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
90
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
91 def _writeFastaFile(self, inFileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
92 f = open(inFileName,'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
93 f.write('>seq1\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
94 f.write('TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
95 f.write('CAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
96 f.write('CAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
97 f.write('>seq2\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
98 f.write('TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
99 f.write('CAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
100 f.write('CAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
101 f.write('>seq3\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
102 f.write('CCTAGACAATTAATTATAATAATTAATAAACTATTAGGCTAGTAGTAGGTAATAATAAAA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
103 f.write('GGATTACTACTAAGCTGCGCTATGTAGATATTTAAAACATGTGGCTTAGGCAAGAGTATA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
104 f.write('>seq4\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
105 f.write('TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
106 f.write('CAGGAATCATGAAGGGTACGACTGTTCG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
107 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
108
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
109 def _writeStep1ExpectedXmls(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
110 f = open("exp_seq1.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
111 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq1"><name>seq1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
112 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
113 f.write('</seq><map_position><arm>seq1</arm><span><start>1</start><end>165</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
114 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
115 f = open("exp_seq2.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
116 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq2"><name>seq2</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
117 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
118 f.write('</seq><map_position><arm>seq2</arm><span><start>1</start><end>180</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
119 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
120 f = open("exp_seq3.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
121 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq3"><name>seq3</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
122 f.write('<residues>CCTAGACAATTAATTATAATAATTAATAAACTATTAGGCTAGTAGTAGGTAATAATAAAAGGATTACTACTAAGCTGCGCTATGTAGATATTTAAAACATGTGGCTTAGGCAAGAGTATA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
123 f.write('</seq><map_position><arm>seq3</arm><span><start>1</start><end>120</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
124 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
125 f = open("exp_seq4.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
126 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq4"><name>seq4</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
127 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCG</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
128 f.write('</seq><map_position><arm>seq4</arm><span><start>1</start><end>88</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
129 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
130
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
131 def _createStep2Tables(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
132 iDb = DbFactory.createInstance()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
133 iDb.createTable("Test_F_GameXmlMaker_set", "set", "Test_F_GameXmlMaker_set.set", True)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
134 iDb.createTable("Test_F_GameXmlMaker_chk_map", "map", "Test_F_GameXmlMaker_chk_map.map", True)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
135 iDb.createTable("Test_F_GameXmlMaker_path", "path", "Test_F_GameXmlMaker_path.path", True)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
136 iDb.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
137
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
138 def _writeStep2InputXmls(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
139 f = open("seq1.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
140 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq1"><name>seq1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
141 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
142 f.write('</seq><map_position><arm>seq1</arm><span><start>1</start><end>165</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
143 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
144 f = open("seq2.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
145 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq2"><name>seq2</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
146 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
147 f.write('</seq><map_position><arm>seq2</arm><span><start>1</start><end>180</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
148 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
149 f = open("seq3.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
150 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq3"><name>seq3</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
151 f.write('<residues>CCTAGACAATTAATTATAATAATTAATAAACTATTAGGCTAGTAGTAGGTAATAATAAAAGGATTACTACTAAGCTGCGCTATGTAGATATTTAAAACATGTGGCTTAGGCAAGAGTATA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
152 f.write('</seq><map_position><arm>seq3</arm><span><start>1</start><end>120</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
153 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
154 f = open("seq4.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
155 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq4"><name>seq4</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
156 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCG</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
157 f.write('</seq><map_position><arm>seq4</arm><span><start>1</start><end>88</end></span></map_position></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
158 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
159
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
160 def _writeStep2InputPathFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
161 f = open("Test_F_GameXmlMaker_path.path", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
162 f.write("1\tseq1\t1\t10\tTE1\t1\t10\t0\t550\t80.7\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
163 f.write("2\tseq1\t15\t50\tTE1\t12\t47\t0\t770\t90.8\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
164 f.write("2\tseq1\t55\t70\tTE1\t50\t65\t0\t5410\t97.7\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
165 f.write("3\tseq1\t75\t80\tTE2\t10\t15\t0\t8710\t60.0\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
166 f.write("4\tseq2\t1\t10\tTE2\t20\t30\t0\t5410\t75.7\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
167 f.write("5\tseq3\t1\t120\tTE2\t450\t550\t0\t5410\t75.7\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
168 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
169
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
170 def _writeStep2InputSetFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
171 f = open("Test_F_GameXmlMaker_set.set", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
172 f.write("1\tseq1\tseq1\t1\t10\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
173 f.write("2\tseq1\tseq1\t15\t50\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
174 f.write("3\tseq1\tseq1\t75\t80\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
175 f.write("4\tseq2\tseq2\t1\t10\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
176 f.write("5\tseq3\tseq3\t1\t120\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
177 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
178
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
179 def _writeStep2InputMapFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
180 f = open("Test_F_GameXmlMaker_chk_map.map", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
181 f.write("chunk1\tseq1\t1\t200000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
182 f.write("chunk2\tseq1\t190001\t390000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
183 f.write("chunk3\tseq3\t380001\t580000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
184 f.write("chunk4\tseq4\t570001\t770000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
185 f.write("chunk5\tseq5\t760001\t960000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
186 f.write("chunk6\tseq6\t950001\t1150000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
187 f.write("chunk7\tseq7\t1140001\t1281640\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
188 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
189
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
190 def _writeStep2ExpXmls(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
191 f = open("exp_seq1.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
192 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq1"><name>seq1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
193 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
194 f.write('</seq><map_position><arm>seq1</arm><span><start>1</start><end>165</end></span></map_position>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
195 f.write('<computational_analysis><program>Test_F_GameXmlMaker_path</program><database>db</database><result_set id="1"><name>TE1::1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
196 f.write('<result_span><seq_relationship seq="seq1" type="query"><span><start>1</start><end>10</end></span></seq_relationship><seq_relationship seq="TE1::1" type="subject"><span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
197 f.write('<start>1</start><end>10</end></span></seq_relationship><score>80.7</score></result_span></result_set><result_set id="2"><name>TE1::2</name><result_span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
198 f.write('<seq_relationship seq="seq1" type="query"><span><start>15</start><end>50</end></span></seq_relationship><seq_relationship seq="TE1::2" type="subject"><span><start>12</start>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
199 f.write('<end>47</end></span></seq_relationship><score>90.8</score></result_span><result_span><seq_relationship seq="seq1" type="query"><span><start>55</start><end>70</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
200 f.write('<seq_relationship seq="TE1::2" type="subject"><span><start>50</start><end>65</end></span></seq_relationship><score>97.7</score></result_span></result_set><result_set id="3"><name>TE2::3</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
201 f.write('<result_span><seq_relationship seq="seq1" type="query"><span><start>75</start><end>80</end></span></seq_relationship><seq_relationship seq="TE2::3" type="subject"><span><start>10</start><end>15</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
202 f.write('<score>60.0</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
203 f.write('<computational_analysis><program>Test_F_GameXmlMaker_set</program><database>db</database>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
204 f.write('<result_set id="1"><name>seq1::1</name><result_span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
205 f.write('<seq_relationship seq="seq1" type="query"><span><start>1</start><end>10</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
206 f.write('<seq_relationship seq="seq1::1" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
207 f.write('<score>0</score></result_span></result_set>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
208 f.write('<result_set id="2"><name>seq1::2</name><result_span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
209 f.write('<seq_relationship seq="seq1" type="query"><span><start>15</start><end>50</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
210 f.write('<seq_relationship seq="seq1::2" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
211 f.write('<score>0</score></result_span></result_set>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
212 f.write('<result_set id="3"><name>seq1::3</name><result_span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
213 f.write('<seq_relationship seq="seq1" type="query"><span><start>75</start><end>80</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
214 f.write('<seq_relationship seq="seq1::3" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
215 f.write('<score>0</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
216 f.write('<computational_analysis><program>Test_F_GameXmlMaker_chk_map</program><database>db</database>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
217 f.write('<result_set id="-1"><name>chunk1::-1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
218 f.write('<result_span><seq_relationship seq="seq1" type="query"><span><start>1</start><end>200000</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
219 f.write('<seq_relationship seq="chunk1::-1" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
220 f.write('<score>0</score></result_span></result_set>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
221 f.write('<result_set id="-1"><name>chunk2::-1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
222 f.write('<result_span><seq_relationship seq="seq1" type="query"><span><start>190001</start><end>390000</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
223 f.write('<seq_relationship seq="chunk2::-1" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship><score>0</score></result_span></result_set></computational_analysis></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
224 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
225
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
226 f = open("exp_seq2.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
227 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq2"><name>seq2</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
228 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAATCAGGAATCATGAAGGGTACGACTGTTCGTCGATTAAAGAGCTACACGAGCTGGGTTAAAT</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
229 f.write('</seq><map_position><arm>seq2</arm><span><start>1</start><end>180</end></span></map_position>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
230 f.write('<computational_analysis><program>Test_F_GameXmlMaker_path</program><database>db</database><result_set id="4"><name>TE2::4</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
231 f.write('<result_span><seq_relationship seq="seq2" type="query"><span><start>1</start><end>10</end></span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
232 f.write('</seq_relationship><seq_relationship seq="TE2::4" type="subject"><span><start>20</start><end>30</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
233 f.write('<score>75.7</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
234 f.write('<computational_analysis><program>Test_F_GameXmlMaker_set</program><database>db</database><result_set id="4"><name>seq2::4</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
235 f.write('<result_span><seq_relationship seq="seq2" type="query"><span><start>1</start><end>10</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
236 f.write('<seq_relationship seq="seq2::4" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
237 f.write('<score>0</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
238 f.write('<computational_analysis><program>Test_F_GameXmlMaker_chk_map</program><database>db</database></computational_analysis></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
239 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
240
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
241 f = open("exp_seq3.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
242 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq3"><name>seq3</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
243 f.write('<residues>CCTAGACAATTAATTATAATAATTAATAAACTATTAGGCTAGTAGTAGGTAATAATAAAAGGATTACTACTAAGCTGCGCTATGTAGATATTTAAAACATGTGGCTTAGGCAAGAGTATA</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
244 f.write('</seq><map_position><arm>seq3</arm><span><start>1</start><end>120</end></span></map_position>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
245 f.write('<computational_analysis><program>Test_F_GameXmlMaker_path</program><database>db</database><result_set id="5"><name>TE2::5</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
246 f.write('<result_span><seq_relationship seq="seq3" type="query"><span><start>1</start><end>120</end></span>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
247 f.write('</seq_relationship><seq_relationship seq="TE2::5" type="subject"><span><start>450</start><end>550</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
248 f.write('<score>75.7</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
249 f.write('<computational_analysis><program>Test_F_GameXmlMaker_set</program><database>db</database><result_set id="5"><name>seq3::5</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
250 f.write('<result_span><seq_relationship seq="seq3" type="query"><span><start>1</start><end>120</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
251 f.write('<seq_relationship seq="seq3::5" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
252 f.write('<score>0</score></result_span></result_set></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
253 f.write('<computational_analysis><program>Test_F_GameXmlMaker_chk_map</program><database>db</database>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
254 f.write('<result_set id="-1"><name>chunk3::-1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
255 f.write('<result_span><seq_relationship seq="seq3" type="query"><span><start>380001</start><end>580000</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
256 f.write('<seq_relationship seq="chunk3::-1" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
257 f.write('<score>0</score></result_span></result_set></computational_analysis></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
258 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
259
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
260 f = open("exp_seq4.gamexml", 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
261 f.write('<?xml version="1.0" ?><game><seq focus="true" id="seq4"><name>seq4</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
262 f.write('<residues>TGTTCATATTCATAGGATGGAGCTAGTAAGCGATGTCGGCTTAGCTCATCCACATGAATGCAGGAATCATGAAGGGTACGACTGTTCG</residues>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
263 f.write('</seq><map_position><arm>seq4</arm><span><start>1</start><end>88</end></span></map_position>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
264 f.write('<computational_analysis><program>Test_F_GameXmlMaker_path</program><database>db</database></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
265 f.write('<computational_analysis><program>Test_F_GameXmlMaker_set</program><database>db</database></computational_analysis>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
266 f.write('<computational_analysis><program>Test_F_GameXmlMaker_chk_map</program><database>db</database>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
267 f.write('<result_set id="-1"><name>chunk4::-1</name>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
268 f.write('<result_span><seq_relationship seq="seq4" type="query"><span><start>570001</start><end>770000</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
269 f.write('<seq_relationship seq="chunk4::-1" type="subject"><span><start>-1</start><end>-1</end></span></seq_relationship>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
270 f.write('<score>0</score></result_span></result_set></computational_analysis></game>')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
271 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
272
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
273 def _writeStep2InputTableFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
274 f = open(self._tableFileName,'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
275 f.write("Test_F_GameXmlMaker_path\tpath\tTest_F_GameXmlMaker_path\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
276 f.write("Test_F_GameXmlMaker_set\tset\tTest_F_GameXmlMaker_set\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
277 f.write("Test_F_GameXmlMaker_chk_map\tmap\tTest_F_GameXmlMaker_chk_map")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
278 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
279
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
280 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
281 unittest.main()