annotate commons/launcher/tests/Test_MapProgramLauncher.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
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 from commons.launcher.MapProgramLauncher import MapProgramLauncher
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 class Test_MapProgramLauncher( unittest.TestCase ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 def setUp( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 self._i = MapProgramLauncher()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 def tearDown( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 self._i = None
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 def test_getSpecificHelpAsString( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 exp = ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 exp += "\nspecific options:"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 exp += "\n -s: size above which a gap is not penalized anymore (default='%i')" % ( self._i.getGapSize() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 exp += "\n -m: penalty for a mismatch (default='%i', match=10)" % ( self._i.getMismatchPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 exp += "\n -O: penalty for a gap opening (default='%i')" % ( self._i.getGapOpenPenalty())
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 exp += "\n -e: penalty for a gap extension (default='%i')" % ( self._i.getGapExtendPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 exp += "\n -o: name of the output file (format='aligned fasta', default=inFile+'.fa_aln')"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 obs = self._i.getSpecificHelpAsString()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 self.assertEqual( exp, obs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 def test_setASpecificAttributeFromCmdLine( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 self._i.setASpecificAttributeFromCmdLine( "-s", "40" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 self.assertEqual( 40, self._i.getGapSize() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self._i.setASpecificAttributeFromCmdLine( "-m", "-7" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 self.assertEqual( -7, self._i.getMismatchPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 self._i.setASpecificAttributeFromCmdLine( "-O", "15" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 self.assertEqual( 15, self._i.getGapOpenPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 self._i.setASpecificAttributeFromCmdLine( "-e", "5" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 self.assertEqual( 5, self._i.getGapExtendPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 self._i.setASpecificAttributeFromCmdLine( "-o", "dummyOutFile.fa_aln" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 self.assertEqual( "dummyOutFile.fa_aln", self._i.getOutputFile() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 def test_setWrapperCommandLine( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 inFile = "dummyInFile.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 self._i.setInputFile( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 exp = "MapProgramLauncher.py"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 exp += " -i %s" % ( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 exp += " -s 50"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 exp += " -m -8"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 exp += " -O 16"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 exp += " -e 4"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 exp += " -o %s.fa_aln" % ( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 exp += " -v 0"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 self._i.setWrapperCommandLine()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 obs = self._i.getWrapperCommandLine()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 self.assertEqual( exp, obs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 def test_setProgramCommandLine( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 inFile = "dummyInFile.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 self._i.setInputFile( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 exp = self._i.getProgramName()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 exp += " %s.shortH" % ( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 exp += " 50"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 exp += " -8"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 exp += " 16"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62 exp += " 4"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63 exp += " > %s.shortH.fa_aln" % ( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 self._i.setProgramCommandLine()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 obs = self._i.getProgramCommandLine()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 self.assertEqual( exp, obs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 def test_setListFilesToKeep( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 inFile = "dummyInFile.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 self._i.setInputFile( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 self._i.setListFilesToKeep()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 lExp = [ "dummyInFile.fa.fa_aln" ]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73 lObs = self._i.getListFilesToKeep()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74 lExp.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 lObs.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 self.assertEqual( lExp, lObs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 self._i._lFilesToKeep = []
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
79
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
80 outFile = "dummyOutFile.fa_aln"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
81 self._i.setOutputFile( outFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
82 self._i.setListFilesToKeep()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
83 lExp = [ outFile ]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
84 lObs = self._i.getListFilesToKeep()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
85 lExp.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
86 lObs.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
87 self.assertEqual( lExp, lObs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
88
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
89 def test_getListFilesToRemove( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
90 inFile = "dummyInFile.fa"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
91 self._i.setInputFile( inFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
92 self._i.setListFilesToRemove()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
93 lExp = [ "dummyInFile.fa.shortH", \
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
94 "dummyInFile.fa.shortH.fa_aln", \
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
95 "dummyInFile.fa.shortHlink" ]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
96 lObs = self._i.getListFilesToRemove()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
97 lExp.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
98 lObs.sort()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
99 self.assertEqual( lExp, lObs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
100
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
101 def test_setSummary( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
102 self._i.setInputFile( "dummyInFile.fa" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
103 self._i.setGapSize( 104 )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
104 exp = "input file: %s" % ( "dummyInFile.fa" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
105 exp += "\ngap size: %i" % ( self._i.getGapSize() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
106 exp += "\nmismatch penalty: %i" % ( self._i.getMismatchPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
107 exp += "\ngap openning penalty: %i" % ( self._i.getGapOpenPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
108 exp += "\ngap extension penalty: %i" % ( self._i.getGapExtendPenalty() )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
109 exp += "\noutput file: %s" % ( "dummyInFile.fa.fa_aln" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
110 self._i.setSummary()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
111 obs = self._i.getSummary()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
112 self.assertEqual( exp, obs )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
113
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
114 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
115 unittest.main()