# Path: riboSeed/classes.py
# class Exes(object):
#     """
#     given the amount of system tools that riboSeed requires, this object
#     holds the paths to the executables after expanding the user-supplied
#     path and verifying with shutil.which that the executable is availible
#     to the program.
# 
# 
#     """
#     def __init__(self, python, samtools, method, spades, quast,
#                  smalt, bwa, skesa, bcftools=None, vcfutils=None,
#                  check=True, mapper=None):
#         self.python = python
#         self.samtools = samtools
#         self.method = method
#         self.mapper = mapper
#         self.spades = spades
#         self.skesa = skesa
#         self.quast = quast
#         self.smalt = smalt
#         self.bwa = bwa
#         self.bcftools = bcftools
#         self.check = check
#         self.check_mands()
#         self.set_mapper()
#         self.check_expand_mand_exes()
#         self.check_expand_opt_exes()
# 
#     def check_mands(self):
#         """ checks that all mandatory arguments are not none
#         """
#         mandatory = [self.python, self.spades, self.method,
#                      self.samtools, self.bwa, self.skesa]
#         assert None not in mandatory, \
#             "must instantiate with python, samtools, " +\
#             "spades, skesa, bwa, and methods!"
# 
#     def set_mapper(self):
#         """Exes.mapper attribute is set here to avoid further
#         "if method =='smalt' clauses later.
#         """
#         if self.method == "smalt":
#             self.mapper = self.smalt
#         elif self.method == "bwa":
#             self.mapper = self.bwa
#         else:
#             raise ValueError("Mapping method not found!")
# 
#     def check_expand_mand_exes(self):
#         """ for each executable, expand wildcards and use shutil.which
#         to get full path to executable.  If not found, throw an error
#         """
#         if self.check:
#             for exe in ["mapper", "samtools", "spades", "skesa",
#                         "mapper"]:
#                 exe_groomed = os.path.expanduser(getattr(self, exe))
#                 exe_groomed = shutil.which(exe_groomed)
#                 if exe_groomed is None:
#                     raise ValueError("%s not found in PATH!" % exe)
#                 setattr(self, exe, exe_groomed)
#         else:
#             pass
# 
#     def check_expand_opt_exes(self):
#         """ for each executable, expand wildcards and use shutil.which
#         to get full path to executable.
#         """
#         if self.check:
#             for exe in ["bcftools", "quast"]:
#                 if getattr(self, exe) is not None:
#                     exe_groomed = os.path.expanduser(getattr(self, exe))
#                     exe_groomed = shutil.which(exe_groomed)
#                     setattr(self, exe, exe_groomed)
#         else:
#             pass
# 
#     def check_spades_python_version(self, logger):
#         """   ensure that we have a availible python to
#         ruin spades with. See details in method docstrings
#         Note this version will be used for quast as well
#         """
#         from .riboSeed import fiddle_with_spades_exe
#         spades_python = fiddle_with_spades_exe(
#             spades_exe=self.spades, logger=logger)
#         return spades_python


import sys
import logging
import shutil
import os
import unittest
from riboSeed.classes import Exes
                 python=self.python_exe,
                 spades=self.spades_exe,
                 bwa=self.bwa_exe,
                 method="bowtie")

    def test_Exes_bad_attribute(self):
        """ check bad instantiation of Exes object"""
        with self.assertRaises(AssertionError):
            Exes(samtools=None,
                 quast=self.quast_exe,
                 spades=self.spades_exe,
                 python=self.python_exe,
                 smalt=self.smalt_exe,
                 bwa=self.bwa_exe,
                 method="bwa")

    def test_Exes_bad_exe(self):
        """check Exes with nonexistant executable
        """
        with self.assertRaises(ValueError):
            Exes(samtools="nottheactualsamtools_exe",
                 quast=self.quast_exe,
                 python=self.python_exe,
                 smalt=self.smalt_exe,
                 spades=self.spades_exe,
                 bwa=self.bwa_exe,
                 method="bwa")

    def test_Exes_(self):
        """check with  executable"""

# Path: riboSeed/classes.py
# class Exes(object):
#     """
#     given the amount of system tools that riboSeed requires, this object
#     holds the paths to the executables after expanding the user-supplied
#     path and verifying with shutil.which that the executable is availible
#     to the program.
# 
# 
#     """
#     def __init__(self, python, samtools, method, spades, quast,
#                  smalt, bwa, skesa, bcftools=None, vcfutils=None,
#                  check=True, mapper=None):
#         self.python = python
#         self.samtools = samtools
#         self.method = method
#         self.mapper = mapper
#         self.spades = spades
#         self.skesa = skesa
#         self.quast = quast
#         self.smalt = smalt
#         self.bwa = bwa
#         self.bcftools = bcftools
#         self.check = check
#         self.check_mands()
#         self.set_mapper()
#         self.check_expand_mand_exes()
#         self.check_expand_opt_exes()
# 
#     def check_mands(self):
#         """ checks that all mandatory arguments are not none
#         """
#         mandatory = [self.python, self.spades, self.method,
#                      self.samtools, self.bwa, self.skesa]
#         assert None not in mandatory, \
#             "must instantiate with python, samtools, " +\
#             "spades, skesa, bwa, and methods!"
# 
#     def set_mapper(self):
#         """Exes.mapper attribute is set here to avoid further
#         "if method =='smalt' clauses later.
#         """
#         if self.method == "smalt":
#             self.mapper = self.smalt
#         elif self.method == "bwa":
#             self.mapper = self.bwa
#         else:
#             raise ValueError("Mapping method not found!")
# 
#     def check_expand_mand_exes(self):
#         """ for each executable, expand wildcards and use shutil.which
#         to get full path to executable.  If not found, throw an error
#         """
#         if self.check:
#             for exe in ["mapper", "samtools", "spades", "skesa",
#                         "mapper"]:
#                 exe_groomed = os.path.expanduser(getattr(self, exe))
#                 exe_groomed = shutil.which(exe_groomed)
#                 if exe_groomed is None:
#                     raise ValueError("%s not found in PATH!" % exe)
#                 setattr(self, exe, exe_groomed)
#         else:
#             pass
# 
#     def check_expand_opt_exes(self):
#         """ for each executable, expand wildcards and use shutil.which
#         to get full path to executable.
#         """
#         if self.check:
#             for exe in ["bcftools", "quast"]:
#                 if getattr(self, exe) is not None:
#                     exe_groomed = os.path.expanduser(getattr(self, exe))
#                     exe_groomed = shutil.which(exe_groomed)
#                     setattr(self, exe, exe_groomed)
#         else:
#             pass
# 
#     def check_spades_python_version(self, logger):
#         """   ensure that we have a availible python to
#         ruin spades with. See details in method docstrings
#         Note this version will be used for quast as well
#         """
#         from .riboSeed import fiddle_with_spades_exe
#         spades_python = fiddle_with_spades_exe(
#             spades_exe=self.spades, logger=logger)
#         return spades_python


# Path: tests/test_Exes.py
import sys
import logging
import shutil
import os
import unittest
from riboSeed.classes import Exes

                 python=self.python_exe,
                 spades=self.spades_exe,
                 bwa=self.bwa_exe,
                 method="bowtie")

    def test_Exes_bad_attribute(self):
        """ check bad instantiation of Exes object"""
        with self.assertRaises(AssertionError):
            Exes(samtools=None,
                 quast=self.quast_exe,
                 spades=self.spades_exe,
                 python=self.python_exe,
                 smalt=self.smalt_exe,
                 bwa=self.bwa_exe,
                 method="bwa")

    def test_Exes_bad_exe(self):
        """check Exes with nonexistant executable
        """
        with self.assertRaises(ValueError):
            Exes(samtools="nottheactualsamtools_exe",
                 quast=self.quast_exe,
                 python=self.python_exe,
                 smalt=self.smalt_exe,
                 spades=self.spades_exe,
                 bwa=self.bwa_exe,
                 method="bwa")

    def test_Exes_(self):
        """check with  executable"""

        test_exes = Exes(samtools=self.samtools_exe,