Exemplo n.º 1
0
 def test_run_bowtie_with_overide(self, env_mock, path_mock, run_mock,
                                  version_mock, logging_mock):
     fake_env_variables = {
         'SRST2_SAMTOOLS': '/usr/bin/samtools',
         'SRST2_BOWTIE2': '/usr/bin/bowtie2',
         'SRST2_BOWTIE2_BUILD': '/usr/bin/bowtie2-build'
     }
     env_mock.get.side_effect = fake_env_variables.get
     path_mock.isfile.side_effect = lambda f: 'missing' not in f
     arg_mock = MagicMock()
     arg_mock.read_type = 'foo'
     arg_mock.stop_after = False
     arg_mock.other = False
     arg_mock.threads = 4
     arg_mock.use_existing_bowtie2_sam = False
     actual_sam = srst2.run_bowtie('mapping_file', 'sample', ['fastq'],
                                   arg_mock, 'db_name', 'db_path')
     self.assertEqual(actual_sam, 'mapping_file.sam')
     self.assertEqual(version_mock.call_count, 2)
     self.assertEqual(version_mock.call_args_list[0][0][0],
                      ['/usr/bin/bowtie2', '--version'])
     self.assertEqual(version_mock.call_args_list[1][0][0],
                      ['/usr/bin/samtools'])
     expected_bowtie2_command = [
         '/usr/bin/bowtie2', '-U', 'fastq', '-S', 'mapping_file.sam',
         '-foo', '--very-sensitive-local', '--no-unal', '-a', '-x',
         'db_path', '--threads', '4'
     ]
     run_mock.assert_called_once_with(expected_bowtie2_command)
Exemplo n.º 2
0
	def test_run_bowtie_with_defaults(self, env_mock, path_mock, run_mock,
									  version_mock, logging_mock):
		fake_env_variables = {}
		env_mock.get.side_effect = fake_env_variables.get
		path_mock.isfile.side_effect = lambda f: 'missing' not in f
		arg_mock = MagicMock()
		arg_mock.read_type = 'foo'
		arg_mock.stop_after = False
		arg_mock.other = False
		arg_mock.threads = 4
		arg_mock.use_existing_bowtie2_sam = False
		actual_sam = srst2.run_bowtie('mapping_file', 'sample', ['fastq'], arg_mock,
									  'db_name', 'db_path')
		self.assertEqual(actual_sam, 'mapping_file.sam')
		self.assertEqual(version_mock.call_count, 2)
		self.assertEqual(version_mock.call_args_list[0][0][0], ['bowtie2',
														'--version'])
		self.assertEqual(version_mock.call_args_list[1][0][0], ['samtools'])
		expected_bowtie2_command = [
			'bowtie2',
			'-U', 'fastq',
			'-S', 'mapping_file.sam',
			'-foo',
			'--very-sensitive-local',
			'--no-unal',
			'-a',
			'-x', 'db_path',
			'--threads', '4'
		]
		run_mock.assert_called_once_with(expected_bowtie2_command)
Exemplo n.º 3
0
 def test_run_bowtie_with_defaults(self, env_mock, path_mock, run_mock,
                                   version_mock, logging_mock):
     fake_env_variables = {}
     env_mock.get.side_effect = fake_env_variables.get
     path_mock.isfile.side_effect = lambda f: 'missing' not in f
     arg_mock = MagicMock()
     arg_mock.read_type = 'foo'
     arg_mock.stop_after = False
     arg_mock.other = False
     actual_sam = srst2.run_bowtie('mapping_file', 'sample', ['fastq'],
                                   arg_mock, 'db_name', 'db_path')
     self.assertEqual(actual_sam, 'mapping_file.sam')
     self.assertEqual(version_mock.call_count, 2)
     self.assertEqual(version_mock.call_args_list[0][0][0],
                      ['bowtie2', '--version'])
     self.assertEqual(version_mock.call_args_list[1][0][0], ['samtools'])
     expected_bowtie2_command = [
         'bowtie2', '-U', 'fastq', '-S', 'mapping_file.sam', '-foo',
         '--very-sensitive-local', '--no-unal', '-a', '-x', 'db_path'
     ]
     run_mock.assert_called_once_with(expected_bowtie2_command)