# Path: circlator/bamfilter.py
# class Error (Exception): pass
# class BamFilter:
#     def __init__(
#              self,
#              bam,
#              outprefix,
#              fastq_out=False,
#              length_cutoff=100000,
#              min_read_length=250,
#              contigs_to_use=None,
#              discard_unmapped=False,
#              log_prefix='[bamfilter]',
#              verbose=False,
#              split_all_reads=False,
#     ):
#     def _get_ref_lengths(self):
#     def _get_contigs_to_use(self, contigs_to_use):
#     def _check_contigs_to_use(self, ref_dict):
#     def _all_reads_from_contig(self, contig, fout):
#     def _get_all_unmapped_reads(self, fout):
#     def _break_reads(self, contig, position, fout, min_read_length=250):
#     def _exclude_region(self, contig, start, end, fout):
#     def _get_region(self, contig, start, end, fout, min_length=250):
#     def run(self):


import unittest
import filecmp
import os
import pyfastaq
from circlator import bamfilter
            outprefix,
            fastq_out=True,
            length_cutoff=600,
            min_read_length=100,
            contigs_to_use={'contig1', 'contig3', 'contig4'}
        )
        b.run()
        expected = os.path.join(data_dir, 'bamfilter_test_run_keep_unmapped.out.reads.fa')
        self.assertTrue(filecmp.cmp(expected, outprefix + '.fastq', shallow=False))
        os.unlink(outprefix + '.fastq')
        os.unlink(outprefix + '.log')


    def test_run_keep_unmapped_with_quals(self):
        '''test run keep unmapped bam has quality scores'''
        outprefix = 'tmp.bamfilter_run'
        b = bamfilter.BamFilter(
            os.path.join(data_dir, 'bamfilter_test_run_with_qual.bam'),
            outprefix,
            fastq_out=False,
            length_cutoff=600,
            min_read_length=100,
            contigs_to_use={'contig1', 'contig3', 'contig4'}
        )
        b.run()
        expected = os.path.join(data_dir, 'bamfilter_test_run_keep_unmapped.out.reads.fa')
        self.assertTrue(filecmp.cmp(expected, outprefix + '.fasta', shallow=False))
        os.unlink(outprefix + '.fasta')
        os.unlink(outprefix + '.log')


# Path: circlator/bamfilter.py
# class Error (Exception): pass
# class BamFilter:
#     def __init__(
#              self,
#              bam,
#              outprefix,
#              fastq_out=False,
#              length_cutoff=100000,
#              min_read_length=250,
#              contigs_to_use=None,
#              discard_unmapped=False,
#              log_prefix='[bamfilter]',
#              verbose=False,
#              split_all_reads=False,
#     ):
#     def _get_ref_lengths(self):
#     def _get_contigs_to_use(self, contigs_to_use):
#     def _check_contigs_to_use(self, ref_dict):
#     def _all_reads_from_contig(self, contig, fout):
#     def _get_all_unmapped_reads(self, fout):
#     def _break_reads(self, contig, position, fout, min_read_length=250):
#     def _exclude_region(self, contig, start, end, fout):
#     def _get_region(self, contig, start, end, fout, min_length=250):
#     def run(self):


# Path: circlator/tests/bamfilter_test.py
import unittest
import filecmp
import os
import pyfastaq
from circlator import bamfilter

            outprefix,
            fastq_out=True,
            length_cutoff=600,
            min_read_length=100,
            contigs_to_use={'contig1', 'contig3', 'contig4'}
        )
        b.run()
        expected = os.path.join(data_dir, 'bamfilter_test_run_keep_unmapped.out.reads.fa')
        self.assertTrue(filecmp.cmp(expected, outprefix + '.fastq', shallow=False))
        os.unlink(outprefix + '.fastq')
        os.unlink(outprefix + '.log')


    def test_run_keep_unmapped_with_quals(self):
        '''test run keep unmapped bam has quality scores'''
        outprefix = 'tmp.bamfilter_run'
        b = bamfilter.BamFilter(
            os.path.join(data_dir, 'bamfilter_test_run_with_qual.bam'),
            outprefix,
            fastq_out=False,
            length_cutoff=600,
            min_read_length=100,
            contigs_to_use={'contig1', 'contig3', 'contig4'}
        )
        b.run()
        expected = os.path.join(data_dir, 'bamfilter_test_run_keep_unmapped.out.reads.fa')
        self.assertTrue(filecmp.cmp(expected, outprefix + '.fasta', shallow=False))
        os.unlink(outprefix + '.fasta')
        os.unlink(outprefix + '.log')


        b = bamfilter.BamFilter(