def test_deplete_empty(self): myInputDir = util.file.get_test_input_path(self) empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') # Run deplete_human args = taxon_filter.parser_deplete_human(argparse.ArgumentParser()).parse_args( [ empty_bam, # output files os.path.join(self.tempDir, 'deplete-empty.bmtagger.bam'), os.path.join(self.tempDir, 'deplete-empty.rmdup.bam'), os.path.join(self.tempDir, 'deplete-empty.blastn.bam'), "--taxfiltBam", os.path.join(self.tempDir, 'deplete-empty.taxfilt.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--lastDb", self.lastdb_path, "--threads", "4" ] ) args.func_main(args) # Compare to expected for fname in [ 'deplete-empty.bmtagger.bam', 'deplete-empty.rmdup.bam', 'deplete-empty.blastn.bam', 'deplete-empty.taxfilt.bam' ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), empty_bam)
def test_deplete_human(self): myInputDir = util.file.get_test_input_path(self) # Run deplete_human args = taxon_filter.parser_deplete_human( argparse.ArgumentParser()).parse_args([ os.path.join(myInputDir, 'test-reads.bam'), # output files os.path.join(self.tempDir, 'test-reads.bmtagger.bam'), os.path.join(self.tempDir, 'test-reads.rmdup.bam'), os.path.join(self.tempDir, 'test-reads.blastn.bam'), "--taxfiltBam", os.path.join(self.tempDir, 'test-reads.taxfilt.imperfect.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--lastDb", self.lastdb_path, "--threads", "4" ]) args.func_main(args) # Compare to expected for fname in [ 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam', 'test-reads.taxfilt.imperfect.bam' ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), os.path.join(myInputDir, 'expected', fname))
def test_blastn_empty_input(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') out_bam = util.file.mkstempfname('-out.bam') taxon_filter.multi_db_deplete_bam(empty_bam, [self.blastdb_path], taxon_filter.deplete_blastn_bam, out_bam) assert_equal_bam_reads(self, out_bam, empty_bam)
def test_bmtagger_empty_input(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') out_bam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger(argparse.ArgumentParser()).parse_args([ empty_bam, self.database_prefix_path, out_bam, '--srprismMemory', '1500']) args.func_main(args) assert_equal_bam_reads(self, out_bam, empty_bam)
def test_deplete_human_aligned_input(self): myInputDir = util.file.get_test_input_path(self) # Run deplete_human args = taxon_filter.parser_deplete(argparse.ArgumentParser()).parse_args( [ os.path.join(myInputDir, 'test-reads-aligned.bam'), # output files os.path.join(self.tempDir, 'test-reads.revert.bam'), os.path.join(self.tempDir, 'test-reads.bwa.bam'), os.path.join(self.tempDir, 'test-reads.bmtagger.bam'), os.path.join(self.tempDir, 'test-reads.blastn.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--srprismMemory", '1500', ] ) args.func_main(args) # Compare to expected for fname in [ 'test-reads.revert.bam', 'test-reads.bwa.bam', 'test-reads.bmtagger.bam', 'test-reads.blastn.bam' ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), os.path.join(myInputDir, 'aligned-expected', fname))
def test_deplete_human(self): os.environ.pop('TMPDIR', None) util.file.set_tmp_dir(None) myInputDir = util.file.get_test_input_path(self) # Run deplete_human args = taxon_filter.parser_deplete_human( argparse.ArgumentParser()).parse_args([ os.path.join(myInputDir, 'test-reads.bam'), # output files os.path.join(self.tempDir, 'test-reads.bmtagger.bam'), os.path.join(self.tempDir, 'test-reads.rmdup.bam'), os.path.join(self.tempDir, 'test-reads.blastn.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--chunkSize", "0", "--srprismMemory", '1500', "--threads", str(_CPUS) ]) args.func_main(args) # Compare to expected for fname in [ 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam', ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), os.path.join(myInputDir, 'expected', fname))
def test_deplete_human_aligned_input(self): myInputDir = util.file.get_test_input_path(self) # Run deplete_human args = taxon_filter.parser_deplete_human(argparse.ArgumentParser()).parse_args( [ os.path.join(myInputDir, 'test-reads-aligned.bam'), # output files os.path.join(self.tempDir, 'test-reads.revert.bam'), os.path.join(self.tempDir, 'test-reads.bmtagger.bam'), os.path.join(self.tempDir, 'test-reads.rmdup.bam'), os.path.join(self.tempDir, 'test-reads.blastn.bam'), "--taxfiltBam", os.path.join(self.tempDir, 'test-reads.taxfilt.imperfect.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--lastDb", self.lastdb_path, "--threads", "4" ] ) args.func_main(args) # Compare to expected for fname in [ 'test-reads.revert.bam', 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam', 'test-reads.taxfilt.imperfect.bam' ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), os.path.join(myInputDir, 'aligned-expected', fname))
def test_deplete_empty(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') # Run deplete_human args = taxon_filter.parser_deplete(argparse.ArgumentParser()).parse_args( [ empty_bam, # output files os.path.join(self.tempDir, 'deplete-empty.revert.bam'), os.path.join(self.tempDir, 'deplete-empty.bwa.bam'), os.path.join(self.tempDir, 'deplete-empty.bmtagger.bam'), os.path.join(self.tempDir, 'deplete-empty.blastn.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--srprismMemory", '1500', ] ) args.func_main(args) # Compare to expected for fname in [ 'deplete-empty.bmtagger.bam', 'deplete-empty.blastn.bam', ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), empty_bam)
def test_deplete_human(self): myInputDir = util.file.get_test_input_path(self) # Run deplete_human args = taxon_filter.parser_deplete(argparse.ArgumentParser()).parse_args( [ os.path.join(myInputDir, 'test-reads.bam'), # output files os.path.join(self.tempDir, 'test-reads.revert.bam'), os.path.join(self.tempDir, 'test-reads.bwa.bam'), os.path.join(self.tempDir, 'test-reads.bmtagger.bam'), os.path.join(self.tempDir, 'test-reads.rmdup.bam'), os.path.join(self.tempDir, 'test-reads.blastn.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--chunkSize", "0", "--srprismMemory", '1500', ] ) args.func_main(args) # Compare to expected for fname in [ 'test-reads.revert.bam', 'test-reads.bwa.bam', 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam' ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), os.path.join(myInputDir, 'expected', fname))
def test_deplete_empty(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') # Run deplete_human args = taxon_filter.parser_deplete(argparse.ArgumentParser()).parse_args( [ empty_bam, # output files os.path.join(self.tempDir, 'deplete-empty.revert.bam'), os.path.join(self.tempDir, 'deplete-empty.bwa.bam'), os.path.join(self.tempDir, 'deplete-empty.bmtagger.bam'), os.path.join(self.tempDir, 'deplete-empty.rmdup.bam'), os.path.join(self.tempDir, 'deplete-empty.blastn.bam'), # DBs "--blastDbs", self.blastdb_path, "--bmtaggerDbs", self.database_prefix_path, "--srprismMemory", '1500', ] ) args.func_main(args) # Compare to expected for fname in [ 'deplete-empty.bmtagger.bam', 'deplete-empty.rmdup.bam', 'deplete-empty.blastn.bam', ]: assert_equal_bam_reads(self, os.path.join(self.tempDir, fname), empty_bam)
def test_lastal_unbuilt_db(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') in_bam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads-human.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') taxon_filter.filter_lastal_bam(in_bam, self.polio_fasta, outBam) assert_equal_bam_reads(self, outBam, empty_bam)
def test_filter_lastal_bam_polio(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.blastn.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') args = taxon_filter.parser_filter_lastal_bam(argparse.ArgumentParser()).parse_args([ inBam, self.lastdb_path, outBam]) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.taxfilt.imperfect.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_bmtagger_empty_input(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') out_bam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args( [empty_bam, self.database_prefix_path, out_bam]) args.func_main(args) assert_equal_bam_reads(self, out_bam, empty_bam)
def test_deplete_bmtagger_bam(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') outBam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger(argparse.ArgumentParser()).parse_args([ inBam, self.database_prefix_path, outBam, '--srprismMemory', '1500']) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_lastal_empty_input(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') taxon_filter.filter_lastal_bam( empty_bam, self.lastdb_path, outBam ) assert_equal_bam_reads(self, outBam, empty_bam)
def test_lastal_unbuilt_db(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') in_bam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads-human.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') taxon_filter.filter_lastal_bam( in_bam, self.polio_fasta, outBam ) assert_equal_bam_reads(self, outBam, empty_bam)
def test_deplete_bmtagger_tar_db(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') outBam = util.file.mkstempfname('-out.bam') tar_db_tgz = util.file.mkstempfname('.db.tar.gz') cmd = ['tar', '-C', os.path.dirname(self.database_prefix_path), '-cvzf', tar_db_tgz, '.'] subprocess.check_call(cmd) args = taxon_filter.parser_deplete_bam_bmtagger(argparse.ArgumentParser()).parse_args([ inBam, tar_db_tgz, outBam, '--srprismMemory', '1500']) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut) os.unlink(tar_db_tgz)
def test_bmtagger_empty_output(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') in_bam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads-human.bam') out_bam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args([ in_bam, self.database_prefix_path, out_bam, '--srprismMemory', '1500' ]) args.func_main(args) assert_equal_bam_reads(self, out_bam, empty_bam)
def test_deplete_bmtagger_bam(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') outBam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args( [inBam, self.database_prefix_path, outBam]) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_bmtagger_empty_input(self): os.environ.pop('TMPDIR', None) util.file.set_tmp_dir(None) empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') out_bam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args([ empty_bam, self.database_prefix_path, out_bam, '--srprismMemory', '1500' ]) args.func_main(args) assert_equal_bam_reads(self, out_bam, empty_bam)
def test_deplete_human(self): myInputDir = util.file.get_test_input_path(self) tempDir = tempfile.mkdtemp() ref_fasta = os.path.join(myInputDir, '5kb_human_from_chr6.fasta') database_prefix_path = os.path.join(tempDir, "5kb_human_from_chr6") # create blast db blastdb_path = tools.blast.MakeblastdbTool().build_database( ref_fasta, database_prefix_path) # create bmtagger db bmtooldb_path = tools.bmtagger.BmtoolTool().build_database( ref_fasta, database_prefix_path + ".bitmask") srprismdb_path = tools.bmtagger.SrprismTool().build_database( ref_fasta, database_prefix_path + ".srprism") # create last db lastdb_path = tools.last.Lastdb().build_database( ref_fasta, database_prefix_path) # Run deplete_human args = taxon_filter.parser_deplete_human( argparse.ArgumentParser()).parse_args([ os.path.join(myInputDir, 'test-reads.bam'), # output files os.path.join(tempDir, 'test-reads.revert.bam'), os.path.join(tempDir, 'test-reads.bmtagger.bam'), os.path.join(tempDir, 'test-reads.rmdup.bam'), os.path.join(tempDir, 'test-reads.blastn.bam'), "--taxfiltBam", os.path.join(tempDir, 'test-reads.taxfilt.bam'), # DBs "--blastDbs", blastdb_path, "--bmtaggerDbs", database_prefix_path, "--lastDb", lastdb_path, "--threads", "4" ]) args.func_main(args) # Compare to expected for fname in [ 'test-reads.revert.bam', 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam', 'test-reads.taxfilt.bam' ]: assert_equal_bam_reads(self, os.path.join(tempDir, fname), os.path.join(myInputDir, 'expected', fname))
def test_filter_lastal_bam_polio(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.blastn.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') args = taxon_filter.parser_filter_lastal_bam( argparse.ArgumentParser()).parse_args( [inBam, self.lastdb_path, outBam]) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.taxfilt.imperfect.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_deplete_bmtagger_fasta_db(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') ref_fasta = os.path.join(util.file.get_test_input_path(), '5kb_human_from_chr6.fasta') outBam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args( [inBam, ref_fasta, outBam, '--srprismMemory', '1500']) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_fastq_bam(self): myInputDir = util.file.get_test_input_path(self) # Define file names inFastq1 = os.path.join(myInputDir, 'in1.fastq') inFastq2 = os.path.join(myInputDir, 'in2.fastq') inHeader = os.path.join(myInputDir, 'inHeader.txt') expected1_7Sam = os.path.join(myInputDir, 'expected.java1_7.sam') expected1_8Sam = os.path.join(myInputDir, 'expected.java1_8.sam') expected1_8Sam_v15 = os.path.join(myInputDir, 'expected.java1_8_v1.5.sam') expectedFastq1 = os.path.join(myInputDir, 'expected.fastq1') outBamCmd = util.file.mkstempfname('.bam') outBamTxt = util.file.mkstempfname('.bam') outSam = util.file.mkstempfname('.sam') outFastq1 = util.file.mkstempfname('.fastq') outFastq2 = util.file.mkstempfname('.fastq') outHeader = util.file.mkstempfname('.txt') outHeaderFix = util.file.mkstempfname('.fix.txt') # in1.fastq, in2.fastq -> out.bam; header params from command-line parser = read_utils.parser_fastq_to_bam(argparse.ArgumentParser()) args = parser.parse_args([ inFastq1, inFastq2, outBamCmd, '--sampleName', 'FreeSample', '--JVMmemory', '1g', '--picardOptions', 'LIBRARY_NAME=Alexandria', 'PLATFORM=9.75', 'SEQUENCING_CENTER=KareemAbdul-Jabbar', ]) args.func_main(args) alternate_expected_vals = {"VN": ["1.4", "1.5", "1.6", "1.7"]} self.assertEqualSamHeaders( outBamCmd, expected1_7Sam, other_allowed_values=alternate_expected_vals) assert_equal_bam_reads(self, outBamCmd, expected1_7Sam) parser = read_utils.parser_fastq_to_bam(argparse.ArgumentParser()) args = parser.parse_args( [inFastq1, inFastq2, outBamTxt, '--header', inHeader]) args.func_main(args)
def test_deplete_bmtagger_bam(self): os.environ.pop('TMPDIR', None) util.file.set_tmp_dir(None) inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') outBam = util.file.mkstempfname('-out.bam') args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args([ inBam, self.database_prefix_path, outBam, '--srprismMemory', '1500' ]) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut)
def test_deplete_human(self): myInputDir = util.file.get_test_input_path(self) tempDir = tempfile.mkdtemp() ref_fasta = os.path.join(myInputDir, '5kb_human_from_chr6.fasta') database_prefix_path = os.path.join(tempDir, "5kb_human_from_chr6") # create blast db blastdb_path = tools.blast.MakeblastdbTool().build_database(ref_fasta, database_prefix_path) # create bmtagger db bmtooldb_path = tools.bmtagger.BmtoolTool().build_database(ref_fasta, database_prefix_path + ".bitmask") srprismdb_path = tools.bmtagger.SrprismTool().build_database(ref_fasta, database_prefix_path + ".srprism") # create last db lastdb_path = tools.last.Lastdb().build_database(ref_fasta, database_prefix_path) # Run deplete_human args = taxon_filter.parser_deplete_human(argparse.ArgumentParser()).parse_args( [ os.path.join(myInputDir, 'test-reads.bam'), # output files os.path.join(tempDir, 'test-reads.revert.bam'), os.path.join(tempDir, 'test-reads.bmtagger.bam'), os.path.join(tempDir, 'test-reads.rmdup.bam'), os.path.join(tempDir, 'test-reads.blastn.bam'), "--taxfiltBam", os.path.join(tempDir, 'test-reads.taxfilt.bam'), # DBs "--blastDbs", blastdb_path, "--bmtaggerDbs", database_prefix_path, "--lastDb", lastdb_path, "--threads", "4" ] ) args.func_main(args) # Compare to expected for fname in [ 'test-reads.revert.bam', 'test-reads.bmtagger.bam', 'test-reads.rmdup.bam', 'test-reads.blastn.bam', 'test-reads.taxfilt.bam' ]: assert_equal_bam_reads(self, os.path.join(tempDir, fname), os.path.join(myInputDir, 'expected', fname))
def test_bam_filter_by_tax_id(self): temp_dir = tempfile.gettempdir() input_dir = util.file.get_test_input_path(self) taxonomy_dir = os.path.join(util.file.get_test_input_path(), "TestMetagenomicsSimple", "db", "taxonomy") filtered_bam = util.file.mkstempfname('.bam') args = [ os.path.join(input_dir, "input.bam"), os.path.join(input_dir, "input.kraken-reads.tsv.gz"), filtered_bam, os.path.join(taxonomy_dir, "nodes.dmp"), os.path.join(taxonomy_dir, "names.dmp"), "--taxIDs", "186538" ] args = metagenomics.parser_filter_bam_to_taxa( argparse.ArgumentParser()).parse_args(args) args.func_main(args) expected_bam = os.path.join(input_dir, "expected.bam") assert_equal_bam_reads(self, filtered_bam, expected_bam)
def test_deplete_bmtagger_tar_db(self): inBam = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'test-reads.bam') outBam = util.file.mkstempfname('-out.bam') tar_db_tgz = util.file.mkstempfname('.db.tar.gz') cmd = [ 'tar', '-C', os.path.dirname(self.database_prefix_path), '-cvzf', tar_db_tgz, '.' ] subprocess.check_call(cmd) args = taxon_filter.parser_deplete_bam_bmtagger( argparse.ArgumentParser()).parse_args( [inBam, tar_db_tgz, outBam, '--srprismMemory', '1500']) args.func_main(args) expectedOut = os.path.join(util.file.get_test_input_path(), 'TestDepleteHuman', 'expected', 'test-reads.bmtagger.bam') assert_equal_bam_reads(self, outBam, expectedOut) os.unlink(tar_db_tgz)
def test_bam_filter_by_tax_id(self): temp_dir = tempfile.gettempdir() input_dir = util.file.get_test_input_path(self) taxonomy_dir = os.path.join(util.file.get_test_input_path(),"TestMetagenomicsSimple","db","taxonomy") filtered_bam = util.file.mkstempfname('.bam') args = [ os.path.join(input_dir,"input.bam"), os.path.join(input_dir,"input.kraken-reads.tsv.gz"), filtered_bam, os.path.join(taxonomy_dir,"nodes.dmp"), os.path.join(taxonomy_dir,"names.dmp"), "--taxIDs", "186538" ] args = metagenomics.parser_filter_bam_to_taxa(argparse.ArgumentParser()).parse_args(args) args.func_main(args) expected_bam = os.path.join(input_dir,"expected.bam") assert_equal_bam_reads(self, filtered_bam, expected_bam)
def test_deplete_blastn_bam(self): tempDir = tempfile.mkdtemp() myInputDir = util.file.get_test_input_path(self) # Run deplete_blastn_bam inBam = os.path.join(myInputDir, 'in.bam') outBam = os.path.join(tempDir, 'out.bam') args = taxon_filter.parser_deplete_blastn_bam( argparse.ArgumentParser()).parse_args([inBam] + self.blastdbs_multi + [outBam, "--chunkSize", "0"]) args.func_main(args) # samtools view for out.sam and compare to expected outSam = os.path.join(tempDir, 'out.sam') samtools = tools.samtools.SamtoolsTool() samtools.view(['-h'], outBam, outSam) assert_equal_bam_reads(self, outSam, os.path.join(myInputDir, 'expected.sam'))
def test_lastal_empty_input(self): empty_bam = os.path.join(util.file.get_test_input_path(), 'empty.bam') outBam = util.file.mkstempfname('-out-taxfilt.bam') taxon_filter.filter_lastal_bam(empty_bam, self.lastdb_path, outBam) assert_equal_bam_reads(self, outBam, empty_bam)