18
|
1 import unittest
|
|
2 import os, os.path, glob
|
|
3 from SMART.Java.Python.GetDifferentialExpression import GetDifferentialExpression
|
|
4
|
|
5
|
|
6 class Test_F_GetDifferentialExpression(unittest.TestCase):
|
|
7
|
|
8 def setUp(self):
|
|
9 self.inputFileName1 = "inputFile1.gff3"
|
|
10 self.inputFileName2 = "inputFile2.gff3"
|
|
11 self.refFileName = "refFile.gff3"
|
|
12 self.outputFileName = "outputFile.gff3"
|
|
13 self.plotFileName = "outputFile.png"
|
|
14
|
|
15 def tearDown(self):
|
|
16 for fileRoot in (self.inputFileName1, self.inputFileName2, self.refFileName, self.outputFileName, self.plotFileName):
|
|
17 for file in glob.glob("%s*" % (fileRoot)):
|
|
18 os.remove(file)
|
|
19 os.remove(".RData")
|
|
20
|
|
21 def test_run_simple(self):
|
|
22 handle = open(self.inputFileName1, "w")
|
|
23 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1;nbElements=100\n")
|
|
24 handle.write("chr2\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test2;Name=test2;nbElements=1000\n")
|
|
25 handle.close()
|
|
26 handle = open(self.inputFileName2, "w")
|
|
27 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1;nbElements=200\n")
|
|
28 handle.write("chr2\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test2;Name=test2;nbElements=1000\n")
|
|
29 handle.close()
|
|
30 handle = open(self.refFileName, "w")
|
|
31 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1")
|
|
32 handle.close()
|
|
33 differentialExpression = GetDifferentialExpression(0)
|
|
34 differentialExpression.setInputFile(0, self.inputFileName1, "gff3")
|
|
35 differentialExpression.setInputFile(1, self.inputFileName2, "gff3")
|
|
36 differentialExpression.setReferenceFile(self.refFileName, "gff3")
|
|
37 differentialExpression.setOutputFile(self.outputFileName)
|
|
38 differentialExpression.setPlotterName(self.plotFileName)
|
|
39 differentialExpression.setPlotter()
|
|
40 differentialExpression.getDifferentialExpression()
|
|
41 differentialExpression.mySqlConnection.deleteDatabase()
|
|
42 handle = open(self.outputFileName)
|
|
43 lines = handle.readlines()
|
|
44 self.assertEquals(len(lines), 1)
|
|
45 self.assertEquals(lines[0], "chr1\tS-MART\ttranscript\t1000\t2000\t.\t+\t.\tnbReadsCond1=100;nbReadsCond2=200;ID=test1;regulation=up;nbUnnormalizedReadsCond2=200;nbUnnormalizedReadsCond1=100;pValue=6.010045e-08;Name=test1\n")
|
|
46 self.assertTrue(os.path.exists(self.plotFileName))
|
|
47
|
|
48 if __name__ == "__main__":
|
|
49 unittest.main()
|
|
50
|