# Path: ariba/common.py
# class Error (Exception): pass
# def syscall(cmd, allow_fail=False, verbose=False, verbose_filehandle=sys.stdout, print_errors=True, shell=True):
# def decode(x):
# def cat_files(infiles, outfile):
# def download_file(url, outfile, max_attempts=3, sleep_time=2, verbose=False):
# def rmtree(input_dir):


import tempfile
import copy
import os
import pymummer
import pyfastaq
from ariba import common
        pyfastaq.utils.close(f_out)
        return True


    @classmethod
    def _sequence_is_in_fasta_file(cls, seq_name, fasta_file):
        for seq in pyfastaq.sequences.file_reader(fasta_file):
            if seq.id == seq_name:
                return True
        return False


    @classmethod
    def _load_nucmer_coords_file(cls, coords_file, log_fh=None):
        matches = {}
        file_reader = pymummer.coords_file.reader(coords_file)
        for hit in file_reader:
            if log_fh is not None:
                print('[choose ref nucmer]', hit, sep='\t', file=log_fh)
            if hit.ref_name not in matches:
                matches[hit.ref_name] = []
            matches[hit.ref_name].append(copy.copy(hit))
        return matches


    @classmethod
    def _l_and_c_from_contig_name(cls, name):
        try:
            prefix, l_string, c_string, ctg, counter = name.split('.')
            l = int(l_string[1:])

# Path: ariba/common.py
# class Error (Exception): pass
# def syscall(cmd, allow_fail=False, verbose=False, verbose_filehandle=sys.stdout, print_errors=True, shell=True):
# def decode(x):
# def cat_files(infiles, outfile):
# def download_file(url, outfile, max_attempts=3, sleep_time=2, verbose=False):
# def rmtree(input_dir):


# Path: ariba/ref_seq_chooser.py
import tempfile
import copy
import os
import pymummer
import pyfastaq
from ariba import common

        pyfastaq.utils.close(f_out)
        return True


    @classmethod
    def _sequence_is_in_fasta_file(cls, seq_name, fasta_file):
        for seq in pyfastaq.sequences.file_reader(fasta_file):
            if seq.id == seq_name:
                return True
        return False


    @classmethod
    def _load_nucmer_coords_file(cls, coords_file, log_fh=None):
        matches = {}
        file_reader = pymummer.coords_file.reader(coords_file)
        for hit in file_reader:
            if log_fh is not None:
                print('[choose ref nucmer]', hit, sep='\t', file=log_fh)
            if hit.ref_name not in matches:
                matches[hit.ref_name] = []
            matches[hit.ref_name].append(copy.copy(hit))
        return matches


    @classmethod
    def _l_and_c_from_contig_name(cls, name):
        try:
            prefix, l_string, c_string, ctg, counter = name.split('.')
            l = int(l_string[1:])

            c = int(c_string[1:])