18
|
1 import unittest
|
|
2 from commons.launcher.BlatProgramLauncher import BlatProgramLauncher
|
|
3
|
|
4
|
|
5 class Test_BlatProgramLauncher( unittest.TestCase ):
|
|
6
|
|
7 def setUp( self ):
|
|
8 self._i = BlatProgramLauncher()
|
|
9
|
|
10
|
|
11 def tearDown( self ):
|
|
12 self._i = None
|
|
13
|
|
14
|
|
15 def test_getHelpAsString( self ):
|
|
16 exp = ""
|
|
17 exp += "usage: BlatProgramLauncher.py [options]"
|
|
18 exp += "\ngeneric options:"
|
|
19 exp += "\n -h: this help"
|
|
20 exp += "\n -i: name of the input file (format='fasta')"
|
|
21 exp += "\n -c: clean"
|
|
22 exp += "\n -v: verbosity level (default=0/1)"
|
|
23 exp += "\nspecific options:"
|
|
24 exp += "\n -s: name of the subject file (database, format='fasta')"
|
|
25 exp += "\n -p: parameters for 'blat'"
|
|
26 exp += "\n -A: same sequences (all-by-all)"
|
|
27 exp += "\n -o: name of the output file (format='align', default=inFile+'.align')"
|
|
28 obs = self._i.getHelpAsString()
|
|
29 self.assertEqual( exp, obs )
|
|
30
|
|
31
|
|
32 def test_setAttributesFromCmdLine( self ):
|
|
33 self._i.setAttributesFromCmdLine( "-s", "dummySubjectFile.fa" )
|
|
34 self.assertEqual( "dummySubjectFile.fa", self._i.getSubjectFile() )
|
|
35
|
|
36 self._i.setAttributesFromCmdLine( "-o", "dummyOutFile.align" )
|
|
37 self.assertEqual( "dummyOutFile.align", self._i.getOutputFile() )
|
|
38
|
|
39
|
|
40 def test_setWrapperCommandLine( self ):
|
|
41 self._i.setInputFile( "dummyInFile.fa" )
|
|
42 self._i.setSubjectFile( "dummySubjectFile.fa" )
|
|
43 exp = "BlatProgramLauncher.py"
|
|
44 exp += " -i %s" % ( "dummyInFile.fa" )
|
|
45 exp += " -s %s" % ( "dummySubjectFile.fa" )
|
|
46 exp += " -o %s.align" % ( "dummyInFile.fa" )
|
|
47 exp += " -v 0"
|
|
48 self._i.setWrapperCommandLine()
|
|
49 obs = self._i.getWrapperCommandLine()
|
|
50 self.assertEqual( exp, obs )
|
|
51
|
|
52
|
|
53 def test_setProgramCommandLine( self ):
|
|
54 self._i.setInputFile( "dummyInFile.fa" )
|
|
55 self._i.setSubjectFile( "dummySubjectFile.fa" )
|
|
56 self._i.setProgramParameters( "-minIdentity=90" )
|
|
57 exp = "blat dummySubjectFile.fa dummyInFile.fa -minIdentity=90 -out=blast8 dummyInFile.fa.blast"
|
|
58 self._i.setProgramCommandLine()
|
|
59 obs = self._i.getProgramCommandLine()
|
|
60 self.assertEqual( exp, obs )
|
|
61
|
|
62
|
|
63 def test_setListFilesToKeep( self ):
|
|
64 self._i.setInputFile( "dummyInFile.fa" )
|
|
65 lExp = [ "dummyInFile.fa.align" ]
|
|
66 self._i.setListFilesToKeep()
|
|
67 lObs = self._i.getListFilesToKeep()
|
|
68 lExp.sort()
|
|
69 lObs.sort()
|
|
70 self.assertEqual( lExp, lObs )
|
|
71
|
|
72
|
|
73 def test_setListFilesToRemove( self ):
|
|
74 self._i.setInputFile( "dummyInFile.fa" )
|
|
75 lExp = [ "dummyInFile.fa.blast" ]
|
|
76 self._i.setListFilesToRemove()
|
|
77 lObs = self._i.getListFilesToRemove()
|
|
78 lExp.sort()
|
|
79 lObs.sort()
|
|
80 self.assertEqual( lExp, lObs )
|
|
81
|
|
82
|
|
83 def test_setSummary( self ):
|
|
84 self._i.setInputFile( "dummyInFile.fa" )
|
|
85 self._i.setSubjectFile( "dummySubjectFile.fa" )
|
|
86 exp = "input file: %s" % ( self._i.getInputFile() )
|
|
87 exp += "\nsubject file: %s" % ( self._i.getSubjectFile() )
|
|
88 exp += "\nparameters: %s" % ( self._i.getProgramParameters() )
|
|
89 exp += "\noutput file: %s" % ( "dummyInFile.fa.align" )
|
|
90 self._i.setSummary()
|
|
91 obs = self._i.getSummary()
|
|
92 self.assertEqual( exp, obs )
|
|
93
|
|
94
|
|
95 test_suite = unittest.TestSuite()
|
|
96 test_suite.addTest( unittest.makeSuite( Test_BlatProgramLauncher ) )
|
|
97 if __name__ == "__main__":
|
|
98 unittest.TextTestRunner(verbosity=2).run( test_suite )
|