def test_kraken_classify(mocks, kraken, db, in_bam): out_reads = util.file.mkstempfname('.reads.txt') kraken.classify(in_bam, db, out_reads) args = mocks['check_call'].call_args[0][0] assert 'kraken' == os.path.basename(args[0]) assert util.misc.list_contains(['--db', db], args) assert util.misc.list_contains(['--output', out_reads], args) assert util.misc.list_contains(['--threads', str(_CPUS)], args)
def test_kraken_tool(tmpdir, kraken, kraken_db, input_bam): outdir = tempfile.mkdtemp('-kraken') out = join(outdir, 'zaire_ebola.kraken') out_filtered = join(outdir, 'zaire_ebola.filtered-kraken') out_report = join(outdir, 'zaire_ebola.kraken-report') kraken.classify(input_bam, kraken_db, out) kraken.filter(out, kraken_db, out_filtered, 0.05) kraken.report(out_filtered, kraken_db, out_report) assert os.path.getsize(out_report) > 0 assert os.path.getsize(out_filtered) > 0
def test_classify_num_threads(mocks, kraken, db, in_bam): out_reads = util.file.mkstempfname('.reads.txt') kraken.classify(in_bam, db, out_reads) args = mocks['check_call'].call_args[0][0] assert 'kraken' == os.path.basename(args[0]) assert '--threads' in args actual = args[args.index('--threads')+1] assert actual == str(_CPUS) for requested in (1,2,3,8,11,20): expected = min(_CPUS, requested) kraken.classify(in_bam, db, out_reads, numThreads=requested) args = mocks['check_call'].call_args[0][0] assert 'kraken' == os.path.basename(args[0]) assert '--threads' in args actual = args[args.index('--threads')+1] assert actual == str(expected), "failure for requested %s, expected %s, actual %s" % (requested, expected, actual)
def test_kraken_tool(tmpdir, kraken, kraken_db, input_fastqs): outdir = tempfile.mkdtemp('-kraken') out = join(outdir, 'zaire_ebola.kraken') out_filtered = join(outdir, 'zaire_ebola.filtered-kraken') out_report = join(outdir, 'zaire_ebola.kraken-report') assert kraken.classify(kraken_db, input_fastqs, out).returncode == 0 result = kraken.execute( 'kraken-filter', kraken_db, out_filtered, [out], options={'--threshold': 0.05}) assert result.returncode == 0 result = kraken.execute( 'kraken-report', kraken_db, out_report, [out_filtered]) assert result.returncode == 0 assert os.path.getsize(out_report) > 0 assert os.path.getsize(out_filtered) > 0
def test_kraken_tool(tmpdir, kraken, kraken_db, input_fastqs): outdir = tempfile.mkdtemp('-kraken') out = join(outdir, 'zaire_ebola.kraken') out_filtered = join(outdir, 'zaire_ebola.filtered-kraken') out_report = join(outdir, 'zaire_ebola.kraken-report') assert kraken.classify(kraken_db, input_fastqs, out).returncode == 0 result = kraken.execute('kraken-filter', kraken_db, out_filtered, [out], options={'--threshold': 0.05}) assert result.returncode == 0 result = kraken.execute('kraken-report', kraken_db, out_report, [out_filtered]) assert result.returncode == 0 assert os.path.getsize(out_report) > 0 assert os.path.getsize(out_filtered) > 0