comparison commons/launcher/tests/Test_F_LaunchPhyML.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
comparison
equal deleted inserted replaced
17:b0e8584489e6 18:94ab73e8a190
1 import unittest
2 import os
3 from commons.core.utils.FileUtils import FileUtils
4 from shutil import rmtree
5 from commons.launcher.LaunchPhyML import LaunchPhyML
6
7
8 class Test_F_LaunchPhyML(unittest.TestCase):
9
10 def setUp(self):
11 self._curTestDir = os.getcwd()
12 self._testPrefix = 'test_LRA'
13 try:
14 os.makedirs(self._testPrefix)
15 except:pass
16 os.chdir(self._testPrefix)
17
18
19 self._inputFastaFileName = "%s_input.fa" % self._testPrefix
20 self._obsOutputFileName = self._inputFastaFileName +'_obs.phylip'
21 self._expOutputFileName = "%s_exp.phylip" % self._testPrefix
22 self._writeInputFile()
23
24 # def tearDown(self):
25 # os.chdir(self._curTestDir)
26 # try:
27 # rmtree(self._testPrefix)
28 # except:pass
29
30 def test_run(self):
31 #phylip use only same length sequences
32 self._writeExpFile()
33 ilauncher = LaunchPhyML(self._inputFastaFileName,verbosity=7)
34 ilauncher.run()
35 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
36
37
38 # def test_run_as_script(self):
39 # self._writeExpOutputFile_wo_refseq()
40 # cmd = 'LaunchPhyML.py -i %s -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
41 # os.system(cmd)
42 # self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
43
44
45 def _writeInputFile(self):
46 InputFile = open(self._inputFastaFileName, 'w')
47 InputFile.write(""">sequence1
48 GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC
49 GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT
50 GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAG
51 >sequence2
52 GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA
53 GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG
54 GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGG
55 >sequence3
56 ATCTTAGTTTTGCTGAGCGCCTTCATGGCTGCTTGACTATCAGACAGTATAGCAATGTCC
57 TTGCCATGATAGTTCCTTTTCAGATTAAACTCTGCACAGCGTCCAATAGCACAGACTTCA
58 GCTTGAATGCTGGTGTATCTGCCCATTGATTCGTGGTATTTCAACCTGGG
59 """)
60 InputFile.close()
61
62 def _writeExpFile(self):
63 InputFile = open(self._expOutputFileName, 'w')
64 InputFile.write(""" 3 170
65 sequence1 GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGG
66 sequence2 GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCG
67 sequence3 ATCTTAGTTTTGCTGAGCGCCTTCATGGCTGCTTGACTATCAGACAGTAT
68
69 CCCCGGGTTCGATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGG
70 TGATCCTGGAGACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAG
71 AGCAATGTCCTTGCCATGATAGTTCCTTTTCAGATTAAACTCTGCACAGC
72
73 AGTTTGCATGTTCTCCCTGTGCCTGCGTGGGTTCTCTCCGGGTACTCCGG
74 CCTGCTTCTCCCTCTGCCTGGGGCGGCACGGTGGTGTGGTGGTTAGCACT
75 GTCCAATAGCACAGACTTCAGCTTGAATGCTGGTGTATCTGCCCATTGAT
76
77 CTTCCTCCCACAGTCCAAAG
78 GTTGCCTCACAGCAAGAAGG
79 TCGTGGTATTTCAACCTGGG""")
80 InputFile.close()
81
82 if __name__ == "__main__":
83 unittest.main()