annotate commons/launcher/tests/Test_MafftProgramLauncher.py @ 31:0ab839023fe4

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