# Path: inmembrane/helpers.py
# 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)
# 
# def print_proteins(proteins):
#     """
#     Prints out the proteins dictionary in a formatted
#     manner that is also Python-eval compatible.
#     """
#     print "{"
#     for seqid in proteins:
#         print "  '%s': {" % seqid
#         for key, value in proteins[seqid].items():
#             print "    '%s': %s, " % (key, repr(value))
#         print "  },"
#     print "}"
#     # Standard Library alternative
#     # import pprint
#     # pp = pprint.PrettyPrinter(indent=4)
#     # print pp.pformat(proteins)


import sys, os, time, json, re
import logging
from suds.client import Client
from suds.bindings import binding
from inmembrane.helpers import log_stderr, print_proteins
                   u"L. L. Sonnhammer (2001) Predicting Transmembrane Protein "
                   u"Topology with a Hidden Markov Model: Application to "
                   u"Complete Genomes. J. Mol. Biol. 305:567-580. \n"
                   u"<http://dx.doi.org/10.1006/jmbi.2000.4315>",
            'name': "TMHMM 2.0"
            }

__DEBUG__ = False



def annotate(params, proteins, \
             # url = 'http://www.cbs.dtu.dk/ws/TMHMM/TMHMM_2_0_ws0.wsdl', \
             # url = 'http://www.cbs.dtu.dk/ws/TMHMM/TMHMM_2_0_ws1.wsdl', \
             url="http://raw.github.com/boscoh/inmembrane/master/inmembrane/plugins/extra/TMHMM_2_0_ws0.wsdl", \
             batchsize=2000, \
             force=False):
    mapping = {'TMhelix': 'tmhmm_helices', \
               'outside': 'tmhmm_outer_loops', \
               'inside': 'tmhmm_inner_loops', \
               }

    if __DEBUG__:
        logging.basicConfig(level=logging.INFO)
        # soap messages (in&out) and http headers
        logging.getLogger('suds.client').setLevel(logging.DEBUG)

        # grab the cached results if present
    outfile = "tmhmm_web.out"
    if not force and os.path.isfile(outfile):

# Path: inmembrane/helpers.py
# 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)
# 
# def print_proteins(proteins):
#     """
#     Prints out the proteins dictionary in a formatted
#     manner that is also Python-eval compatible.
#     """
#     print "{"
#     for seqid in proteins:
#         print "  '%s': {" % seqid
#         for key, value in proteins[seqid].items():
#             print "    '%s': %s, " % (key, repr(value))
#         print "  },"
#     print "}"
#     # Standard Library alternative
#     # import pprint
#     # pp = pprint.PrettyPrinter(indent=4)
#     # print pp.pformat(proteins)


# Path: inmembrane/plugins/tmhmm_web.py
import sys, os, time, json, re
import logging
from suds.client import Client
from suds.bindings import binding
from inmembrane.helpers import log_stderr, print_proteins

                   u"L. L. Sonnhammer (2001) Predicting Transmembrane Protein "
                   u"Topology with a Hidden Markov Model: Application to "
                   u"Complete Genomes. J. Mol. Biol. 305:567-580. \n"
                   u"<http://dx.doi.org/10.1006/jmbi.2000.4315>",
            'name': "TMHMM 2.0"
            }

__DEBUG__ = False



def annotate(params, proteins, \
             # url = 'http://www.cbs.dtu.dk/ws/TMHMM/TMHMM_2_0_ws0.wsdl', \
             # url = 'http://www.cbs.dtu.dk/ws/TMHMM/TMHMM_2_0_ws1.wsdl', \
             url="http://raw.github.com/boscoh/inmembrane/master/inmembrane/plugins/extra/TMHMM_2_0_ws0.wsdl", \
             batchsize=2000, \
             force=False):
    mapping = {'TMhelix': 'tmhmm_helices', \
               'outside': 'tmhmm_outer_loops', \
               'inside': 'tmhmm_inner_loops', \
               }

    if __DEBUG__:
        logging.basicConfig(level=logging.INFO)
        # soap messages (in&out) and http headers
        logging.getLogger('suds.client').setLevel(logging.DEBUG)

        # grab the cached results if present
    outfile = "tmhmm_web.out"
    if not force and os.path.isfile(outfile):

        log_stderr("# -> skipped: %s already exists" % outfile)