annotate SMART/Java/Python/test/Test_F_findTss.py @ 22:1e3f2c2657a3

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:26:07 -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
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 TestF_PATH = os.environ['REPET_PATH'] + '/SMART/Java/Python/TestFiles'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 class Test_F_findTss(unittest.TestCase):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 def setUp(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._outputFileName = 'output.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._expOutputFileName = 'expOutput.gff3'
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 os.remove(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 os.remove(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 def test_run_default_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 cmd = "python ../findTss.py -i %s/mapperAnalyzerExpected.gff3 -f gff3 -o output.gff3 -v 0" % TestF_PATH
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 self._writeExpDefaultOption(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 def test_run_normalize_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 cmd = "python ../findTss.py -i %s/mapperAnalyzerExpected.gff3 -f gff3 -o output.gff3 -n -v 0" % TestF_PATH
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 self._writeExpNormalizeOption(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 def test_run_distance_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 cmd = "python ../findTss.py -i %s/mapperAnalyzerExpected.gff3 -f gff3 -o output.gff3 -d 20 -v 0" % TestF_PATH
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 self._writeExpDistance_option(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 def test_run_colinear_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 cmd = "python ../findTss.py -i %s/mapperAnalyzerExpected.gff3 -f gff3 -o output.gff3 -e -v 0" % TestF_PATH
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 self._writeExpColinearOption(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 def test_run_excel_option(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 cmd = "python ../findTss.py -i %s/mapperAnalyzerExpected.gff3 -f gff3 -o output.gff3 -c output.csv -v 0" % TestF_PATH
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 obsCsv = 'output.csv'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 self.assertTrue(os.path.exists(obsCsv))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 os.remove(obsCsv)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 self._writeExpExcelOption(self._expOutputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 self.assertTrue(Utils.diff(self._expOutputFileName, self._outputFileName))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 def _writeExpDefaultOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 f.write("chr1\tS-MART\tmatch\t6155418\t6155418\t24\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=test1/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 f.write("chr2\tS-MART\tmatch\t26303950\t26303950\t32\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 f.write("chr3\tS-MART\tmatch\t28320540\t28320540\t35\t+\t.\toccurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 f.write("chr4\tS-MART\tmatch\t28565007\t28565007\t35\t+\t.\toccurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 def _writeExpNormalizeOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 f.write("chr1\tS-MART\tmatch\t6155418\t6155418\t24\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=test1/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 f.write("chr2\tS-MART\tmatch\t26303950\t26303950\t32\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 f.write("chr3\tS-MART\tmatch\t28320540\t28320540\t35\t+\t.\toccurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 f.write("chr4\tS-MART\tmatch\t28565007\t28565007\t35\t+\t.\toccurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 def _writeExpDistance_option(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 f.write("chr1\tS-MART\tmatch\t6155418\t6155418\t24\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=test1/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 f.write("chr2\tS-MART\tmatch\t26303950\t26303950\t32\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 f.write("chr3\tS-MART\tmatch\t28320540\t28320540\t35\t+\t.\toccurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 f.write("chr4\tS-MART\tmatch\t28565007\t28565007\t35\t+\t.\toccurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 def _writeExpColinearOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 f.write("chr1\tS-MART\tmatch\t6155418\t6155418\t24\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=test1/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 f.write("chr2\tS-MART\tmatch\t26303950\t26303950\t32\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 f.write("chr3\tS-MART\tmatch\t28320540\t28320540\t35\t+\t.\toccurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 f.write("chr4\tS-MART\tmatch\t28565007\t28565007\t35\t+\t.\toccurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 def _writeExpExcelOption(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
86 f.write("chr1\tS-MART\tmatch\t6155418\t6155418\t24\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=test1/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
87 f.write("chr2\tS-MART\tmatch\t26303950\t26303950\t32\t+\t.\toccurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
88 f.write("chr3\tS-MART\tmatch\t28320540\t28320540\t35\t+\t.\toccurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
89 f.write("chr4\tS-MART\tmatch\t28565007\t28565007\t35\t+\t.\toccurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=test2/1\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
90 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
91
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
92 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
93 unittest.main()