# 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)


import sys, os, time, json, re, urllib2
import logging
from suds.client import Client
from suds.bindings import binding
from inmembrane.helpers import log_stderr

        client = Client(url, cache=None)

        request = client.factory.create('runService.parameters')

        # this is a horrible horrible workaround to account for the fact that
        # the lipop SOAP service returns null results if there is are certain
        # non-alphanumeric characters in the sequence id provided. horrible.
        lipop_seq_id_mapping = {}
        seqcount = 0

        sys.stderr.write("# ")
        for seqid in seqid_batch:
            seq = client.factory.create(
                'runService.parameters.sequencedata.sequence')

            # workaround: removes any non-alphanumeric character (except '_') and adds
            # a unique number to the start to ensure every id is unique after mangling
            newseqid = `seqcount` + re.sub(r'[^\w]', "", seqid)
            seqcount += 1
            lipop_seq_id_mapping[newseqid] = seqid
            seq.id = newseqid
            # seq.id = seqid
            seq.seq = proteins[seqid]['seq']

            request.sequencedata.sequence.append(seq)
            sys.stderr.write(".")
        try:
            response = client.service.runService(request)
        except urllib2.URLError as e:

# 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)


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


        client = Client(url, cache=None)

        request = client.factory.create('runService.parameters')

        # this is a horrible horrible workaround to account for the fact that
        # the lipop SOAP service returns null results if there is are certain
        # non-alphanumeric characters in the sequence id provided. horrible.
        lipop_seq_id_mapping = {}
        seqcount = 0

        sys.stderr.write("# ")
        for seqid in seqid_batch:
            seq = client.factory.create(
                'runService.parameters.sequencedata.sequence')

            # workaround: removes any non-alphanumeric character (except '_') and adds
            # a unique number to the start to ensure every id is unique after mangling
            newseqid = `seqcount` + re.sub(r'[^\w]', "", seqid)
            seqcount += 1
            lipop_seq_id_mapping[newseqid] = seqid
            seq.id = newseqid
            # seq.id = seqid
            seq.seq = proteins[seqid]['seq']

            request.sequencedata.sequence.append(seq)
            sys.stderr.write(".")
        try:
            response = client.service.runService(request)
        except urllib2.URLError as e:

            log_stderr("ERROR LipoP(web) failed: '%s'" % `e.reason`)