# Path: circlator/merge.py
# class Error (Exception): pass
# class Merger:
#     def __init__(
#           self,
#           original_assembly,
#           reassembly,
#           outprefix,
#           reads=None,
#           nucmer_diagdiff=25,
#           nucmer_min_id=95,
#           nucmer_min_length=500,
#           nucmer_min_length_for_merges=4000,
#           nucmer_breaklen=500,
#           min_spades_circular_percent=95,
#           spades_kmers=None,
#           spades_use_first_success=False,
#           spades_careful=True,
#           spades_only_assembler=True,
#           assembler='spades',
#           length_cutoff=100000,
#           split_all_reads=False,
#           data_type='pacbio-corrected',
#           ref_end_tolerance=15000,
#           qry_end_tolerance=1000,
#           verbose=False,
#           threads=1,
#           log_prefix='merge',
#     ):
#     def _run_nucmer(self, ref, qry, outfile):
#     def _load_nucmer_hits(self, infile):
#     def _hits_hashed_by_query(self, hits):
#     def _get_longest_hit_by_ref_length(self, nucmer_hits):
#     def _is_at_ref_start(self, nucmer_hit):
#     def _is_at_ref_end(self, nucmer_hit):
#     def _is_at_qry_start(self, nucmer_hit):
#     def _is_at_qry_end(self, nucmer_hit):
#     def _get_hit_nearest_ref_start(self, hits):
#     def _get_hit_nearest_ref_end(self, hits):
#     def _get_longest_hit_at_ref_start(self, nucmer_hits, hits_to_exclude=None):
#     def _get_longest_hit_at_ref_end(self, nucmer_hits, hits_to_exclude=None):
#     def _get_longest_hit_at_qry_start(self, nucmer_hits):
#     def _get_longest_hit_at_qry_end(self, nucmer_hits):
#     def _hits_have_same_query(self, nucmer_hit1, nucmer_hit2):
#     def _hits_have_same_reference(self, nucmer_hit1, nucmer_hit2):
#     def _min_qry_hit_length(self, nucmer_hits):
#     def _has_qry_hit_longer_than(self, nucmer_hits, min_length, hits_to_exclude=None):
#     def _can_circularise(self, start_hit, end_hit):
#     def _get_possible_circular_ref_contigs(self, nucmer_hits, log_fh=None, log_outprefix=None):
#     def _remove_keys_from_dict_with_nonunique_values(self, d, log_fh=None, log_outprefix=None):
#     def _make_circularised_contig(self, ref_start_hit, ref_end_hit):
#     def _circularise_contigs(self, nucmer_hits):
#     def _orientation_ok_to_bridge_contigs(self, start_hit, end_hit):
#     def _get_possible_query_bridging_contigs(self, nucmer_hits, log_fh=None, log_outprefix=None):
#     def _filter_bridging_contigs(self, bridges):
#     def _merge_bridged_contig_pair(self, start_hit, end_hit, ref_contigs, qry_contigs, log_fh=None, log_outprefix=None):
#     def _merge_all_bridged_contigs(self, nucmer_hits, ref_contigs, qry_contigs, log_fh=None, log_outprefix=None):
#     def _index_fasta(self, infile):
#     def _write_act_files(self, ref_fasta, qry_fasta, coords_file, outprefix):
#     def _iterative_bridged_contig_pair_merge(self, outprefix):
#     def _contigs_dict_to_file(self, contigs, fname):
#     def _get_spades_circular_nodes(self, fastg):
#     def _make_new_contig_from_nucmer_and_spades(self, original_contig, hits, circular_spades, log_fh=None, log_outprefix=None):
#     def _write_merge_log(self, filename):
#     def run(self):


import unittest
import shutil
import filecmp
import copy
import os
import pymummer
import pyfastaq
from circlator import merge

modules_dir = os.path.dirname(os.path.abspath(merge.__file__))
data_dir = os.path.join(modules_dir, 'tests', 'data')


class TestMerge(unittest.TestCase):
    def setUp(self):

# Path: circlator/merge.py
# class Error (Exception): pass
# class Merger:
#     def __init__(
#           self,
#           original_assembly,
#           reassembly,
#           outprefix,
#           reads=None,
#           nucmer_diagdiff=25,
#           nucmer_min_id=95,
#           nucmer_min_length=500,
#           nucmer_min_length_for_merges=4000,
#           nucmer_breaklen=500,
#           min_spades_circular_percent=95,
#           spades_kmers=None,
#           spades_use_first_success=False,
#           spades_careful=True,
#           spades_only_assembler=True,
#           assembler='spades',
#           length_cutoff=100000,
#           split_all_reads=False,
#           data_type='pacbio-corrected',
#           ref_end_tolerance=15000,
#           qry_end_tolerance=1000,
#           verbose=False,
#           threads=1,
#           log_prefix='merge',
#     ):
#     def _run_nucmer(self, ref, qry, outfile):
#     def _load_nucmer_hits(self, infile):
#     def _hits_hashed_by_query(self, hits):
#     def _get_longest_hit_by_ref_length(self, nucmer_hits):
#     def _is_at_ref_start(self, nucmer_hit):
#     def _is_at_ref_end(self, nucmer_hit):
#     def _is_at_qry_start(self, nucmer_hit):
#     def _is_at_qry_end(self, nucmer_hit):
#     def _get_hit_nearest_ref_start(self, hits):
#     def _get_hit_nearest_ref_end(self, hits):
#     def _get_longest_hit_at_ref_start(self, nucmer_hits, hits_to_exclude=None):
#     def _get_longest_hit_at_ref_end(self, nucmer_hits, hits_to_exclude=None):
#     def _get_longest_hit_at_qry_start(self, nucmer_hits):
#     def _get_longest_hit_at_qry_end(self, nucmer_hits):
#     def _hits_have_same_query(self, nucmer_hit1, nucmer_hit2):
#     def _hits_have_same_reference(self, nucmer_hit1, nucmer_hit2):
#     def _min_qry_hit_length(self, nucmer_hits):
#     def _has_qry_hit_longer_than(self, nucmer_hits, min_length, hits_to_exclude=None):
#     def _can_circularise(self, start_hit, end_hit):
#     def _get_possible_circular_ref_contigs(self, nucmer_hits, log_fh=None, log_outprefix=None):
#     def _remove_keys_from_dict_with_nonunique_values(self, d, log_fh=None, log_outprefix=None):
#     def _make_circularised_contig(self, ref_start_hit, ref_end_hit):
#     def _circularise_contigs(self, nucmer_hits):
#     def _orientation_ok_to_bridge_contigs(self, start_hit, end_hit):
#     def _get_possible_query_bridging_contigs(self, nucmer_hits, log_fh=None, log_outprefix=None):
#     def _filter_bridging_contigs(self, bridges):
#     def _merge_bridged_contig_pair(self, start_hit, end_hit, ref_contigs, qry_contigs, log_fh=None, log_outprefix=None):
#     def _merge_all_bridged_contigs(self, nucmer_hits, ref_contigs, qry_contigs, log_fh=None, log_outprefix=None):
#     def _index_fasta(self, infile):
#     def _write_act_files(self, ref_fasta, qry_fasta, coords_file, outprefix):
#     def _iterative_bridged_contig_pair_merge(self, outprefix):
#     def _contigs_dict_to_file(self, contigs, fname):
#     def _get_spades_circular_nodes(self, fastg):
#     def _make_new_contig_from_nucmer_and_spades(self, original_contig, hits, circular_spades, log_fh=None, log_outprefix=None):
#     def _write_merge_log(self, filename):
#     def run(self):


# Path: circlator/tests/merge_test.py
import unittest
import shutil
import filecmp
import copy
import os
import pymummer
import pyfastaq
from circlator import merge


modules_dir = os.path.dirname(os.path.abspath(merge.__file__))
data_dir = os.path.join(modules_dir, 'tests', 'data')


class TestMerge(unittest.TestCase):
    def setUp(self):

        self.merger = merge.Merger(