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
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 class Test_F_LaunchRefAlign(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 self._inputFastaFileName = "input.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._obsOutputFileName = "obs"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._expOutputFileName = "exp"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._writeInputFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 self._writeExpOutputFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 # def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 # try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 # os.remove(self._inputFastaFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 # except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 #
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 # try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 # os.remove(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 # except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 # try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 # os.remove(self._obsOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 # except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 # try:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 # os.remove("input.fa.2.3.5.80.10.20.15.dat")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 # except:pass
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 def test_run(self):
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_as_script(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 # cmd = 'LaunchTRF.py -i %s -o %s -v 3' % (self._inputFastaFileName, self._obsTRFOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 # os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 # self.assertTrue(FileUtils.are2FilesIdentical(self._expTRFOutputFileName, self._obsTRFOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 def _writeInputFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 InputFile = open(self._inputFastaFileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 InputFile.write('>sequence\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 InputFile.write('GGGCGGCACGGTGGTGTGGTGGTTAGCACTGTTGCCTCACAGCAAGAAGGCCCCGGGTTC\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 InputFile.write('GATCCCCGGTTGGGACTGAGGCTGGGGACTTTCTGTGTGGAGTTTGCATGTTCTCCCTGT\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 InputFile.write('GCCTGCGTGGGTTCTCTCCGGGTACTCCGGCTTCCTCCCACAGTCCAAAGACATGCATGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 InputFile.write('TTGGGGATTAGGCTAATTGGAAACTCTAAAATTGCCCGTAGGTGTGAGTGTGAGAGAGAA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 InputFile.write('TGGTTGTTTGTCTATATGTGTTAGCCCTGCGATTGACTGGCGTCCAGTCCAGGGTGTACC\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 InputFile.write('CTGCCTCCGCCCATTGTGCTGGGATAGGCTCCAGTCCCCCCG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 InputFile.write('CAAGCGGTAGAAAGTGAGTGAGTGAGTGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 InputFile.write('>sequence2\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 InputFile.write('GGGCAGCCTGGGTGGCTCAGCGGTTTAGCGCCTGCCTTTGGCCCAGGGCGTGATCCTGGA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 InputFile.write('GACCCGGGATCGAGTCCCACATCGGGCTCCCTGCATGGAGCCTGCTTCTCCCTCTGCCTG\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 InputFile.write('TGTCTCTGCCTCTCTCTCTCTCTGTGTCTCTCATGAATAAA\n')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 InputFile.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 def _writeExpOutputFile(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 with open(self._expOutputFileName,'w') as expOutputFile:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 expOutputFile.write("""1\t(GTGGT)2\tsequence\t11\t21
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 2\t(GGT)5\tsequence\t10\t23
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 3\t(GTGTGA)4\tsequence\t222\t242
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 4\t(GTCCA)2\tsequence\t282\t292
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 5\t(AGTG)4\tsequence\t355\t371
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 6\t(GCCTGTCTCTCCTCT)4\tsequence2\t100\t152
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 7\t(CTCTGCCTGTGT)3\tsequence2\t112\t151
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 8\t(TC)23\tsequence2\t107\t152
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 """)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 unittest.main()