18
|
1 import unittest
|
|
2 from commons.launcher.MafftProgramLauncher import MafftProgramLauncher
|
|
3
|
|
4 class Test_MafftProgramLauncher( unittest.TestCase ):
|
|
5
|
|
6
|
|
7 def setUp( self ):
|
|
8 self._i = MafftProgramLauncher()
|
|
9
|
|
10
|
|
11 def tearDown( self ):
|
|
12 self._i = None
|
|
13
|
|
14
|
|
15 def test_getSpecificHelpAsString( self ):
|
|
16 exp = ""
|
|
17 exp += "\nspecific options:"
|
|
18 exp += "\n -p: parameters for '%s' (default='--auto')" % ( "mafft" )
|
|
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
|
|
24 def test_setASpecificAttributeFromCmdLine( self ):
|
|
25 self._i.setASpecificAttributeFromCmdLine( "-p", "'--auto --maxiterate 500'" )
|
|
26 self.assertEqual( "'--auto --maxiterate 500'", self._i.getProgramParameters() )
|
|
27
|
|
28 self._i.setASpecificAttributeFromCmdLine( "-o", "dummyOutFile.fa_aln" )
|
|
29 self.assertEqual( "dummyOutFile.fa_aln", self._i.getOutputFile() )
|
|
30
|
|
31
|
|
32 def test_setWrapperCommandLine( self ):
|
|
33 inFile = "dummyInFile.fa"
|
|
34 self._i.setInputFile( inFile )
|
|
35 exp = "MafftProgramLauncher.py"
|
|
36 exp += " -i %s" % ( inFile )
|
|
37 exp += " -p '%s'" % ( "--auto" )
|
|
38 exp += " -o %s.fa_aln" % ( inFile )
|
|
39 exp += " -v 0"
|
|
40 self._i.setWrapperCommandLine()
|
|
41 obs = self._i.getWrapperCommandLine()
|
|
42 self.assertEqual( exp, obs )
|
|
43
|
|
44
|
|
45 def test_setProgramCommandLine( self ):
|
|
46 inFile = "dummyInFile.fa"
|
|
47 self._i.setInputFile( inFile )
|
|
48 exp = self._i.getProgramName()
|
|
49 exp += " %s" % ( "--auto" )
|
|
50 exp += " --quiet"
|
|
51 exp += " %s.shortH" % ( inFile )
|
|
52 exp += " > %s.shortH.fa_aln" % ( inFile )
|
|
53 exp += " 2> /dev/null"
|
|
54 self._i.setProgramCommandLine()
|
|
55 obs = self._i.getProgramCommandLine()
|
|
56 self.assertEqual( exp, obs )
|
|
57
|
|
58
|
|
59 def test_setListFilesToKeep( self ):
|
|
60 inFile = "dummyInFile.fa"
|
|
61 self._i.setInputFile( inFile )
|
|
62 self._i.setListFilesToKeep()
|
|
63 lExp = [ "dummyInFile.fa.fa_aln" ]
|
|
64 lObs = self._i.getListFilesToKeep()
|
|
65 lExp.sort()
|
|
66 lObs.sort()
|
|
67 self.assertEqual( lExp, lObs )
|
|
68
|
|
69 self._i._lFilesToKeep = []
|
|
70
|
|
71 outFile = "dummyOutFile.fa_aln"
|
|
72 self._i.setOutputFile( outFile )
|
|
73 self._i.setListFilesToKeep()
|
|
74 lExp = [ outFile ]
|
|
75 lObs = self._i.getListFilesToKeep()
|
|
76 lExp.sort()
|
|
77 lObs.sort()
|
|
78 self.assertEqual( lExp, lObs )
|
|
79
|
|
80
|
|
81 def test_setListFilesToRemove( self ):
|
|
82 inFile = "dummyInFile.fa"
|
|
83 self._i.setInputFile( inFile )
|
|
84 self._i.setListFilesToRemove()
|
|
85 lExp = [ "dummyInFile.fa.shortH", \
|
|
86 "dummyInFile.fa.shortH.fa_aln", \
|
|
87 "dummyInFile.fa.shortHlink" ]
|
|
88 lObs = self._i.getListFilesToRemove()
|
|
89 lExp.sort()
|
|
90 lObs.sort()
|
|
91 self.assertEqual( lExp, lObs )
|
|
92
|
|
93
|
|
94 def test_setSummary( self ):
|
|
95 self._i.setInputFile( "dummyInFile.fa" )
|
|
96 exp = "input file: %s" % ( "dummyInFile.fa" )
|
|
97 exp += "\nparameters: %s" % ( "--auto" )
|
|
98 exp += "\noutput file: %s" % ( "dummyInFile.fa.fa_aln" )
|
|
99 self._i.setSummary()
|
|
100 obs = self._i.getSummary()
|
|
101 self.assertEqual( exp, obs )
|
|
102
|
|
103
|
|
104 if __name__ == "__main__":
|
|
105 unittest.main() |