# Path: circlator/dnaa.py
# class Error (Exception): pass
# class UniprotDownloader:
#     def __init__(self, min_gene_length=333, max_gene_length=500, uniprot_search='dnaa', header_regex='dnaa', header_regex_ignorecase=True):
#     def _get_uniprot_url(self):
#     def _download_from_uniprot(self, outfile):
#     def _header_to_genus_species(self, header):
#     def _header_matches_regex(self, sequence):
#     def _check_sequence(self, sequence, seen_genus_species):
#     def _append_stop_to_seq(self, sequence):
#     def _reverse_translate(self, sequence):
#     def run(self, outprefix):


import unittest
import filecmp
import os
import pyfastaq
from circlator import dnaa
        for regex, sequence_name, ignorecase, expected in tests:
            downloader = dnaa.UniprotDownloader(header_regex=regex, header_regex_ignorecase=ignorecase)
            seq = pyfastaq.sequences.Fasta(sequence_name, 'ACGT')
            self.assertEqual(downloader._header_matches_regex(seq), expected)


    def test_check_sequence(self):
        '''test _check_sequence'''
        downloader = dnaa.UniprotDownloader(min_gene_length=3, max_gene_length=6)
        seen = set()
        tests = [
            (pyfastaq.sequences.Fasta('dnaa OS=genus1 species1 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('Dnaa OS=genus1 species2 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('DnaA OS=genus2 species1 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('dnaA OS=genus2 species2 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('DNAA OS=genus2 species3 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species1 foo', 'MA'), (False, 'Too long or short')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species2 foo', 'MABCDEF'), (False, 'Too long or short')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species3 foo', 'XABC'), (False, 'Does not start with M')),
            (pyfastaq.sequences.Fasta('x OS=genus3 species4 foo', 'MABC'), (False, 'No match to regex in name')),
            (pyfastaq.sequences.Fasta('dnaa foo', 'MABC'), (False, 'Error getting genus species')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus1 species1 foo', 'MABC'), (False, "Duplicate genus species ('genus1', 'species1')")),
        ]

        for fa, expected in tests:
            self.assertEqual(downloader._check_sequence(fa, seen), expected)


    def test_append_stop_to_seq(self):
        '''test _append_stop_to_seq'''

# Path: circlator/dnaa.py
# class Error (Exception): pass
# class UniprotDownloader:
#     def __init__(self, min_gene_length=333, max_gene_length=500, uniprot_search='dnaa', header_regex='dnaa', header_regex_ignorecase=True):
#     def _get_uniprot_url(self):
#     def _download_from_uniprot(self, outfile):
#     def _header_to_genus_species(self, header):
#     def _header_matches_regex(self, sequence):
#     def _check_sequence(self, sequence, seen_genus_species):
#     def _append_stop_to_seq(self, sequence):
#     def _reverse_translate(self, sequence):
#     def run(self, outprefix):


# Path: circlator/tests/dnaa_test.py
import unittest
import filecmp
import os
import pyfastaq
from circlator import dnaa

        for regex, sequence_name, ignorecase, expected in tests:
            downloader = dnaa.UniprotDownloader(header_regex=regex, header_regex_ignorecase=ignorecase)
            seq = pyfastaq.sequences.Fasta(sequence_name, 'ACGT')
            self.assertEqual(downloader._header_matches_regex(seq), expected)


    def test_check_sequence(self):
        '''test _check_sequence'''
        downloader = dnaa.UniprotDownloader(min_gene_length=3, max_gene_length=6)
        seen = set()
        tests = [
            (pyfastaq.sequences.Fasta('dnaa OS=genus1 species1 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('Dnaa OS=genus1 species2 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('DnaA OS=genus2 species1 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('dnaA OS=genus2 species2 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('DNAA OS=genus2 species3 foo', 'MABC'), (True, None)),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species1 foo', 'MA'), (False, 'Too long or short')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species2 foo', 'MABCDEF'), (False, 'Too long or short')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus3 species3 foo', 'XABC'), (False, 'Does not start with M')),
            (pyfastaq.sequences.Fasta('x OS=genus3 species4 foo', 'MABC'), (False, 'No match to regex in name')),
            (pyfastaq.sequences.Fasta('dnaa foo', 'MABC'), (False, 'Error getting genus species')),
            (pyfastaq.sequences.Fasta('dnaa OS=genus1 species1 foo', 'MABC'), (False, "Duplicate genus species ('genus1', 'species1')")),
        ]

        for fa, expected in tests:
            self.assertEqual(downloader._check_sequence(fa, seen), expected)


    def test_append_stop_to_seq(self):
        '''test _append_stop_to_seq'''

        downloader = dnaa.UniprotDownloader()