# Path: augur/align.py
# class AlignmentError(Exception):
# def register_arguments(parser):
# def prepare(sequences, existing_aln_fname, output, ref_name, ref_seq_fname):
# def run(args):
# def postprocess(output_file, ref_name, keep_reference, fill_gaps):
# def read_sequences(*fnames):
# def check_arguments(args):
# def read_alignment(fname):
# def ensure_reference_strain_present(ref_name, existing_alignment, seqs):
# def read_reference(ref_fname):
# def generate_alignment_cmd(method, nthreads, existing_aln_fname, seqs_to_align_fname, aln_fname, log_fname):
# def remove_reference_sequence(seqs, reference_name):
# def strip_non_reference(aln, reference, insertion_csv=None):
# def analyse_insertions(aln, ungapped, insertion_csv):
# def prettify_alignment(aln):
# def make_gaps_ambiguous(aln):
# def check_duplicates(*values):
#     def add(name):
# def write_seqs(seqs, fname):
# def prune_seqs_matching_alignment(seqs, aln):


import argparse
import functools
import os
import pytest
import pathlib
from shlex import quote
from Bio import SeqIO
from Bio.Align import MultipleSeqAlignment
from Bio.Seq import Seq
from Bio.Seq import MutableSeq
from Bio.SeqRecord import SeqRecord
from augur import align
        from augur.align import prepare as prpr # Prevent recursion depth exceeded. Yes, this is terrible.
        from augur.align import prepare as prpr # Prevent recursion depth exceeded. Yes, this is terrible.
@pytest.fixture
def ref_file(tmpdir, ref_seq):
    return write_strains(tmpdir, "ref", ref_seq)

@pytest.fixture
def test_file(tmpdir, test_seqs):
    return write_strains(tmpdir, "test", test_seqs.values())

@pytest.fixture
def test_with_ref(tmpdir, test_seqs, ref_seq):
    return write_strains(tmpdir, "test_w_ref", [ref_seq,] + list(test_seqs.values()))

@pytest.fixture
def existing_file(tmpdir, existing_aln):
    return write_strains(tmpdir, "existing", existing_aln.values())

@pytest.fixture
def existing_with_ref(tmpdir, existing_aln, ref_seq):
    return write_strains(tmpdir, "existing_w_ref", [ref_seq,] + list(existing_aln.values()))

@pytest.fixture
def out_file(tmpdir):
    out_file = str(tmpdir / "out")
    open(out_file, "w").close()
    return out_file

@pytest.fixture
def argparser():
    """Provide an easy way to test command line arguments"""
    parser = argparse.ArgumentParser()

# Path: augur/align.py
# class AlignmentError(Exception):
# def register_arguments(parser):
# def prepare(sequences, existing_aln_fname, output, ref_name, ref_seq_fname):
# def run(args):
# def postprocess(output_file, ref_name, keep_reference, fill_gaps):
# def read_sequences(*fnames):
# def check_arguments(args):
# def read_alignment(fname):
# def ensure_reference_strain_present(ref_name, existing_alignment, seqs):
# def read_reference(ref_fname):
# def generate_alignment_cmd(method, nthreads, existing_aln_fname, seqs_to_align_fname, aln_fname, log_fname):
# def remove_reference_sequence(seqs, reference_name):
# def strip_non_reference(aln, reference, insertion_csv=None):
# def analyse_insertions(aln, ungapped, insertion_csv):
# def prettify_alignment(aln):
# def make_gaps_ambiguous(aln):
# def check_duplicates(*values):
#     def add(name):
# def write_seqs(seqs, fname):
# def prune_seqs_matching_alignment(seqs, aln):


# Path: tests/test_align.py
import argparse
import functools
import os
import pytest
import pathlib
from shlex import quote
from Bio import SeqIO
from Bio.Align import MultipleSeqAlignment
from Bio.Seq import Seq
from Bio.Seq import MutableSeq
from Bio.SeqRecord import SeqRecord
from augur import align
        from augur.align import prepare as prpr # Prevent recursion depth exceeded. Yes, this is terrible.
        from augur.align import prepare as prpr # Prevent recursion depth exceeded. Yes, this is terrible.

@pytest.fixture
def ref_file(tmpdir, ref_seq):
    return write_strains(tmpdir, "ref", ref_seq)

@pytest.fixture
def test_file(tmpdir, test_seqs):
    return write_strains(tmpdir, "test", test_seqs.values())

@pytest.fixture
def test_with_ref(tmpdir, test_seqs, ref_seq):
    return write_strains(tmpdir, "test_w_ref", [ref_seq,] + list(test_seqs.values()))

@pytest.fixture
def existing_file(tmpdir, existing_aln):
    return write_strains(tmpdir, "existing", existing_aln.values())

@pytest.fixture
def existing_with_ref(tmpdir, existing_aln, ref_seq):
    return write_strains(tmpdir, "existing_w_ref", [ref_seq,] + list(existing_aln.values()))

@pytest.fixture
def out_file(tmpdir):
    out_file = str(tmpdir / "out")
    open(out_file, "w").close()
    return out_file

@pytest.fixture
def argparser():
    """Provide an easy way to test command line arguments"""
    parser = argparse.ArgumentParser()

    align.register_arguments(parser)