annotate commons/pyRepetUnit/fastaTranslation/allFrames/tests/Test_TranslateInAllFramesAndReplaceStopByX.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 import os
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 import unittest
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from commons.pyRepetUnit.fastaTranslation.allFrames.TranslateInAllFramesAndReplaceStopByX import TranslateInAllFramesAndReplaceStopByX
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from commons.core.seq.Bioseq import Bioseq
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 from commons.core.utils.FileUtils import FileUtils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 class Test_TranslateInAllFramesAndReplaceStopByX(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.bioseq = Bioseq()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self.preProcess = TranslateInAllFramesAndReplaceStopByX()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._inputFile = "./datas/dummy.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._outputFile = "./datas/dummyoutput.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 def testRun(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 self.preProcess.setInputFile(self._inputFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 self.preProcess.setOutputFile(self._outputFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 # real fasta file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 f = open(self._inputFile, "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 f.write(">header1 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 f.write("TGTGGCTTCTAGTTGATCAGTTTATGATCACAATGATTTCACGTAGGTGTCTCGTGGCTC\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 f.write("CGACTAATCAACAATATAATGCGAGTAGAGCTTGA\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 f.write(">header2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 f.write("TGTGGCTTCTAGTTGATCAGTTTATGATCACAATGATTTCACGTAGGTGTCTCGTGGCTA\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 f.write("CGACTAATCAACAATATAATGCGAGTAGAGCTTGA")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 # expected fasta translated file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 f = open("./datas/expectedTranslated.fa", "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 f.write(">header1_1 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 f.write("CGFXLISLXSQXFHVGVSWLRLINNIMRVEL\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 f.write(">header1_2 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 f.write("VASSXSVYDHNDFTXVSRGSDXSTIXCEXSL\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 f.write(">header1_3 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 f.write("WLLVDQFMITMISRRCLVAPTNQQYNASRAX\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 f.write(">header1_4 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 f.write("SSSTRIILLISRSHETPTXNHCDHKLINXKP\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 f.write(">header1_5 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 f.write("QALLALYCXLVGATRHLREIIVIINXSTRSH\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 f.write(">header1_6 description\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 f.write("KLYSHYIVDXSEPRDTYVKSLXSXTDQLEAT\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 f.write(">header2_1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 f.write("CGFXLISLXSQXFHVGVSWLRLINNIMRVEL\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 f.write(">header2_2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 f.write("VASSXSVYDHNDFTXVSRGYDXSTIXCEXSL\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 f.write(">header2_3\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 f.write("WLLVDQFMITMISRRCLVATTNQQYNASRAX\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 f.write(">header2_4\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 f.write("SSSTRIILLISRSHETPTXNHCDHKLINXKP\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 f.write(">header2_5\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 f.write("QALLALYCXLVVATRHLREIIVIINXSTRSH\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 f.write(">header2_6\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 f.write("KLYSHYIVDXSXPRDTYVKSLXSXTDQLEAT\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 self.preProcess.run()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 self.assertTrue(FileUtils.are2FilesIdentical("./datas/expectedTranslated.fa", self._outputFile))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 os.system("rm " + self._inputFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 os.system("rm " + self._outputFile)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 os.system("rm ./datas/expectedTranslated.fa")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 # empty fasta file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 #self.preProcess.translateAfastaFileInAllFrame()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 #self.assertFalse(FileUtils.isRessourceExists(self._outputFile))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 unittest.main()