Mercurial > repos > yufei-luo > s_mart
diff commons/launcher/tests/Test_MafftProgramLauncher.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commons/launcher/tests/Test_MafftProgramLauncher.py Mon Apr 29 03:20:15 2013 -0400 @@ -0,0 +1,105 @@ +import unittest +from commons.launcher.MafftProgramLauncher import MafftProgramLauncher + +class Test_MafftProgramLauncher( unittest.TestCase ): + + + def setUp( self ): + self._i = MafftProgramLauncher() + + + def tearDown( self ): + self._i = None + + + def test_getSpecificHelpAsString( self ): + exp = "" + exp += "\nspecific options:" + exp += "\n -p: parameters for '%s' (default='--auto')" % ( "mafft" ) + exp += "\n -o: name of the output file (format='aligned fasta', default=inFile+'.fa_aln')" + obs = self._i.getSpecificHelpAsString() + self.assertEqual( exp, obs ) + + + def test_setASpecificAttributeFromCmdLine( self ): + self._i.setASpecificAttributeFromCmdLine( "-p", "'--auto --maxiterate 500'" ) + self.assertEqual( "'--auto --maxiterate 500'", self._i.getProgramParameters() ) + + self._i.setASpecificAttributeFromCmdLine( "-o", "dummyOutFile.fa_aln" ) + self.assertEqual( "dummyOutFile.fa_aln", self._i.getOutputFile() ) + + + def test_setWrapperCommandLine( self ): + inFile = "dummyInFile.fa" + self._i.setInputFile( inFile ) + exp = "MafftProgramLauncher.py" + exp += " -i %s" % ( inFile ) + exp += " -p '%s'" % ( "--auto" ) + exp += " -o %s.fa_aln" % ( inFile ) + exp += " -v 0" + self._i.setWrapperCommandLine() + obs = self._i.getWrapperCommandLine() + self.assertEqual( exp, obs ) + + + def test_setProgramCommandLine( self ): + inFile = "dummyInFile.fa" + self._i.setInputFile( inFile ) + exp = self._i.getProgramName() + exp += " %s" % ( "--auto" ) + exp += " --quiet" + exp += " %s.shortH" % ( inFile ) + exp += " > %s.shortH.fa_aln" % ( inFile ) + exp += " 2> /dev/null" + self._i.setProgramCommandLine() + obs = self._i.getProgramCommandLine() + self.assertEqual( exp, obs ) + + + def test_setListFilesToKeep( self ): + inFile = "dummyInFile.fa" + self._i.setInputFile( inFile ) + self._i.setListFilesToKeep() + lExp = [ "dummyInFile.fa.fa_aln" ] + lObs = self._i.getListFilesToKeep() + lExp.sort() + lObs.sort() + self.assertEqual( lExp, lObs ) + + self._i._lFilesToKeep = [] + + outFile = "dummyOutFile.fa_aln" + self._i.setOutputFile( outFile ) + self._i.setListFilesToKeep() + lExp = [ outFile ] + lObs = self._i.getListFilesToKeep() + lExp.sort() + lObs.sort() + self.assertEqual( lExp, lObs ) + + + def test_setListFilesToRemove( self ): + inFile = "dummyInFile.fa" + self._i.setInputFile( inFile ) + self._i.setListFilesToRemove() + lExp = [ "dummyInFile.fa.shortH", \ + "dummyInFile.fa.shortH.fa_aln", \ + "dummyInFile.fa.shortHlink" ] + lObs = self._i.getListFilesToRemove() + lExp.sort() + lObs.sort() + self.assertEqual( lExp, lObs ) + + + def test_setSummary( self ): + self._i.setInputFile( "dummyInFile.fa" ) + exp = "input file: %s" % ( "dummyInFile.fa" ) + exp += "\nparameters: %s" % ( "--auto" ) + exp += "\noutput file: %s" % ( "dummyInFile.fa.fa_aln" ) + self._i.setSummary() + obs = self._i.getSummary() + self.assertEqual( exp, obs ) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file