# Path: inmembrane/helpers.py
# LOG_SILENT = False
#     LOG_SILENT = b
# def dict_get(this_dict, prop):
# def run_with_output(cmd):
# def run(cmd, out_file=None):
# def silence_log(b):
# def log_stderr(s, width=76, comment=True):
# def log_stdout(s, width=76):
# def parse_fasta_header(header):
# def seqid_to_filename(seqid):
# def create_proteins_dict(fasta):
# def print_proteins(proteins):
# def write_proteins_fasta(
#         fasta_filename, proteins, seqids, width=50):
# def proteins_to_fasta(proteins, seqids=[], use_safe_seqid=False, width=50):
# def chop_nterminal_peptide(protein, i_cut):
# def generate_safe_seqids(proteins):
# def clean_directory(top, excluded_files):
# def html2text(page, aggressive=False):


import os, tempfile, shutil
import unittest
import sys
import inmembrane
import inmembrane.tests
from inmembrane import helpers
class PluginTestBase(unittest.TestCase):
    _plugin_name = ""

    def setUp(self):
        """
        Sets up a directory, a parameters dictionary and a proteins dictionary
        object in preparation for running a test of a plugin.

        Creates a temporary directory (eg /tmp/.inmembrane_signalp_web_TleeRw ),
        copies the test input data (input.fasta) into it and changes the
        current working directory.

        Should be subclassed adding a method with the specific test(s) for
        the plugin. The subclass should set self._plugin_name to the name of
        the plugin.
        """
        self.test_data_dir = os.path.join(
            os.path.abspath(
                os.path.dirname(inmembrane.tests.__file__)), self._plugin_name)

        self.output_dir = tempfile.mkdtemp(
            prefix=".inmembrane_%s_" % (self._plugin_name))
        shutil.copyfile(os.path.join(self.test_data_dir, "input.fasta"),
                        os.path.join(self.output_dir, "input.fasta"))
        os.chdir(self.output_dir)
        helpers.silence_log(True)

        self.params = inmembrane.get_params()
        self.params['fasta'] = "input.fasta"
        self.seqids, self.proteins = \

# Path: inmembrane/helpers.py
# LOG_SILENT = False
#     LOG_SILENT = b
# def dict_get(this_dict, prop):
# def run_with_output(cmd):
# def run(cmd, out_file=None):
# def silence_log(b):
# def log_stderr(s, width=76, comment=True):
# def log_stdout(s, width=76):
# def parse_fasta_header(header):
# def seqid_to_filename(seqid):
# def create_proteins_dict(fasta):
# def print_proteins(proteins):
# def write_proteins_fasta(
#         fasta_filename, proteins, seqids, width=50):
# def proteins_to_fasta(proteins, seqids=[], use_safe_seqid=False, width=50):
# def chop_nterminal_peptide(protein, i_cut):
# def generate_safe_seqids(proteins):
# def clean_directory(top, excluded_files):
# def html2text(page, aggressive=False):


# Path: inmembrane/tests/PluginTestBase.py
import os, tempfile, shutil
import unittest
import sys
import inmembrane
import inmembrane.tests
from inmembrane import helpers

class PluginTestBase(unittest.TestCase):
    _plugin_name = ""

    def setUp(self):
        """
        Sets up a directory, a parameters dictionary and a proteins dictionary
        object in preparation for running a test of a plugin.

        Creates a temporary directory (eg /tmp/.inmembrane_signalp_web_TleeRw ),
        copies the test input data (input.fasta) into it and changes the
        current working directory.

        Should be subclassed adding a method with the specific test(s) for
        the plugin. The subclass should set self._plugin_name to the name of
        the plugin.
        """
        self.test_data_dir = os.path.join(
            os.path.abspath(
                os.path.dirname(inmembrane.tests.__file__)), self._plugin_name)

        self.output_dir = tempfile.mkdtemp(
            prefix=".inmembrane_%s_" % (self._plugin_name))
        shutil.copyfile(os.path.join(self.test_data_dir, "input.fasta"),
                        os.path.join(self.output_dir, "input.fasta"))
        os.chdir(self.output_dir)
        helpers.silence_log(True)

        self.params = inmembrane.get_params()
        self.params['fasta'] = "input.fasta"
        self.seqids, self.proteins = \

            helpers.create_proteins_dict(self.params['fasta'])