#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Script to run the `midori253darn` database test.
"""

# Built-in modules #
import inspect, os

# First party modules #
from autopaths import Path

# Third party modules #
import pytest

# Internal modules #
from crest4 import Classify

# Get the current directory of this python script #
this_file = Path((inspect.stack()[0])[1])
this_dir  = this_file.directory

###############################################################################
@pytest.mark.skipif(
    os.getenv("GITHUB_ACTIONS") == "true",
    reason="GitHub limits cache to 10GB, this DB is too big.",
)
def test_db_midori():
    # The input fasta #
    fasta = this_dir.find('*.fasta')
    # The output directory #
    output_dir = this_dir + 'results/'
    output_dir.remove()
    # Create object #
    c = Classify(fasta       = fasta,
                 output_dir  = output_dir,
                 search_algo = 'vsearch',
                 search_db   = 'midori253darn',
                 num_threads = True)
    # Run it #
    c()
    # Check that the results are good #
    assert c.queries_by_id['Test'].taxonomy[0] == "Saccharomyces"
    # Return #
    return c

###############################################################################
if __name__ == '__main__':
    classify = test_db_midori()