# Path: inmembrane/helpers.py
# def dict_get(this_dict, prop):
#     """
#     Useful helper function to get values from dicts. Takes in
#     the possibility that the key may not exist, and in that
#     case returns False. Makes it easier to write code to avoid
#     handling the case of missing keys.
#     """
#     if prop not in this_dict:
#         return False
#     return this_dict[prop]
# 
# def chop_nterminal_peptide(protein, i_cut):
#     """
#     Finds all transmembrane fields in protein ("*_loops" and "*_helices")
#     and deletes an N-terminal section of the protein indicated by i_cut.
# 
#     Assuming the topology of inner and outer loops remain the same, this
#     may delete a certain number of elements at the N-terminus. Allows a
#     simple way of removing lipo-protein and secretion-protein signals from
#     the evaluation of the outer_loops of the protein.
#     """
#     protein['sequence_length'] -= i_cut
#     for prop in protein:
#         if '_loops' in prop or '_helices' in prop:
#             sses = protein[prop]
#             for i in range(len(sses)):
#                 j, k = sses[i]
#                 sses[i] = (j - i_cut, k - i_cut)
#     for prop in protein:
#         if '_loops' in prop or '_helices' in prop:
#             sses = protein[prop]
#             for i in reversed(range(len(sses))):
#                 j, k = sses[i]
#                 # tests if this loop or TM-helix has been cut out
#                 if j <= 0 and k <= 0:
#                     del sses[i]
#                 # otherewise, neg value means loop or TM-helix is at the new N-terminal
#                 elif j <= 0 and k > 0:
#                     sses[i] = (1, k)
#                     # if a TM-helix gets cut in half and becomes a new N-terminal,
#                     # convert the remaining residues to a loop and remove the helix
#                     if '_helices' in prop:
#                         program = prop.split('_')[0]
#                         for x in protein:
#                             if x == '%s_loops' % program:
#                                 new_N_loop = protein[x][0]
#                                 new_N_loop[0] = 1
#                         del sses[i]
# 
# def log_stderr(s, width=76, comment=True):
#     """
#     Wrapper for all stderr out. Allows future customization.
#     """
#     if LOG_SILENT:
#         return
#     if s and s[-1] != "\n":
#         s += "\n"
#     if not s.startswith("#"):
#         s = "# " + s
#     sys.stderr.write(s)


import os
from inmembrane.helpers import dict_get, chop_nterminal_peptide, log_stderr
                return True
        return False

    # these functions detect if and TM-containing IM proteins
    # have large loops / terminal regions in the periplasm or cytoplasm
    # that may be accessible / inaccessible in spheroplast shaving
    # experiments.
    def has_long_loops(protein, loop_str='_outer_loops', \
                       loop_length=params['internal_exposed_loop_min']):
        for annot in protein:
            if loop_str in annot:
                for loop in protein[annot]:
                    l_len = loop[1] - loop[0]
                    if l_len >= loop_length:
                        return True
        return False

    def long_in_periplasm(protein, \
                          loop_length=params['internal_exposed_loop_min']):
        return has_long_loops(protein, '_outer_loops', loop_length)

    def long_in_cytoplasm(protein, \
                          loop_length=params['internal_exposed_loop_min']):
        return has_long_loops(protein, '_inner_loops', loop_length)

    details = []
    category = "UNKNOWN"
    is_hmm_profile_match = dict_get(protein, 'hmmsearch')
    is_signalp = dict_get(protein, 'is_signalp')
    is_tatfind = dict_get(protein, 'is_tatfind')

# Path: inmembrane/helpers.py
# def dict_get(this_dict, prop):
#     """
#     Useful helper function to get values from dicts. Takes in
#     the possibility that the key may not exist, and in that
#     case returns False. Makes it easier to write code to avoid
#     handling the case of missing keys.
#     """
#     if prop not in this_dict:
#         return False
#     return this_dict[prop]
# 
# def chop_nterminal_peptide(protein, i_cut):
#     """
#     Finds all transmembrane fields in protein ("*_loops" and "*_helices")
#     and deletes an N-terminal section of the protein indicated by i_cut.
# 
#     Assuming the topology of inner and outer loops remain the same, this
#     may delete a certain number of elements at the N-terminus. Allows a
#     simple way of removing lipo-protein and secretion-protein signals from
#     the evaluation of the outer_loops of the protein.
#     """
#     protein['sequence_length'] -= i_cut
#     for prop in protein:
#         if '_loops' in prop or '_helices' in prop:
#             sses = protein[prop]
#             for i in range(len(sses)):
#                 j, k = sses[i]
#                 sses[i] = (j - i_cut, k - i_cut)
#     for prop in protein:
#         if '_loops' in prop or '_helices' in prop:
#             sses = protein[prop]
#             for i in reversed(range(len(sses))):
#                 j, k = sses[i]
#                 # tests if this loop or TM-helix has been cut out
#                 if j <= 0 and k <= 0:
#                     del sses[i]
#                 # otherewise, neg value means loop or TM-helix is at the new N-terminal
#                 elif j <= 0 and k > 0:
#                     sses[i] = (1, k)
#                     # if a TM-helix gets cut in half and becomes a new N-terminal,
#                     # convert the remaining residues to a loop and remove the helix
#                     if '_helices' in prop:
#                         program = prop.split('_')[0]
#                         for x in protein:
#                             if x == '%s_loops' % program:
#                                 new_N_loop = protein[x][0]
#                                 new_N_loop[0] = 1
#                         del sses[i]
# 
# def log_stderr(s, width=76, comment=True):
#     """
#     Wrapper for all stderr out. Allows future customization.
#     """
#     if LOG_SILENT:
#         return
#     if s and s[-1] != "\n":
#         s += "\n"
#     if not s.startswith("#"):
#         s = "# " + s
#     sys.stderr.write(s)


# Path: inmembrane/protocols/gram_neg.py
import os
from inmembrane.helpers import dict_get, chop_nterminal_peptide, log_stderr

                return True
        return False

    # these functions detect if and TM-containing IM proteins
    # have large loops / terminal regions in the periplasm or cytoplasm
    # that may be accessible / inaccessible in spheroplast shaving
    # experiments.
    def has_long_loops(protein, loop_str='_outer_loops', \
                       loop_length=params['internal_exposed_loop_min']):
        for annot in protein:
            if loop_str in annot:
                for loop in protein[annot]:
                    l_len = loop[1] - loop[0]
                    if l_len >= loop_length:
                        return True
        return False

    def long_in_periplasm(protein, \
                          loop_length=params['internal_exposed_loop_min']):
        return has_long_loops(protein, '_outer_loops', loop_length)

    def long_in_cytoplasm(protein, \
                          loop_length=params['internal_exposed_loop_min']):
        return has_long_loops(protein, '_inner_loops', loop_length)

    details = []
    category = "UNKNOWN"
    is_hmm_profile_match = dict_get(protein, 'hmmsearch')
    is_signalp = dict_get(protein, 'is_signalp')
    is_tatfind = dict_get(protein, 'is_tatfind')

    is_lipop = dict_get(protein, 'is_lipop')