def test_out_reads(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') metagenomics.kraken(self.inBam, self.db, outReads=out_reads) self.mock_samtofastq().execute.assert_called_once_with( self.inBam, mock.ANY, mock.ANY, picardOptions=mock.ANY, JVMmemory=mock.ANY) picard_opts = self.mock_samtofastq( ).execute.call_args[1]['picardOptions'] six.assertCountEqual(self, picard_opts, [ 'CLIPPING_ACTION=X', 'CLIPPING_ATTRIBUTE=%s' % tools.picard.SamToFastqTool.illumina_clipping_attribute ]) self.mock_kraken().classify.assert_called_once_with(self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, }) # Exists due to test. Need a better tmpfile patcher. self.assertTrue(os.path.isfile(out_reads))
def test_num_threads(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') metagenomics.kraken(self.inBam, self.db, outReads=out_reads, numThreads=11) self.mock_kraken().classify.assert_called_once_with( self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': min(util.misc.available_cpu_count(), 11), })
def test_out_reads_and_report(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') out_report = util.file.mkstempfname('.kraken_report.txt') metagenomics.kraken(self.inBam, self.db, outReads=out_reads, outReport=out_report) self.mock_kraken().classify.assert_called_once_with( self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, }) self.mock_kraken().execute.assert_called_with( 'kraken-report', self.db, out_report, args=[mock.ANY])
def test_filter_threshold(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') metagenomics.kraken(self.inBam, self.db, outReads=out_reads, filterThreshold=0.05) self.mock_kraken().execute.assert_called_with( 'kraken-filter', self.db, mock.ANY, args=[mock.ANY], options={ '--threshold': 0.05 }) self.mock_kraken().classify.assert_called_once_with( self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, })
def test_out_report(self): out_report = util.file.mkstempfname('.kraken_report.txt') metagenomics.kraken(self.inBam, self.db, outReport=out_report) self.mock_kraken().classify.assert_called_once_with(self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, }) self.mock_kraken().execute.assert_called_with('kraken-report', self.db, out_report, args=[mock.ANY])
def test_filter_threshold(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') metagenomics.kraken(self.inBam, self.db, outReads=out_reads, filterThreshold=0.05) self.mock_kraken().execute.assert_called_with( 'kraken-filter', self.db, mock.ANY, args=[mock.ANY], options={'--threshold': 0.05}) self.mock_kraken().classify.assert_called_once_with(self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, })
def test_out_reads(self): out_reads = util.file.mkstempfname('.kraken_reads.gz') metagenomics.kraken(self.inBam, self.db, outReads=out_reads) self.mock_samtofastq().execute.assert_called_once_with( self.inBam, mock.ANY, mock.ANY, picardOptions=mock.ANY, JVMmemory=mock.ANY) picard_opts = self.mock_samtofastq().execute.call_args[1]['picardOptions'] six.assertCountEqual( self, picard_opts, ['CLIPPING_ACTION=X', 'CLIPPING_ATTRIBUTE=%s' % tools.picard.SamToFastqTool.illumina_clipping_attribute]) self.mock_kraken().classify.assert_called_once_with( self.db, mock.ANY, mock.ANY, options={ '--paired': None, '--threads': 1, }) # Exists due to test. Need a better tmpfile patcher. self.assertTrue(os.path.isfile(out_reads))
def test_assert(self): with self.assertRaises(AssertionError): metagenomics.kraken(self.inBam, self.db)