# Path: bipy/toolbox/bedtools.py
# def intersectbam2bed(bam_file, bed_file, exclude=False, out_file=None):
# def count_overlaps(in_file, bed, out_file=None):
# def multi_intersect(in_files, options=None, out_file=None):
# def _run_command(in_files, cmd, suffix="", out_file=None):
# def intersect(in_files, options=None, out_file=None):
# 
# Path: bipy/utils.py
# def replace_suffix(filename, suffix, delim="."):
#     """ returns a filename with the suffix replaced
#     with a new suffix
#     exampoe: /path/to/test.run.sam -> /path/to/test.run.fa"""
#     dirname = os.path.dirname(filename)
#     filename = os.path.basename(filename)
#     fsplit = filename.split(delim)[:-1]
#     fsplit.append(suffix)
#     return os.path.join(dirname, delim.join(fsplit))


from bipy.toolbox import bedtools
from bipy.utils import replace_suffix
from bcbio.utils import safe_makedir
import os
import unittest


class TestBedtools(unittest.TestCase):

    def setUp(self):
        self.bam_file = "test/data/s_1_1_10k.bam"
        self.gtf = "test/data/E_coli_k12.ASM584v1.15.gtf"

    def test_count_overlap(self):
        out_dir = "results/count_overlaps"
        safe_makedir(out_dir)
        out_file = os.path.join(out_dir, "count_overlap_test.counts")


# Path: bipy/toolbox/bedtools.py
# def intersectbam2bed(bam_file, bed_file, exclude=False, out_file=None):
# def count_overlaps(in_file, bed, out_file=None):
# def multi_intersect(in_files, options=None, out_file=None):
# def _run_command(in_files, cmd, suffix="", out_file=None):
# def intersect(in_files, options=None, out_file=None):
# 
# Path: bipy/utils.py
# def replace_suffix(filename, suffix, delim="."):
#     """ returns a filename with the suffix replaced
#     with a new suffix
#     exampoe: /path/to/test.run.sam -> /path/to/test.run.fa"""
#     dirname = os.path.dirname(filename)
#     filename = os.path.basename(filename)
#     fsplit = filename.split(delim)[:-1]
#     fsplit.append(suffix)
#     return os.path.join(dirname, delim.join(fsplit))


# Path: test/bedtools/test_bedtools.py
from bipy.toolbox import bedtools
from bipy.utils import replace_suffix
from bcbio.utils import safe_makedir
import os
import unittest



class TestBedtools(unittest.TestCase):

    def setUp(self):
        self.bam_file = "test/data/s_1_1_10k.bam"
        self.gtf = "test/data/E_coli_k12.ASM584v1.15.gtf"

    def test_count_overlap(self):
        out_dir = "results/count_overlaps"
        safe_makedir(out_dir)
        out_file = os.path.join(out_dir, "count_overlap_test.counts")


        out_file = bedtools.count_overlaps(self.bam_file, self.gtf,