# 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/plugins/tmhmm.py
# def annotate(params, proteins):
# def parse_tmhmm(text, proteins, id_mapping=[]):
# 
# Path: inmembrane/tests/PluginTestBase.py
# 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'])


import os
import unittest
import sys
import inmembrane
import inmembrane.tests
import inmembrane
import inmembrane.plugins as plugins
from inmembrane import helpers
from inmembrane.plugins import tmhmm
from inmembrane.tests.PluginTestBase import PluginTestBase

    def test_tmhmm(self):
        if not self.params['tmhmm_bin']:
            self.params['tmhmm_bin'] = 'tmhmm'

        tmhmm.annotate(self.params, self.proteins)

        # helpers.print_proteins(self.proteins)

        self.expected_output = {
            'SPy_1392': {
                'tmhmm_outer_loops':
                    [(30, 43), (94, 102), (160, 163), (244, 257), (307, 310),
                     (366, 374)],
                'name': 'SPy_1392 from AE004092',
                'tmhmm_helices':
                    [(7, 29), (44, 66), (73, 93), (103, 125), (137, 159),
                     (164, 186), (221, 243), (258, 280), (287, 306), (311, 330),
                     (343, 365), (375, 394)],
                'tmhmm_inner_loops':
                    [(1, 6), (67, 72), (126, 136), (187, 220), (281, 286),
                     (331, 342), (395, 398)],
            },
            'SPy_1379': {
                'tmhmm_outer_loops':
                    [(56, 58), (106, 178), (231, 244), (307, 320), (373, 381),
                     (434, 437)],
                'name': 'SPy_1379 from AE004092',
                'tmhmm_helices':
                    [(33, 55), (59, 81), (88, 105), (179, 201), (208, 230),

# 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/plugins/tmhmm.py
# def annotate(params, proteins):
# def parse_tmhmm(text, proteins, id_mapping=[]):
# 
# Path: inmembrane/tests/PluginTestBase.py
# 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'])


# Path: inmembrane/tests/test_tmhmm.py
import os
import unittest
import sys
import inmembrane
import inmembrane.tests
import inmembrane
import inmembrane.plugins as plugins
from inmembrane import helpers
from inmembrane.plugins import tmhmm
from inmembrane.tests.PluginTestBase import PluginTestBase


    def test_tmhmm(self):
        if not self.params['tmhmm_bin']:
            self.params['tmhmm_bin'] = 'tmhmm'

        tmhmm.annotate(self.params, self.proteins)

        # helpers.print_proteins(self.proteins)

        self.expected_output = {
            'SPy_1392': {
                'tmhmm_outer_loops':
                    [(30, 43), (94, 102), (160, 163), (244, 257), (307, 310),
                     (366, 374)],
                'name': 'SPy_1392 from AE004092',
                'tmhmm_helices':
                    [(7, 29), (44, 66), (73, 93), (103, 125), (137, 159),
                     (164, 186), (221, 243), (258, 280), (287, 306), (311, 330),
                     (343, 365), (375, 394)],
                'tmhmm_inner_loops':
                    [(1, 6), (67, 72), (126, 136), (187, 220), (281, 286),
                     (331, 342), (395, 398)],
            },
            'SPy_1379': {
                'tmhmm_outer_loops':
                    [(56, 58), (106, 178), (231, 244), (307, 320), (373, 381),
                     (434, 437)],
                'name': 'SPy_1379 from AE004092',
                'tmhmm_helices':
                    [(33, 55), (59, 81), (88, 105), (179, 201), (208, 230),

                     (245, 267), (288, 306), (321, 343), (350, 372), (382, 404),