Mercurial > repos > yufei-luo > s_mart
view commons/launcher/tests/Test_MafftProgramLauncher.py @ 31:0ab839023fe4
Uploaded
author | m-zytnicki |
---|---|
date | Tue, 30 Apr 2013 14:33:21 -0400 |
parents | 94ab73e8a190 |
children |
line wrap: on
line source
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()