annotate SMART/Java/Python/test/Test_F_clusterizeBySlidingWindows.py @ 24:452e051f6562

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:28:24 -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 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 SMART.Java.Python.misc import Utils
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_clusterizeBySlidingWindows(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._outputFileName = 'output.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._outputCsvFileName = 'output.csv'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._outputPngFileName = 'output.png'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._expectedOutputFileName = 'expOut.png'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 for fileName in (self._outputFileName, self._outputCsvFileName, self._outputPngFileName, self._expectedOutputFileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 if os.path.exists(fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 os.remove(fileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 def test_run_default_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerExpected.gff3 -f gff3 -o %s -s 50000 -e 50 -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 exp = '../TestFiles/clusterize_default_expected.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 self.assertTrue(Utils.diff(exp, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 def test_run_default_option_map_output(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self._outputFileName = 'output.map'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerExpected.gff3 -f gff3 -o %s -s 50000 -e 50 -u map -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 exp = '../TestFiles/clusterize_default_expected.map'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 self.assertTrue(Utils.diff(exp, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 def test_run_newTag_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerExpected.gff3 -f gff3 -o %s -s 50000 -e 50 -w newTag -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 exp = '../TestFiles/clusterize_output_tag_expected.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 self.assertTrue(Utils.diff(exp, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 def test_run_normalize_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerOutput.gff3 -f gff3 -o %s -s 50000 -e 50 -m -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 exp = '../TestFiles/clusterize_normalize_expected.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 self.assertTrue(Utils.diff(exp, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 def test_run_strand_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerOutput.gff3 -f gff3 -o %s -s 50000 -e 50 -2 -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 exp = '../TestFiles/clusterize_strands_expected.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 self.assertTrue(Utils.diff(exp, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 def test_run_excel_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerOutput.gff3 -f gff3 -o %s -s 50000 -e 50 -x %s -v 0" % (self._outputFileName, self._outputCsvFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 self.assertTrue(FileUtils.isRessourceExists(self._outputCsvFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 def test_run_normalize_strand_excel_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/mapperAnalyzerOutput.gff3 -f gff3 -o %s -s 50000 -e 50 -m -2 -x %s -v 0" % (self._outputFileName, self._outputCsvFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 self.assertTrue(FileUtils.isRessourceExists(self._outputCsvFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 def test_run_tag_operation_options(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/testSW.gff3 -f gff -s 100 -e 0 -g value1 -r min -o %s -v 0" % (self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 exp = open(self._expectedOutputFileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 exp.write("chr1\tS-MART\ttranscript\t1\t100\t.\t+\t.\tnbElements=0;minValue1=0;ID=region1;Name=region1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 exp.write("chr1\tS-MART\ttranscript\t101\t200\t.\t+\t.\tnbElements=2.000000;minValue1=1.0;ID=region2;Name=region2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 exp.write("chr1\tS-MART\ttranscript\t201\t300\t.\t+\t.\tnbElements=2.000000;minValue1=10.0;ID=region3;Name=region3\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 exp.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 self.assertTrue(Utils.diff(self._outputFileName, self._expectedOutputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 def test_run_plot_options(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 cmd = "python ../clusterizeBySlidingWindows.py -i ../TestFiles/testSW.gff3 -f gff -s 100 -e 0 -g value1 -r min -o %s -p %s -v 0" % (self._outputFileName, self._outputPngFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 self.assertTrue(FileUtils.isRessourceExists(self._outputPngFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 unittest.main()