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