Mercurial > repos > yufei-luo > s_mart
view commons/launcher/tests/Test_MapProgramLauncher.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line source
import unittest from commons.launcher.MapProgramLauncher import MapProgramLauncher class Test_MapProgramLauncher( unittest.TestCase ): def setUp( self ): self._i = MapProgramLauncher() def tearDown( self ): self._i = None def test_getSpecificHelpAsString( self ): exp = "" exp += "\nspecific options:" exp += "\n -s: size above which a gap is not penalized anymore (default='%i')" % ( self._i.getGapSize() ) exp += "\n -m: penalty for a mismatch (default='%i', match=10)" % ( self._i.getMismatchPenalty() ) exp += "\n -O: penalty for a gap opening (default='%i')" % ( self._i.getGapOpenPenalty()) exp += "\n -e: penalty for a gap extension (default='%i')" % ( self._i.getGapExtendPenalty() ) 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( "-s", "40" ) self.assertEqual( 40, self._i.getGapSize() ) self._i.setASpecificAttributeFromCmdLine( "-m", "-7" ) self.assertEqual( -7, self._i.getMismatchPenalty() ) self._i.setASpecificAttributeFromCmdLine( "-O", "15" ) self.assertEqual( 15, self._i.getGapOpenPenalty() ) self._i.setASpecificAttributeFromCmdLine( "-e", "5" ) self.assertEqual( 5, self._i.getGapExtendPenalty() ) 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 = "MapProgramLauncher.py" exp += " -i %s" % ( inFile ) exp += " -s 50" exp += " -m -8" exp += " -O 16" exp += " -e 4" 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.shortH" % ( inFile ) exp += " 50" exp += " -8" exp += " 16" exp += " 4" exp += " > %s.shortH.fa_aln" % ( inFile ) 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_getListFilesToRemove( 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" ) self._i.setGapSize( 104 ) exp = "input file: %s" % ( "dummyInFile.fa" ) exp += "\ngap size: %i" % ( self._i.getGapSize() ) exp += "\nmismatch penalty: %i" % ( self._i.getMismatchPenalty() ) exp += "\ngap openning penalty: %i" % ( self._i.getGapOpenPenalty() ) exp += "\ngap extension penalty: %i" % ( self._i.getGapExtendPenalty() ) exp += "\noutput file: %s" % ( "dummyInFile.fa.fa_aln" ) self._i.setSummary() obs = self._i.getSummary() self.assertEqual( exp, obs ) if __name__ == "__main__": unittest.main()