comparison 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
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
1 import os
2 import unittest
3 from commons.pyRepetUnit.fastaTranslation.allFrames.TranslateInAllFramesAndReplaceStopByX import TranslateInAllFramesAndReplaceStopByX
4 from commons.core.seq.Bioseq import Bioseq
5 from commons.core.utils.FileUtils import FileUtils
6
7 class Test_TranslateInAllFramesAndReplaceStopByX(unittest.TestCase):
8
9 def setUp(self):
10 self.bioseq = Bioseq()
11 self.preProcess = TranslateInAllFramesAndReplaceStopByX()
12 self._inputFile = "./datas/dummy.fa"
13 self._outputFile = "./datas/dummyoutput.fa"
14
15
16 def testRun(self):
17 self.preProcess.setInputFile(self._inputFile)
18 self.preProcess.setOutputFile(self._outputFile)
19 # real fasta file
20 f = open(self._inputFile, "w")
21 f.write(">header1 description\n")
22 f.write("TGTGGCTTCTAGTTGATCAGTTTATGATCACAATGATTTCACGTAGGTGTCTCGTGGCTC\n")
23 f.write("CGACTAATCAACAATATAATGCGAGTAGAGCTTGA\n")
24 f.write(">header2\n")
25 f.write("TGTGGCTTCTAGTTGATCAGTTTATGATCACAATGATTTCACGTAGGTGTCTCGTGGCTA\n")
26 f.write("CGACTAATCAACAATATAATGCGAGTAGAGCTTGA")
27 f.close()
28 # expected fasta translated file
29 f = open("./datas/expectedTranslated.fa", "w")
30 f.write(">header1_1 description\n")
31 f.write("CGFXLISLXSQXFHVGVSWLRLINNIMRVEL\n")
32 f.write(">header1_2 description\n")
33 f.write("VASSXSVYDHNDFTXVSRGSDXSTIXCEXSL\n")
34 f.write(">header1_3 description\n")
35 f.write("WLLVDQFMITMISRRCLVAPTNQQYNASRAX\n")
36 f.write(">header1_4 description\n")
37 f.write("SSSTRIILLISRSHETPTXNHCDHKLINXKP\n")
38 f.write(">header1_5 description\n")
39 f.write("QALLALYCXLVGATRHLREIIVIINXSTRSH\n")
40 f.write(">header1_6 description\n")
41 f.write("KLYSHYIVDXSEPRDTYVKSLXSXTDQLEAT\n")
42 f.write(">header2_1\n")
43 f.write("CGFXLISLXSQXFHVGVSWLRLINNIMRVEL\n")
44 f.write(">header2_2\n")
45 f.write("VASSXSVYDHNDFTXVSRGYDXSTIXCEXSL\n")
46 f.write(">header2_3\n")
47 f.write("WLLVDQFMITMISRRCLVATTNQQYNASRAX\n")
48 f.write(">header2_4\n")
49 f.write("SSSTRIILLISRSHETPTXNHCDHKLINXKP\n")
50 f.write(">header2_5\n")
51 f.write("QALLALYCXLVVATRHLREIIVIINXSTRSH\n")
52 f.write(">header2_6\n")
53 f.write("KLYSHYIVDXSXPRDTYVKSLXSXTDQLEAT\n")
54 f.close()
55 self.preProcess.run()
56 self.assertTrue(FileUtils.are2FilesIdentical("./datas/expectedTranslated.fa", self._outputFile))
57 os.system("rm " + self._inputFile)
58 os.system("rm " + self._outputFile)
59 os.system("rm ./datas/expectedTranslated.fa")
60 # empty fasta file
61 #self.preProcess.translateAfastaFileInAllFrame()
62 #self.assertFalse(FileUtils.isRessourceExists(self._outputFile))
63
64 if __name__ == "__main__":
65 unittest.main()