def test_read_bed_file_with_bad_lines(self, tmpdir): """read_bed_file should error out if any other lines are unreadable""" bed_file = str(tmpdir / "temp.bed") bed_lines = ["SEQ\t7\t8", "CHROM\tSTART\tEND", "SEQ\t2\t5"] with open(bed_file, "w") as fh: fh.write("\n".join(bed_lines)) with pytest.raises(Exception): utils.read_bed_file(bed_file)
def test_read_bed_file_good_input(self, tmpdir): """read_bed_file should read site ranges from properly formatted bed files""" bed_file = str(tmpdir / "temp.bed") bed_lines = ["SEQ\t7\t8", "SEQ\t2\t6", "SEQ\t3\t4"] expected_sites = [2, 3, 4, 5, 7] with open(bed_file, "w") as fh: fh.write("\n".join(bed_lines)) assert utils.read_bed_file(bed_file) == expected_sites
def test_read_bed_file_with_header(self, tmpdir): """read_bed_file should skip header lines if they exist in bed files""" bed_file = str(tmpdir / "temp.bed") bed_lines = ["CHROM\tSTART\tEND", "SEQ\t7\t8", "SEQ\t2\t5"] expected_sites = [2, 3, 4, 7] with open(bed_file, "w") as fh: fh.write("\n".join(bed_lines)) assert utils.read_bed_file(bed_file) == expected_sites