annotate commons/launcher/tests/Test_F_LaunchRefalign.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 from commons.core.utils.FileUtils import FileUtils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from commons.launcher.LaunchRefAlign import LaunchRefAlign
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 from shutil import rmtree
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 class Test_F_LaunchRefAlign(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._curTestDir = os.getcwd()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._testPrefix = 'test_LRA'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 os.makedirs(self._testPrefix)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 os.chdir(self._testPrefix)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 self._inputFastaFileName = "%s_input.fa" % self._testPrefix
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 self._obsOutputFileName = self._inputFastaFileName +'.fa_aln'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 self._expOutputFileName = "%s_exp.fa_aln" % self._testPrefix
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 self._writeInputFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 os.chdir(self._curTestDir)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 rmtree(self._testPrefix)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 def test_run(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 self._writeExpOutputFile_wo_refseq()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 ilauncher.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 def test_run_KeepRefSeq(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 self._writeExpOutputFile_with_refseq()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 ilauncher = LaunchRefAlign(self._inputFastaFileName,verbosity=5, keepRefseq=True)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 ilauncher.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 def test_run_as_script(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 self._writeExpOutputFile_wo_refseq()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 cmd = 'LaunchRefAlign.py -i %s -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 def test_run_as_script_KeepRefSeq(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 self._writeExpOutputFile_with_refseq()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 cmd = 'LaunchRefAlign.py -i %s -r -o %s -v 5' % (self._inputFastaFileName, self._obsOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutputFileName, self._obsOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 def _writeInputFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 InputFile = open(self._inputFastaFileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 InputFile.write('>sequence\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 InputFile.write('>sequence2\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 InputFile.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 def _writeExpOutputFile_wo_refseq(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 with open(self._expOutputFileName,'w') as expOutputFile:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 expOutputFile.write(""">sequence2
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 GCCTGTGTCTCTTCTCTC------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 ------------------------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 ------------------------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 -----------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 """)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83 def _writeExpOutputFile_with_refseq(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 with open(self._expOutputFileName,'w') as expOutputFile:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 expOutputFile.write(""">sequence
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
86 GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
87 GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
88 GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
89 TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
90 TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
91 CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCGCAAGCGGTAGAAAGTGAG
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
92 TGAGTGAGTGA
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
93 >sequence2
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
94 GGGCAGC-CGGTGGTGCGGT--TTAGCGCTGTTGGCCCAGGGCGTGATGGACCCGGGATC
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
95 GATCCCACATCGGG--------------CTCCCTGCATGGAGCCTGC---TTCTCCCTCT
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
96 GCCTGTGTCTCTTCTCTC------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
97 ------------------------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
98 ----------TCTCTCTGTGTCTCTCATGA-ATAAA------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
99 ------------------------------------------------------------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
100 -----------
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
101 """)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
102
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
103 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
104 unittest.main()