Mercurial > repos > yufei-luo > s_mart
comparison commons/core/checker/test/Test_ConfigChecker.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 commons.core.checker.ConfigChecker import ConfigChecker | |
2 from commons.core.checker.ConfigChecker import ConfigRules | |
3 from commons.core.checker.RepetException import RepetException | |
4 import os | |
5 import unittest | |
6 | |
7 class Test_ConfigChecker(unittest.TestCase): | |
8 | |
9 def setUp(self): | |
10 self._configFileName = "testConfigChecker.cfg" | |
11 self._iMock = MockConfig() | |
12 | |
13 def test_checkIfExistsConfigFile_file_exist(self): | |
14 f=open(self._configFileName, "w") | |
15 f.close() | |
16 | |
17 doesFileExists = True | |
18 iConfigRules = ConfigRules() | |
19 try: | |
20 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
21 iConfigChecker.checkIfExistsConfigFile() | |
22 except RepetException: | |
23 doesFileExists = False | |
24 os.remove(self._configFileName) | |
25 self.assertTrue(doesFileExists) | |
26 | |
27 def test_checkIfExistsConfigFile_file_not_exist(self): | |
28 iConfigRules = ConfigRules() | |
29 expMsg ="CONFIG FILE not found - '%s'" %self._configFileName | |
30 doesFileExists = True | |
31 try: | |
32 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
33 iConfigChecker.checkIfExistsConfigFile() | |
34 except RepetException, re: | |
35 doesFileExists = False | |
36 self.assertFalse(doesFileExists) | |
37 self.assertEqual(expMsg, re.getMessage()) | |
38 | |
39 def test_readConfigFile(self): | |
40 self._iMock.write_config(self._configFileName) | |
41 iConfigRules = ConfigRules() | |
42 expDictRawConfigValues = {"dir_name" : {"work_dir":"toto"}, | |
43 "organism" : {"abbreviation":"T.aestivum", | |
44 "genus":"triticum", | |
45 "species":"aestivum", | |
46 "common_name":"wheat", | |
47 "comment":""}, | |
48 'analysis1': {'description': '', | |
49 'gff_name': 'BLASTX.gff2', | |
50 'name': 'BLASTXWheat2', | |
51 'program': 'BLASTX2', | |
52 'programversion': '3.32', | |
53 'sourcename': 'dummyDesc_BLASTX2'} | |
54 } | |
55 isNoExceptionRaised = True | |
56 try: | |
57 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
58 iConfig = iConfigChecker.readConfigFile() | |
59 iConfigChecker.setRawConfig(iConfig) | |
60 obsDictRawConfigValues = iConfigChecker._iRawConfig.dOptionsValues4Sections | |
61 except RepetException: | |
62 isNoExceptionRaised = False | |
63 os.remove(self._configFileName) | |
64 self.assertTrue(isNoExceptionRaised) | |
65 self.assertEquals(obsDictRawConfigValues, expDictRawConfigValues) | |
66 | |
67 def test_readConfigFile_section_define_twice(self): | |
68 self._iMock.write_case_section_define_twice(self._configFileName) | |
69 iConfigRules = ConfigRules() | |
70 expMsg = "Duplicate section exist in config file %s" %self._configFileName | |
71 expDictRawConfigValues = {"dir_name": {"work_dir":"toto"}, | |
72 "analysis1" : {"name": "BLASTXWheat2", | |
73 "program" : "BLASTX2", | |
74 "programversion" : "3.32", | |
75 "sourcename" :"dummyDesc_BLASTX2", | |
76 "description" : "", | |
77 "gff_name" :"BLASTX.gff2"} | |
78 } | |
79 doesNoExceptionRaised = True | |
80 try: | |
81 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
82 iConfig = iConfigChecker.readConfigFile() | |
83 iConfigChecker.setRawConfig(iConfig) | |
84 obsDictRawConfigValues = iConfigChecker._iRawConfig.dOptionsValues4Sections | |
85 except RepetException, re: | |
86 doesNoExceptionRaised = False | |
87 os.remove(self._configFileName) | |
88 # self.assertFalse(doesNoExceptionRaised) | |
89 # self.assertEqual(expMsg, re.getMessage()) | |
90 # | |
91 self.assertTrue(doesNoExceptionRaised) | |
92 self.assertEquals(obsDictRawConfigValues, expDictRawConfigValues) | |
93 | |
94 def test_readConfigFile_option_define_twice(self): | |
95 self._iMock.write_case_option_define_twice(self._configFileName) | |
96 iConfigRules = ConfigRules() | |
97 doesNoExceptionRaised = True | |
98 expDictRawConfigValues = {"dir_name": {"work_dir":"toto"}, | |
99 "analysis1" : {"name": "BLASTXWheat", | |
100 "program" : "BLASTX2", | |
101 "programversion" : "3.3", | |
102 "sourcename" :"dummyDesc_BLASTX", | |
103 "description" : "", | |
104 "gff_name" :"BLASTX.gff"} | |
105 } | |
106 try: | |
107 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
108 iConfig = iConfigChecker.readConfigFile() | |
109 iConfigChecker.setRawConfig(iConfig) | |
110 obsDictRawConfigValues = iConfigChecker._iRawConfig.dOptionsValues4Sections | |
111 except RepetException, re: | |
112 doesNoExceptionRaised = False | |
113 os.remove(self._configFileName) | |
114 ## self.assertFalse(doesNoExceptionRaised) | |
115 ## self.assertEqual(expMsg, re.getMessage()) | |
116 | |
117 self.assertTrue(doesNoExceptionRaised) | |
118 self.assertEquals(obsDictRawConfigValues, expDictRawConfigValues) | |
119 | |
120 def test_checkMandatorySections(self): | |
121 self._iMock.write_config(self._configFileName) | |
122 iConfigRules = ConfigRules() | |
123 iConfigRules.addRuleSection(section="dir_name", mandatory=True) | |
124 iConfigRules.addRuleSection(section="organism", mandatory=True) | |
125 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
126 iConfig = iConfigChecker.readConfigFile() | |
127 iConfigChecker.setRawConfig(iConfig) | |
128 iConfigChecker.extendConfigRulesWithPatternRules() | |
129 areAllMandatorySectionsFound = True | |
130 try: | |
131 iConfigChecker.checkMandatorySections() | |
132 except RepetException: | |
133 areAllMandatorySectionsFound = False | |
134 os.remove(self._configFileName) | |
135 self.assertTrue(areAllMandatorySectionsFound) | |
136 | |
137 def test_checkMandatorySections_one_missing (self): | |
138 self._iMock.write_config(self._configFileName) | |
139 iConfigRules = ConfigRules() | |
140 iConfigRules.addRuleSection(section="dir_name", mandatory=True) | |
141 iConfigRules.addRuleSection(section="target", mandatory=True) | |
142 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
143 iConfig = iConfigChecker.readConfigFile() | |
144 iConfigChecker.setRawConfig(iConfig) | |
145 iConfigChecker.extendConfigRulesWithPatternRules() | |
146 expMsg = "Error in configuration file %s, following sections are missing:\n - target\n"% self._configFileName | |
147 areAllMandatorySectionsFound = True | |
148 try: | |
149 iConfigChecker.checkMandatorySections() | |
150 except RepetException, re: | |
151 areAllMandatorySectionsFound = False | |
152 os.remove(self._configFileName) | |
153 self.assertFalse(areAllMandatorySectionsFound) | |
154 self.assertEquals(expMsg, re.getMessage()) | |
155 | |
156 def test_checkMandatorySections_mandatory_section_with_pattern_section_is_missing (self): | |
157 self._iMock.write_config(self._configFileName) | |
158 iConfigRules = ConfigRules() | |
159 iConfigRules.addRuleSection(section="dir_name", mandatory=True) | |
160 iConfigRules.addRuleSection(section="mandatorySection", mandatory=True, isPattern = True) | |
161 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
162 iConfig = iConfigChecker.readConfigFile() | |
163 iConfigChecker.setRawConfig(iConfig) | |
164 iConfigChecker.extendConfigRulesWithPatternRules() | |
165 expMsg = "Error in configuration file %s, following sections are missing:\n - mandatorySection\n"% self._configFileName | |
166 areAllMandatorySectionsFound = True | |
167 try: | |
168 iConfigChecker.checkMandatorySections() | |
169 except RepetException, re: | |
170 areAllMandatorySectionsFound = False | |
171 os.remove(self._configFileName) | |
172 self.assertFalse(areAllMandatorySectionsFound) | |
173 self.assertEquals(expMsg, re.getMessage()) | |
174 | |
175 def test_checkMandatorySections_mandatory_section_is_pattern (self): | |
176 self._iMock.write_case_pattern_rule(self._configFileName) | |
177 iConfigRules = ConfigRules() | |
178 iConfigRules.addRuleSection(section="dir_name", mandatory=True) | |
179 iConfigRules.addRuleSection(section="analysis[0-9]*", mandatory=True, isPattern = True) | |
180 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
181 iConfig = iConfigChecker.readConfigFile() | |
182 iConfigChecker.setRawConfig(iConfig) | |
183 iConfigChecker.extendConfigRulesWithPatternRules() | |
184 areAllMandatorySectionsFound = True | |
185 try: | |
186 iConfigChecker.checkMandatorySections() | |
187 except RepetException: | |
188 areAllMandatorySectionsFound = False | |
189 os.remove(self._configFileName) | |
190 self.assertTrue(areAllMandatorySectionsFound) | |
191 | |
192 def test_checkMandatoryOptions_in_mandatory_section (self): | |
193 self._iMock.write_config(self._configFileName) | |
194 iConfigRules = ConfigRules() | |
195 iConfigRules.addRuleSection(section="organism", mandatory=True) | |
196 iConfigRules.addRuleOption(section="organism", option ="genus", mandatory=True) | |
197 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
198 iConfig = iConfigChecker.readConfigFile() | |
199 iConfigChecker.setRawConfig(iConfig) | |
200 iConfigChecker.extendConfigRulesWithPatternRules() | |
201 areAllMandatoryOptionsFound = True | |
202 try: | |
203 iConfigChecker.checkMandatoryOptions() | |
204 except RepetException: | |
205 areAllMandatoryOptionsFound = False | |
206 os.remove(self._configFileName) | |
207 self.assertTrue(areAllMandatoryOptionsFound) | |
208 | |
209 def test_checkMandatoryOptions_in_mandatory_section_option_is_missing (self): | |
210 self._iMock.write_config(self._configFileName) | |
211 iConfigRules = ConfigRules() | |
212 iConfigRules.addRuleSection(section="organism", mandatory=True) | |
213 iConfigRules.addRuleOption(section="organism", option ="MissingOption", mandatory=True) | |
214 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
215 iConfig = iConfigChecker.readConfigFile() | |
216 iConfigChecker.setRawConfig(iConfig) | |
217 iConfigChecker.extendConfigRulesWithPatternRules() | |
218 expMsg = "Error in configuration file %s, following options are missing: \n - [organism]: MissingOption\n" % self._configFileName | |
219 areAllMandatoryOptionsFound = True | |
220 try: | |
221 iConfigChecker.checkMandatoryOptions() | |
222 except RepetException, re: | |
223 areAllMandatoryOptionsFound = False | |
224 os.remove(self._configFileName) | |
225 self.assertFalse(areAllMandatoryOptionsFound) | |
226 self.assertEquals(expMsg, re.getMessage()) | |
227 | |
228 def test_checkMandatoryOptions_in_non_mandatory_section_and_section_and_option_exist (self): | |
229 self._iMock.write_config(self._configFileName) | |
230 iConfigRules = ConfigRules() | |
231 iConfigRules.addRuleOption(section="organism", option ="genus", mandatory=True) | |
232 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
233 iConfig = iConfigChecker.readConfigFile() | |
234 iConfigChecker.setRawConfig(iConfig) | |
235 iConfigChecker.extendConfigRulesWithPatternRules() | |
236 areAllMandatoryOptionsFound = True | |
237 try: | |
238 iConfigChecker.checkMandatoryOptions() | |
239 except RepetException: | |
240 areAllMandatoryOptionsFound = False | |
241 os.remove(self._configFileName) | |
242 self.assertTrue(areAllMandatoryOptionsFound) | |
243 | |
244 def test_checkMandatoryOptions_in_non_mandatory_section_and_section_exist_option_is_missing (self): | |
245 self._iMock.write_config(self._configFileName) | |
246 iConfigRules = ConfigRules() | |
247 iConfigRules.addRuleOption(section="organism", option ="MissingOption", mandatory=True) | |
248 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
249 iConfig = iConfigChecker.readConfigFile() | |
250 iConfigChecker.setRawConfig(iConfig) | |
251 iConfigChecker.extendConfigRulesWithPatternRules() | |
252 expMsg = "Error in configuration file %s, following options are missing: \n - [organism]: MissingOption\n" % self._configFileName | |
253 areAllMandatoryOptionsFound = True | |
254 try: | |
255 iConfigChecker.checkMandatoryOptions() | |
256 except RepetException, re: | |
257 areAllMandatoryOptionsFound = False | |
258 os.remove(self._configFileName) | |
259 self.assertFalse(areAllMandatoryOptionsFound) | |
260 self.assertEquals(expMsg,re.getMessage()) | |
261 | |
262 def test_checkMandatoryOptions_in_non_mandatory_section_and_section_does_not_exist (self): | |
263 self._iMock.write_config(self._configFileName) | |
264 iConfigRules = ConfigRules() | |
265 iConfigRules.addRuleOption(section="NonExistingAndNonMandatorySection", option ="genus", mandatory=True) | |
266 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
267 iConfig = iConfigChecker.readConfigFile() | |
268 iConfigChecker.setRawConfig(iConfig) | |
269 iConfigChecker.extendConfigRulesWithPatternRules() | |
270 areAllMandatoryOptionsFound = True | |
271 try: | |
272 iConfigChecker.checkMandatoryOptions() | |
273 except RepetException: | |
274 areAllMandatoryOptionsFound = False | |
275 os.remove(self._configFileName) | |
276 self.assertTrue(areAllMandatoryOptionsFound) | |
277 | |
278 def test_checkMandatoryOptions_with_Pattern_rules_in_section (self): | |
279 self._iMock.write_case_pattern_rule(self._configFileName) | |
280 iConfigRules = ConfigRules() | |
281 iConfigRules.addRuleSection(section="analysis", isPattern=True) | |
282 iConfigRules.addRuleOption(section="analysis", option ="name", mandatory=True) | |
283 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
284 iConfig = iConfigChecker.readConfigFile() | |
285 iConfigChecker.setRawConfig(iConfig) | |
286 iConfigChecker.extendConfigRulesWithPatternRules() | |
287 areAllMandatoryOptionsFound = True | |
288 try: | |
289 iConfigChecker.checkMandatoryOptions() | |
290 except RepetException: | |
291 areAllMandatoryOptionsFound = False | |
292 os.remove(self._configFileName) | |
293 self.assertTrue(areAllMandatoryOptionsFound) | |
294 | |
295 def test_checkMandatoryOptions_with_pattern_rules_in_option_section_is_mandatory (self): | |
296 self._iMock.write_case_pattern_rule(self._configFileName) | |
297 iConfigRules = ConfigRules() | |
298 iConfigRules.addRuleSection(section="section_with_option_pattern", mandatory=True) | |
299 iConfigRules.addRuleOption(section="section_with_option_pattern", option ="option", isPattern= True, mandatory=True) | |
300 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
301 iConfig = iConfigChecker.readConfigFile() | |
302 iConfigChecker.setRawConfig(iConfig) | |
303 iConfigChecker.extendConfigRulesWithPatternRules() | |
304 areAllMandatoryOptionsFound = True | |
305 try: | |
306 iConfigChecker.checkMandatoryOptions() | |
307 except RepetException: | |
308 areAllMandatoryOptionsFound = False | |
309 os.remove(self._configFileName) | |
310 self.assertTrue(areAllMandatoryOptionsFound) | |
311 | |
312 def test_checkMandatoryOptions_with_pattern_rules_in_option_in_mandatory_section_option_is_missing (self): | |
313 self._iMock.write_case_pattern_rule(self._configFileName) | |
314 iConfigRules = ConfigRules() | |
315 iConfigRules.addRuleSection(section="section_with_option_pattern", mandatory=True) | |
316 iConfigRules.addRuleOption(section="section_with_option_pattern", option ="MissingOption", isPattern= True, mandatory=True) | |
317 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
318 iConfig = iConfigChecker.readConfigFile() | |
319 iConfigChecker.setRawConfig(iConfig) | |
320 iConfigChecker.extendConfigRulesWithPatternRules() | |
321 expMsg = "Error in configuration file %s, following options are missing: \n - [section_with_option_pattern]: MissingOption\n" % self._configFileName | |
322 areAllMandatoryOptionsFound = True | |
323 try: | |
324 iConfigChecker.checkMandatoryOptions() | |
325 except RepetException, re: | |
326 areAllMandatoryOptionsFound = False | |
327 os.remove(self._configFileName) | |
328 self.assertFalse(areAllMandatoryOptionsFound) | |
329 self.assertEquals(expMsg, re.getMessage()) | |
330 | |
331 def test_checkMandatoryOptions_with_pattern_rules_in_non_mandatory_section_and_section_and_option_exist (self): | |
332 self._iMock.write_case_pattern_rule(self._configFileName) | |
333 iConfigRules = ConfigRules() | |
334 iConfigRules.addRuleOption(section="section_with_option_pattern", option ="option", isPattern= True, mandatory=True) | |
335 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
336 iConfig = iConfigChecker.readConfigFile() | |
337 iConfigChecker.setRawConfig(iConfig) | |
338 iConfigChecker.extendConfigRulesWithPatternRules() | |
339 areAllMandatoryOptionsFound = True | |
340 try: | |
341 iConfigChecker.checkMandatoryOptions() | |
342 except RepetException: | |
343 areAllMandatoryOptionsFound = False | |
344 os.remove(self._configFileName) | |
345 self.assertTrue(areAllMandatoryOptionsFound) | |
346 | |
347 def test_checkMandatoryOptions_with_pattern_rules_in_non_mandatory_section_and_section_exist_option_is_missing (self): | |
348 self._iMock.write_case_pattern_rule(self._configFileName) | |
349 iConfigRules = ConfigRules() | |
350 iConfigRules.addRuleOption(section="section_with_option_pattern", option ="MissingOption", isPattern= True, mandatory=True) | |
351 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
352 iConfig = iConfigChecker.readConfigFile() | |
353 iConfigChecker.setRawConfig(iConfig) | |
354 iConfigChecker.extendConfigRulesWithPatternRules() | |
355 expMsg = "Error in configuration file %s, following options are missing: \n - [section_with_option_pattern]: MissingOption\n" % self._configFileName | |
356 areAllMandatoryOptionsFound = True | |
357 try: | |
358 iConfigChecker.checkMandatoryOptions() | |
359 except RepetException, re: | |
360 areAllMandatoryOptionsFound = False | |
361 os.remove(self._configFileName) | |
362 self.assertFalse(areAllMandatoryOptionsFound) | |
363 self.assertEquals(expMsg,re.getMessage()) | |
364 | |
365 def test_checkMandatoryOptions_with_pattern_rules_in_non_mandatory_section_and_section_does_not_exist (self): | |
366 self._iMock.write_case_pattern_rule(self._configFileName) | |
367 iConfigRules = ConfigRules() | |
368 iConfigRules.addRuleOption(section="non_mandatory_section", option ="MissingOption", isPattern= True, mandatory=True) | |
369 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
370 iConfig = iConfigChecker.readConfigFile() | |
371 iConfigChecker.setRawConfig(iConfig) | |
372 iConfigChecker.extendConfigRulesWithPatternRules() | |
373 areAllMandatoryOptionsFound = True | |
374 try: | |
375 iConfigChecker.checkMandatoryOptions() | |
376 except RepetException: | |
377 areAllMandatoryOptionsFound = False | |
378 os.remove(self._configFileName) | |
379 self.assertTrue(areAllMandatoryOptionsFound) | |
380 | |
381 def test_checkMandatoryOptions_with_pattern_rules_for_both_section_and_option (self): | |
382 self._iMock.write_case_pattern_rule(self._configFileName) | |
383 iConfigRules = ConfigRules() | |
384 iConfigRules.addRuleSection(section="section_with_option_pattern", isPattern=True) | |
385 iConfigRules.addRuleOption(section="section_with_option_pattern", option ="option", isPattern= True, mandatory=True) | |
386 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
387 iConfig = iConfigChecker.readConfigFile() | |
388 iConfigChecker.setRawConfig(iConfig) | |
389 iConfigChecker.extendConfigRulesWithPatternRules() | |
390 areAllMandatoryOptionsFound = True | |
391 try: | |
392 iConfigChecker.checkMandatoryOptions() | |
393 except RepetException: | |
394 areAllMandatoryOptionsFound = False | |
395 os.remove(self._configFileName) | |
396 self.assertTrue(areAllMandatoryOptionsFound) | |
397 | |
398 def test_checkMandatoryOptions_case(self): | |
399 self._iMock.write_config_case(self._configFileName) | |
400 iConfigRules = ConfigRules() | |
401 iConfigRules.addRuleSection("dir_name", True) | |
402 iConfigRules.addRuleSection("organism", True) | |
403 iConfigRules.addRuleOption("organism", "min_SSR_coverage", True) | |
404 iConfigChecker = ConfigChecker(self._configFileName, iConfigRules) | |
405 iConfig = iConfigChecker.readConfigFile() | |
406 iConfigChecker.setRawConfig(iConfig) | |
407 iConfigChecker.extendConfigRulesWithPatternRules() | |
408 areAllMandatorySectionsFound = True | |
409 try: | |
410 iConfigChecker.checkMandatoryOptions() | |
411 except RepetException: | |
412 areAllMandatorySectionsFound = False | |
413 os.remove(self._configFileName) | |
414 self.assertTrue(areAllMandatorySectionsFound) | |
415 | |
416 #TODO Test de extendConfigRulesWithPatternRules et de applyRuleToRawValue | |
417 # option avec une liste de valeurs possibles dans un ensemble | |
418 # option type=string type="num" type="date"???. | |
419 #option define twice and options use in other | |
420 | |
421 class MockConfig (object): | |
422 | |
423 def write_config(self, configFileName): | |
424 configF = open(configFileName, "w" ) | |
425 configF.write( "[dir_name]\n") | |
426 configF.write( "work_dir : toto \n") | |
427 configF.write( "\n") | |
428 configF.write( "[organism]\n") | |
429 configF.write( "abbreviation: T.aestivum\n") | |
430 configF.write( "genus: triticum\n") | |
431 configF.write( "species: aestivum\n") | |
432 configF.write( "common_name: wheat\n") | |
433 configF.write( "comment: \n") | |
434 configF.write( "[analysis1]\n") | |
435 configF.write( "name: BLASTXWheat2\n") | |
436 configF.write( "program: BLASTX2\n") | |
437 configF.write( "programversion: 3.32\n") | |
438 configF.write( "sourcename: dummyDesc_BLASTX2\n") | |
439 configF.write( "description: \n") | |
440 configF.write( "gff_name: BLASTX.gff2\n") | |
441 configF.write( "\n") | |
442 configF.close() | |
443 | |
444 def write_case_section_define_twice(self, configFileName): | |
445 configF = open(configFileName, "w" ) | |
446 configF.write( "[dir_name]\n") | |
447 configF.write( "work_dir : toto \n") | |
448 configF.write( "\n") | |
449 configF.write( "[analysis1]\n") | |
450 configF.write( "name: BLASTXWheat\n") | |
451 configF.write( "program: BLASTX\n") | |
452 configF.write( "programversion: 3.3\n") | |
453 configF.write( "sourcename: dummyDesc_BLASTX\n") | |
454 configF.write( "description: \n") | |
455 configF.write( "gff_name: BLASTX.gff\n") | |
456 configF.write( "\n") | |
457 configF.write( "[analysis1]\n") | |
458 configF.write( "name: BLASTXWheat2\n") | |
459 configF.write( "program: BLASTX2\n") | |
460 configF.write( "programversion: 3.32\n") | |
461 configF.write( "sourcename: dummyDesc_BLASTX2\n") | |
462 configF.write( "description: \n") | |
463 configF.write( "gff_name: BLASTX.gff2\n") | |
464 configF.write( "\n") | |
465 configF.close() | |
466 | |
467 def write_case_option_define_twice(self, configFileName): | |
468 configF = open(configFileName, "w" ) | |
469 configF.write( "[dir_name]\n") | |
470 configF.write( "work_dir : toto \n") | |
471 configF.write( "\n") | |
472 configF.write( "[analysis1]\n") | |
473 configF.write( "name: BLASTXWheat\n") | |
474 configF.write( "program: BLASTX\n") | |
475 configF.write( "programversion: 3.3\n") | |
476 configF.write( "sourcename: dummyDesc_BLASTX\n") | |
477 configF.write( "program: BLASTX2\n") | |
478 configF.write( "description: \n") | |
479 configF.write( "gff_name: BLASTX.gff\n") | |
480 configF.write( "\n") | |
481 configF.write( "\n") | |
482 configF.close() | |
483 | |
484 #configuration file with section with option depends on presence of other options | |
485 def write_with_one_option_depends_of_an_other_one(self, configFileName ): | |
486 configF = open(configFileName, "w" ) | |
487 configF.write( "[dir_name]\n") | |
488 configF.write( "work_dir : toto\n") | |
489 configF.write( "\n") | |
490 configF.write( "[organism]\n") | |
491 configF.write( "abbreviation: T.aestivum\n") | |
492 configF.write( "genus: Triticum\n") | |
493 configF.write( "species: aestivum\n") | |
494 configF.write( "common_name: wheat\n") | |
495 configF.write( "comment: \n") | |
496 configF.write( "\n") | |
497 configF.write( "[analysis1]\n") | |
498 configF.write( "name: BLASTXWheat\n") | |
499 configF.write( "program: BLASTX\n") | |
500 configF.write( "programversion: 3.3\n") | |
501 configF.write( "sourcename: src_BLASTX\n") | |
502 configF.write( "description: \n") | |
503 configF.write( "gff_name: BLASTX.gff\n") | |
504 configF.write( "\n") | |
505 configF.write( "[analysis2]\n") | |
506 configF.write( "name: GMHMMWheat\n") | |
507 configF.write( "program: GMHMM\n") | |
508 configF.write( "programversion: 4.3\n") | |
509 configF.write( "sourcename: src_GMHMM\n") | |
510 configF.write( "description: \n") | |
511 configF.write( "gff_name: GMHMM.gff\n") | |
512 configF.write( "\n") | |
513 configF.write( "[target]\n") | |
514 configF.write( "target_used: yes\n") | |
515 configF.write( "target_used_list: target.lst\n") | |
516 configF.close() | |
517 | |
518 def write_case_pattern_rule(self, configFileName ): | |
519 configF = open(configFileName, "w" ) | |
520 configF.write( "[dir_name]\n") | |
521 configF.write( "work_dir : toto\n" ) | |
522 configF.write( "\n") | |
523 configF.write( "[organism]\n") | |
524 configF.write( "abbreviation: T.aestivum\n") | |
525 configF.write( "genus: Triticum\n") | |
526 configF.write( "species: aestivum\n") | |
527 configF.write( "common_name: wheat\n") | |
528 configF.write( "comment: \n") | |
529 configF.write( "\n") | |
530 configF.write( "[analysis1]\n") | |
531 configF.write( "name: BLASTXWheat\n") | |
532 configF.write( "program: BLASTX\n") | |
533 configF.write( "programversion: 3.3\n") | |
534 configF.write( "sourcename: src_BLASTX\n") | |
535 configF.write( "description: \n") | |
536 configF.write( "gff_name: BLASTX.gff\n") | |
537 configF.write( "\n") | |
538 configF.write( "[analysis2]\n") | |
539 configF.write( "name: GMHMMWheat\n") | |
540 configF.write( "program: GMHMM\n") | |
541 configF.write( "programversion: 4.3\n") | |
542 configF.write( "sourcename: src_GMHMM\n") | |
543 configF.write( "description: \n") | |
544 configF.write( "gff_name: GMHMM.gff\n") | |
545 configF.write( "\n") | |
546 configF.write( "[target]\n") | |
547 configF.write( "target_used: yes\n") | |
548 configF.write( "target_used_list: target.lst\n") | |
549 configF.write( "\n") | |
550 configF.write( "[section_with_option_pattern]\n") | |
551 configF.write( "option1: value1\n") | |
552 configF.write( "option2: value2\n") | |
553 configF.write( "[second_section_with_option_pattern]\n") | |
554 configF.write( "option1: value1\n") | |
555 configF.write( "option2: value2\n") | |
556 configF.close() | |
557 | |
558 def write_config_case(self, configFileName): | |
559 configF = open(configFileName, "w" ) | |
560 configF.write( "[dir_name]\n") | |
561 configF.write( "work_dir : toto \n") | |
562 configF.write( "\n") | |
563 configF.write( "[organism]\n") | |
564 configF.write( "min_SSR_coverage: 0.50\n") | |
565 configF.write( "\n") | |
566 configF.close() | |
567 | |
568 if __name__ == "__main__": | |
569 unittest.main() |