annotate SMART/Java/Python/test/Test_F_getWigData.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -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
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from SMART.Java.Python.misc import Utils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from SMART.Java.Python.getWigData import *
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 class Test_F_getWigData(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
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._inputGffFileName = 'inputGff.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._writeInputGff(self._inputGffFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._inputWigFileName = '../TestFiles/sorted_query_wig.wig'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._expOutFileName = 'expOut.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 self._outFileName = 'outGffWig.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 os.remove(self._inputGffFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 os.remove(self._expOutFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 os.remove(self._outFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 def test_getWigData_DefaultOption_asScript(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 cmd = 'python ../getWigData.py -i %s -f gff3 -w %s -t wigValue -o %s -v 0' % (self._inputGffFileName, self._inputWigFileName, self._outFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 self._writeExpDefaultOption(self._expOutFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self.assertTrue(Utils.diff(self._expOutFileName, self._outFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 def test_getWigData_strandsOption(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 cmd = 'python ../getWigData.py -i %s -f gff3 -w %s -t wigValue -o %s -s -v 0' % (self._inputGffFileName, self._inputWigFileName, self._outFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 self._writeExpStransOption(self._expOutFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 self.assertTrue(Utils.diff(self._expOutFileName, self._outFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 def _writeInputGff(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 f.write("chr1\tquery\ttest1.1\t25\t150\t126\t+\t.\tID=query_1;Name=test1.1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 f.write("chr1\tquery\ttest1.2\t70\t850\t781\t-\t.\tID=query_2;Name=test1.2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 f.write("chr1\tquery\ttest1.3\t550\t850\t201\t-\t.\tID=query_3;Name=test1.3\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 f.write("chr1\tquery\ttest1.4\t925\t1025\t101\t+\t.\tID=query_4;Name=test1.4\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 f.write("chr1\tquery\ttest1.5\t1201\t1210\t10\t+\t.\tID=query_5;Name=test1.5\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 f.write("chr1\tquery\ttest1.6\t1500\t1600\t101\t+\t.\tID=query_6;Name=test1.6\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 def _writeExpDefaultOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 f.write("chr1\tS-MART\ttest1.1\t25\t150\t126\t+\t.\twigValue=1.64285714286;ID=query_1;Name=test1.1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 f.write("chr1\tS-MART\ttest1.2\t70\t850\t781\t-\t.\twigValue=1.48911651729;ID=query_2;Name=test1.2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 f.write("chr1\tS-MART\ttest1.3\t550\t850\t201\t-\t.\twigValue=2.0;ID=query_3;Name=test1.3\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 f.write("chr1\tS-MART\ttest1.4\t925\t1025\t101\t+\t.\twigValue=1.0;ID=query_4;Name=test1.4\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 f.write("chr1\tS-MART\ttest1.5\t1201\t1210\t10\t+\t.\twigValue=1.0;ID=query_5;Name=test1.5\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 f.write("chr1\tS-MART\ttest1.6\t1500\t1600\t101\t+\t.\twigValue=1.0;ID=query_6;Name=test1.6\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 def _writeExpStransOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 f.write("chr1\tS-MART\ttest1.1\t25\t150\t126\t+\t.\twigValue=0.0;ID=query_1;Name=test1.1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 f.write("chr1\tS-MART\ttest1.2\t70\t850\t781\t-\t.\twigValue=0.0;ID=query_2;Name=test1.2\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 f.write("chr1\tS-MART\ttest1.3\t550\t850\t201\t-\t.\twigValue=0.0;ID=query_3;Name=test1.3\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 f.write("chr1\tS-MART\ttest1.4\t925\t1025\t101\t+\t.\twigValue=0.0;ID=query_4;Name=test1.4\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 f.write("chr1\tS-MART\ttest1.5\t1201\t1210\t10\t+\t.\twigValue=0.0;ID=query_5;Name=test1.5\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 f.write("chr1\tS-MART\ttest1.6\t1500\t1600\t101\t+\t.\twigValue=0.0;ID=query_6;Name=test1.6\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 unittest.main()