# Path: bipy/utils.py
# def in2out(in_file, word, transform=True, out_dir=None):
# def get_stem(filename):
# def combine_pairs(input_files):
# def freeze_files(files, directory):
# def memoize_outfile_to_dir(res_dir, ext):
#     def decor(f):
#         def wrapper(*args, **kwargs):
# def prepare_ref_file(ref, config):
# def _download_ref(url, ref_dir):
# def build_results_dir(stage_config, config):
# def transform_infile(filename, stage, delim="."):
# def filter_infile(filename, stage, delim="."):
# def remove_suffix(filename):
# def append_stem(filename, word, delim="."):
# def replace_suffix(filename, suffix, delim="."):
# def flatten_options(config):
# def flatten(l):
# def rfind_key(d, item):
# def rfind_value(d, item):
# def validate_config(config, data=True):
# def get_stages(config):
# def _add_full_path(program):
# def find_one_if(predicate, coll):
# def load_yaml(filename):
# def which(program):
#     def is_exe(fpath):
#     def __init__(self, in_file, **kwargs):
#     def curr_file(self):
#     def add_file(self, in_file):
#     def was_file(self, in_file):
# def update_tracker(tracker, curr_files):
# def curr_files(tracker):
# def dict_to_vectors(d):
#     def __getattr__(self, attr):
# def nested_lookup(d, t):
# def get_in(d, t, default=None):
# def is_sequence(arg):
# def is_pair(arg):
# def locate(pattern, root=os.curdir):
#     PAIR_FILE_IDENTIFIERS = ["1", "2"]
# class FileWithHistory(object):
# class dotdict(dict):


from bipy import utils
import yaml
import unittest
import os
import tempfile
import sh
                "FA7dayrep1_1.fastq", "FA7dayrep1_2.fastq",
                "FA14dayrep2_1.fastq", "FA14dayrep2_2.fastq",
                "FA1dayrep2_1.fastq", "FA1dayrep2_2.fastq",
                "FA28dayrep2_1.fastq", "FA28dayrep2_2.fastq",
                "FA2dayrep2_1.fastq", "FA2dayrep2_2.fastq",
                "FA3dayrep2_1.fastq", "FA3dayrep2_2.fastq",
                "FA7dayrep2_1.fastq", "FA7dayrep2_2.fastq",
                "FA1dayrep3_1.fastq", "FA1dayrep3_2.fastq",
                "FA28dayrep3_1.fastq", "FA28dayrep3_2.fastq",
                "FA2dayrep3_1.fastq", "FA2dayrep3_2.fastq",
                "FA3dayrep3_1.fastq", "FA3dayrep3_2.fastq",
                "FA7dayrep3_1.fastq", "FA7dayrep3_2.fastq"]

CORRECT_DIR = "test/cutadapt/data/correct"


class TestUtils(unittest.TestCase):

    def setUp(self):
        with open(CONFIG_FILE) as in_handle:
            self.config = yaml.load(in_handle)

    def _touch_files(self, touched_files):
        test_dir = tempfile.mkdtemp()
        out_files = [os.path.join(test_dir, x) for x in touched_files]
        [open(x, "w").close() for x in out_files]
        return test_dir, out_files

    def test_locate(self):
        test_dir, out_files = self._touch_files(PAIRED_FILES)

# Path: bipy/utils.py
# def in2out(in_file, word, transform=True, out_dir=None):
# def get_stem(filename):
# def combine_pairs(input_files):
# def freeze_files(files, directory):
# def memoize_outfile_to_dir(res_dir, ext):
#     def decor(f):
#         def wrapper(*args, **kwargs):
# def prepare_ref_file(ref, config):
# def _download_ref(url, ref_dir):
# def build_results_dir(stage_config, config):
# def transform_infile(filename, stage, delim="."):
# def filter_infile(filename, stage, delim="."):
# def remove_suffix(filename):
# def append_stem(filename, word, delim="."):
# def replace_suffix(filename, suffix, delim="."):
# def flatten_options(config):
# def flatten(l):
# def rfind_key(d, item):
# def rfind_value(d, item):
# def validate_config(config, data=True):
# def get_stages(config):
# def _add_full_path(program):
# def find_one_if(predicate, coll):
# def load_yaml(filename):
# def which(program):
#     def is_exe(fpath):
#     def __init__(self, in_file, **kwargs):
#     def curr_file(self):
#     def add_file(self, in_file):
#     def was_file(self, in_file):
# def update_tracker(tracker, curr_files):
# def curr_files(tracker):
# def dict_to_vectors(d):
#     def __getattr__(self, attr):
# def nested_lookup(d, t):
# def get_in(d, t, default=None):
# def is_sequence(arg):
# def is_pair(arg):
# def locate(pattern, root=os.curdir):
#     PAIR_FILE_IDENTIFIERS = ["1", "2"]
# class FileWithHistory(object):
# class dotdict(dict):


# Path: test/utils/test_utils.py
from bipy import utils
import yaml
import unittest
import os
import tempfile
import sh

                "FA7dayrep1_1.fastq", "FA7dayrep1_2.fastq",
                "FA14dayrep2_1.fastq", "FA14dayrep2_2.fastq",
                "FA1dayrep2_1.fastq", "FA1dayrep2_2.fastq",
                "FA28dayrep2_1.fastq", "FA28dayrep2_2.fastq",
                "FA2dayrep2_1.fastq", "FA2dayrep2_2.fastq",
                "FA3dayrep2_1.fastq", "FA3dayrep2_2.fastq",
                "FA7dayrep2_1.fastq", "FA7dayrep2_2.fastq",
                "FA1dayrep3_1.fastq", "FA1dayrep3_2.fastq",
                "FA28dayrep3_1.fastq", "FA28dayrep3_2.fastq",
                "FA2dayrep3_1.fastq", "FA2dayrep3_2.fastq",
                "FA3dayrep3_1.fastq", "FA3dayrep3_2.fastq",
                "FA7dayrep3_1.fastq", "FA7dayrep3_2.fastq"]

CORRECT_DIR = "test/cutadapt/data/correct"


class TestUtils(unittest.TestCase):

    def setUp(self):
        with open(CONFIG_FILE) as in_handle:
            self.config = yaml.load(in_handle)

    def _touch_files(self, touched_files):
        test_dir = tempfile.mkdtemp()
        out_files = [os.path.join(test_dir, x) for x in touched_files]
        [open(x, "w").close() for x in out_files]
        return test_dir, out_files

    def test_locate(self):
        test_dir, out_files = self._touch_files(PAIRED_FILES)

        located_files = utils.locate("*.fastq", test_dir)