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