annotate commons/launcher/tests/Test_BlatProgramLauncher.py @ 18:94ab73e8a190

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