18
|
1 import unittest
|
|
2 import os, glob
|
|
3
|
|
4
|
|
5 class Test_F_getReadDistribution(unittest.TestCase):
|
|
6
|
|
7 def setUp(self):
|
|
8 self.inputFileName = "inputFile.fasta"
|
|
9 self.outputFileName = "outputFile"
|
|
10
|
|
11 def tearDown(self):
|
|
12 for fileRoot in (self.inputFileName, self.outputFileName):
|
|
13 for file in glob.glob("%s*" % (fileRoot)):
|
|
14 os.remove(file)
|
|
15 os.system("rm .RData")
|
|
16
|
|
17 def test_run_simple(self):
|
|
18 handle = open(self.inputFileName, "w")
|
|
19 handle.write(">test1\n")
|
|
20 handle.write("AAAAAA\n")
|
|
21 handle.write(">test2\n")
|
|
22 handle.write("AAAAAA\n")
|
|
23 handle.write(">test3\n")
|
|
24 handle.write("CCCCCC\n")
|
|
25 handle.close()
|
|
26 handle.close()
|
|
27 os.system("python ../getReadDistribution.py -i %s -f fasta -n 1 -o %s -v 0" % (self.inputFileName, self.outputFileName))
|
|
28 self.assertTrue(os.path.exists("%s.png" % (self.outputFileName)))
|
|
29 handle = open("%s.txt" % (self.outputFileName))
|
|
30 lines = handle.readlines()
|
|
31 self.assertEquals(len(lines), 1)
|
|
32 self.assertEquals(lines[0], "AAAAAA\t2\n")
|
|
33
|
|
34
|
|
35 if __name__ == "__main__":
|
|
36 unittest.main()
|
|
37
|