def test_calmd_bam(self): ref_fpath = os.path.join(TEST_DATA_DIR, 'CUUC00007_TC01.fasta') bam_fpath = os.path.join(TEST_DATA_DIR, 'sample.bam') orig_qual = pysam.Samfile(bam_fpath).next().qual out_bam = NamedTemporaryFile() calmd_bam(bam_fpath, ref_fpath, out_bam.name) samfile = pysam.Samfile(out_bam.name) calmd_qual = alignment = samfile.next().qual assert orig_qual != calmd_qual assert calmd_qual == 'HHHHHHBHGGH!!!!!!!!!!!!!!!!!!!!!!!!!!!'
def test_calmd_no_out(self): ref_fpath = os.path.join(TEST_DATA_DIR, 'CUUC00007_TC01.fasta') bam_fpath = os.path.join(TEST_DATA_DIR, 'sample.bam') copied_fpath = os.path.join(TEST_DATA_DIR, 'sample_copy.bam') try: shutil.copy(bam_fpath, copied_fpath) orig_stats = os.stat(copied_fpath) calmd_bam(copied_fpath, ref_fpath) calmd_stats = os.stat(copied_fpath) assert calmd_stats != orig_stats finally: if os.path.exists(copied_fpath): os.remove(copied_fpath)
def test_calmd_bam(self): ref_fpath = os.path.join(TEST_DATA_DIR, "CUUC00007_TC01.fasta") bam_fpath = os.path.join(TEST_DATA_DIR, "sample.bam") orig_qual = AlignmentFile(bam_fpath).next().qual try: out_bam = NamedTemporaryFile() calmd_bam(bam_fpath, ref_fpath, out_bam.name) samfile = AlignmentFile(out_bam.name) calmd_qual = samfile.next().qual assert orig_qual != calmd_qual assert calmd_qual == "HHHHHHBHGGH!!!!!!!!!!!!!!!!!!!!!!!!!!!" finally: if os.path.exists(out_bam.name): out_bam.close()
def test_calmd_bam(self): ref_fpath = os.path.join(TEST_DATA_DIR, 'CUUC00007_TC01.fasta') bam_fpath = os.path.join(TEST_DATA_DIR, 'sample.bam') orig_qual = AlignmentFile(bam_fpath).next().qual try: out_bam = NamedTemporaryFile() calmd_bam(bam_fpath, ref_fpath, out_bam.name) samfile = AlignmentFile(out_bam.name) calmd_qual = samfile.next().qual assert orig_qual != calmd_qual assert calmd_qual == 'HHHHHHBHGGH!!!!!!!!!!!!!!!!!!!!!!!!!!!' finally: if os.path.exists(out_bam.name): out_bam.close()