annotate SMART/Java/Python/test/Test_F_GetDifferentialExpression.py @ 27:4e7ee5683ef1

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:30:11 -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, os.path, glob
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from SMART.Java.Python.GetDifferentialExpression import GetDifferentialExpression
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 class Test_F_GetDifferentialExpression(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 self.inputFileName1 = "inputFile1.gff3"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 self.inputFileName2 = "inputFile2.gff3"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self.refFileName = "refFile.gff3"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self.outputFileName = "outputFile.gff3"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self.plotFileName = "outputFile.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 fileRoot in (self.inputFileName1, self.inputFileName2, self.refFileName, self.outputFileName, self.plotFileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 for file in glob.glob("%s*" % (fileRoot)):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 os.remove(file)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 os.remove(".RData")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 def test_run_simple(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 handle = open(self.inputFileName1, "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1;nbElements=100\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 handle.write("chr2\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test2;Name=test2;nbElements=1000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 handle.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 handle = open(self.inputFileName2, "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1;nbElements=200\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 handle.write("chr2\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test2;Name=test2;nbElements=1000\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 handle.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 handle = open(self.refFileName, "w")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 handle.write("chr1\tSMART\tmRNA\t1000\t2000\t.\t+\t.\tID=test1;Name=test1")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 handle.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 differentialExpression = GetDifferentialExpression(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 differentialExpression.setInputFile(0, self.inputFileName1, "gff3")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 differentialExpression.setInputFile(1, self.inputFileName2, "gff3")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 differentialExpression.setReferenceFile(self.refFileName, "gff3")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 differentialExpression.setOutputFile(self.outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 differentialExpression.setPlotterName(self.plotFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 differentialExpression.setPlotter()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 differentialExpression.getDifferentialExpression()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 differentialExpression.mySqlConnection.deleteDatabase()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 handle = open(self.outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 lines = handle.readlines()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 self.assertEquals(len(lines), 1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
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")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 self.assertTrue(os.path.exists(self.plotFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 unittest.main()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50