def test_call_with_flags(self): """Sffinfo flags should alter output as expected.""" # -a flag a = Sffinfo() a.Parameters['-a'].on() app_results = a(self.sff_fp) observed = app_results['StdOut'].read() self.assertEqual(observed, 'FA6P1OK01CGMHQ\n') # -s flag a = Sffinfo() a.Parameters['-s'].on() app_results = a(self.sff_fp) observed = app_results['StdOut'].read() expected = ( '>FA6P1OK01CGMHQ length=48 xy=0892_1356 region=1 ' 'run=R_2008_05_28_17_11_38_\n' 'ATCTGAGCTGGGTCATAGCTGCCTCCGTAGGAGGTGCCTCCCTACGGC\n' ) self.assertEqual(observed, expected) # -q flag a = Sffinfo() a.Parameters['-q'].on() app_results = a(self.sff_fp) observed = app_results['StdOut'].read() expected = ( '>FA6P1OK01CGMHQ length=48 xy=0892_1356 region=1 ' 'run=R_2008_05_28_17_11_38_\n' '32 32 32 32 32 32 32 25 25 21 21 21 28 32 32 31 30 30 32 32 32 ' '33 31 25 18 18 20 18 32 30 28 23 22 22 24 28 18 19 18 16 16 16 ' '17 18 13 17 27 21\n') self.assertEqual(observed, expected) # -f flag a = Sffinfo() a.Parameters['-f'].on() app_results = a(self.sff_fp) observed = app_results['StdOut'].read() expected = ( '>FA6P1OK01CGMHQ xy=0892_1356 region=1 run=R_2008_05_28_17_11_38_\n' 'A,1.02 C,0.00 G,0.00 T,0.99 A,0.00 C,1.00 G,0.00 T,1.00 A,0.00 C,0.00\n' 'G,1.00 T,0.00 A,1.10 C,0.00 G,1.08 T,0.00 A,0.00 C,1.46 G,0.00 T,0.88\n' 'A,0.18 C,0.00 G,2.69 T,1.01 A,0.08 C,0.96 G,0.00 T,0.02 A,0.92 C,0.08\n' 'G,0.00 T,0.98 A,0.68 C,0.00 G,0.89 T,0.00 A,0.00 C,1.15 G,0.00 T,1.13\n' 'A,0.00 C,0.02 G,1.12 T,0.05 A,0.15 C,1.84 G,0.00 T,1.10 A,0.00 C,2.47\n' 'G,0.96 T,0.86 A,1.06 C,0.00 G,1.96 T,0.12 A,0.93 C,0.13 G,1.65 T,1.06\n' 'A,0.06 C,0.00 G,0.99 T,0.00 A,0.00 C,1.87 G,0.44 T,1.08 A,0.00 C,3.25\n' 'G,0.09 T,0.97 A,0.50 C,1.00 G,1.72 T,0.07 A,0.00 C,0.92 \n') self.assertEqual(observed, expected)
def test_call_with_accno(self): """Sffinfo accession number parameters should filter output.""" # Valid accession number a = Sffinfo() a.Parameters['accno'].on('FA6P1OK01CGMHQ') app_results = a(self.sff_fp) observed = app_results['StdOut'].read() self.assertEqual(observed, sffinfo_output) # Invalid accession number a = Sffinfo() a.Parameters['accno'].on('AAAAAAAAAAAAAA') app_results = a(self.sff_fp) observed = app_results['StdOut'].read() self.assertEqual(observed, empty_sffinfo_output)
def test_input_handler(self): """Sffinfo should decorate input handler output with accession numbers""" my_accno = '12345ABC' a = Sffinfo() a.Parameters['accno'].on(my_accno) self.assertEqual(a.InputHandler, '_input_handler_decorator') observed = getattr(a, a.InputHandler)(self.sff_fp) expected = '"%s" %s' % (self.sff_fp, my_accno) self.assertEqual(observed, expected)
def test_changing_working_dir(self): """WorkingDir should be created and included in BaseCommand.""" # Directory is not created, only filename is returned working_dir = tempfile.mktemp() self.assertRaises(OSError, os.rmdir, working_dir) a = Sffinfo(WorkingDir=working_dir) expected = 'cd "%s/"; sffinfo' % working_dir self.assertEqual(a.BaseCommand, expected) # Removing the directory is proof that it was created. If the # directory is not there, an OSError will be raised. os.rmdir(working_dir)
def test_base_command(self): """BaseCommand should include non-positional parameters.""" s = Sffinfo() expected = 'cd "%s/"; sffinfo' % os.getcwd() self.assertEqual(s.BaseCommand, expected) s.Parameters['-a'].on() expected = 'cd "%s/"; sffinfo -a' % os.getcwd() self.assertEqual(s.BaseCommand, expected) # accession number parameters should not be included in base command s.Parameters['-a'].off() s.Parameters['accno'].on('12345ABC') expected = 'cd "%s/"; sffinfo' % os.getcwd() self.assertEqual(s.BaseCommand, expected)
def test_call(self): """Simple sffinfo call should produce expected output.""" a = Sffinfo() app_results = a(self.sff_fp) observed = app_results['StdOut'].read() self.assertEqual(observed, sffinfo_output)