annotate SMART/Java/Python/test/Test_F_mergeSlidingWindowsClusters.py @ 25:7809e72960fe

Deleted selected files
author m-zytnicki
date Mon, 29 Apr 2013 03:29:14 -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
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 from SMART.Java.Python.mergeSlidingWindowsClusters import MergeSlidingWindowsClusters
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 from SMART.Java.Python.misc import Utils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 class Test_F_mergeSlidingWindowsClusters(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._outputFileName = 'outputMSWC'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 self._inputFileName1 = 'inputMSWC1.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 self._inputFileName2 = 'inputMSWC2.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 self._writeInput1(self._inputFileName1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 self._writeInput2(self._inputFileName2)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 self._expOutput = 'expOutputMSWC.gff3'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 self._writeExpOutput(self._expOutput)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 def tearDown(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 os.remove(self._inputFileName1)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 os.remove(self._inputFileName2)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 os.remove(self._outputFileName+'.gff3')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 os.remove(self._expOutput)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 def test_run(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 iMSWC = MergeSlidingWindowsClusters(0)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 iMSWC.addInput(self._inputFileName1, 'gff3')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 iMSWC.addInput(self._inputFileName2, 'gff3')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 iMSWC.setOutput(self._outputFileName)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 iMSWC.merge()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 self.assertTrue(Utils.diff(self._outputFileName+'.gff3', self._expOutput))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 def test_run_asScript(self):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 cmd = 'python ../mergeSlidingWindowsClusters.py -i %s -f gff3 -j %s -g gff3 -o outputMSWC.gff3 --galaxy -v 0' % (self._inputFileName1, self._inputFileName2)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 os.system(cmd)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 self.assertTrue(Utils.diff(self._outputFileName+'.gff3', self._expOutput))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 def _writeInput1(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 f.write("chr1\ttest\tmatch\t6155418\t6155441\t24\t+\t.\tName=test1/1;occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 f.write("chr2\ttest\tmatch\t26303950\t26303981\t32\t+\t.\tName=test2/1;occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 f.write("chr3\ttest\tmatch\t28320540\t28320574\t35\t+\t.\tName=test2/1;occurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 f.write("chr4\ttest\tmatch\t28565007\t28565041\t35\t+\t.\tName=test2/1;occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 f.write("chr6\ttest\tmatch\t48565007\t48565041\t35\t+\t.\tName=test2/1;occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=3;ID=test2/1-4;identity=80\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 def _writeInput2(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 f.write("chr1\ttest\tmatch\t6155418\t6155441\t24\t+\t.\tName=test1/1;occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 f.write("chr2\ttest\tmatch\t26303990\t26304021\t32\t+\t.\tName=test2/1;occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 f.write("chr3\ttest\tmatch\t28320540\t28320574\t35\t+\t.\tName=test2/1;occurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 f.write("chr4\ttest\tmatch\t28565017\t28565051\t35\t+\t.\tName=test2/1;occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 f.write("chr5\ttest\tmatch\t30000000\t30000050\t50\t+\t.\tName=test3/1;occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=1;ID=test3/1-4;identity=50\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 _writeExpOutput(self, fileName):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 f = open(fileName, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 f.write("""chr6 S-MART match 48565007 48565041 35 + . occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=3;ID=test2/1-4;identity=80;Name=region_1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 chr5 S-MART match 30000000 30000050 50 + . occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=1;ID=test3/1-4;identity=50;Name=region_2
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 chr4 S-MART match 28565017 28565051 35 + . occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=region_3
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 chr4 S-MART match 28565007 28565041 35 + . occurrence=3;rank=3;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88;Name=region_4
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 chr3 S-MART match 28320540 28320574 35 + . occurrence=2;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94;Name=region_5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 chr2 S-MART match 26303990 26304021 32 + . occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=region_6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 chr2 S-MART match 26303950 26303981 32 + . occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93;Name=region_7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 chr1 S-MART match 6155418 6155441 24 + . occurrence=1;rank=1;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100;Name=region_8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 """)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 # f.write("chr6\tS-MART\tmatch\t48565007\t48565041\t35\t+\t.\tName=region_1;occurrence=3;feature=match;rank=3;score=35;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=3;ID=test2/1-4;identity=80\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 # f.write("chr5\tS-MART\tmatch\t30000000\t30000050\t50\t+\t.\tName=region_2;occurrence=3;feature=match;rank=3;score=50;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=1;ID=test3/1-4;identity=50\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 # f.write("chr4\tS-MART\tmatch\t28565017\t28565051\t35\t+\t.\tName=region_3;occurrence=3;feature=match;rank=3;score=35;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 # f.write("chr4\tS-MART\tmatch\t28565007\t28565041\t35\t+\t.\tName=region_4;occurrence=3;feature=match;rank=3;score=35;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=4;ID=test2/1-3;identity=88\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 # f.write("chr3\tS-MART\tmatch\t28320540\t28320574\t35\t+\t.\tName=region_5;occurrence=2;feature=match;score=35;bestRegion=chr2:26303950-26303981;nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-2;identity=94\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 # f.write("chr2\tS-MART\tmatch\t26303990\t26304021\t32\t+\t.\tName=region_6;occurrence=1;feature=match;rank=1;score=32;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 # f.write("chr2\tS-MART\tmatch\t26303950\t26303981\t32\t+\t.\tName=region_7;occurrence=1;feature=match;rank=1;score=32;bestRegion=(self);nbGaps=0;nbOccurrences=3;nbMismatches=2;ID=test2/1-1;identity=93\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 # f.write("chr1\tS-MART\tmatch\t6155418\t6155441\t24\t+\t.\tName=region_8;occurrence=1;feature=match;rank=1;score=24;bestRegion=(self);nbGaps=0;nbOccurrences=1;nbMismatches=0;ID=test1/1;identity=100\n")
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 f.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 unittest.main()