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

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