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