# Path: constants.py
# ALPHABET = ['A', 'C', 'G', 'T']
# 
# EXTENDED_ALPHABET = ['A', 'C', 'G', 'T', 'N', 'M', 'K']
# 
# TFFM_KIND = enum(FIRST_ORDER="1st-order", DETAILED="detailed",
#                  ZERO_ORDER="0-order")
# 
# LOGO_TYPE = enum(SUMMARY="summary", DENSE="dense")


import sys
import os
import math
import re
import ghmm
import drawing
import exceptions_errors
import utils
import hit_module
from Bio.Alphabet import IUPAC
from Bio import SeqIO
from Bio import motifs
from constants import ALPHABET, EXTENDED_ALPHABET, TFFM_KIND, LOGO_TYPE
            considered significant (given in this order).
        :rtype: tuple

        """

        pos_ic = self.get_positions_ic()
        first = 1
        last = len(self)
        while first <= last and pos_ic[first - 1] < threshold:
            first += 1
        while last > 0 and pos_ic[last - 1] < threshold:
            last -= 1
        return first, last

    def _get_posterior_proba(self, sequence_split):
        """
        Get the posterior probabilities at each nucleotide position given the
        TFFM.

        :arg sequence_split: The sequence splitted in subsequences to not
            consider non ACGT nucleotides.
        :type sequence_split: list

        :returns: The posterior probabilities at each position of the sequence.
        :rtype: list of list

        :note: One example of a sequence_split is ["ACT", "N", "ATC"].

        """


# Path: constants.py
# ALPHABET = ['A', 'C', 'G', 'T']
# 
# EXTENDED_ALPHABET = ['A', 'C', 'G', 'T', 'N', 'M', 'K']
# 
# TFFM_KIND = enum(FIRST_ORDER="1st-order", DETAILED="detailed",
#                  ZERO_ORDER="0-order")
# 
# LOGO_TYPE = enum(SUMMARY="summary", DENSE="dense")


# Path: tffm_module.py
import sys
import os
import math
import re
import ghmm
import drawing
import exceptions_errors
import utils
import hit_module
from Bio.Alphabet import IUPAC
from Bio import SeqIO
from Bio import motifs
from constants import ALPHABET, EXTENDED_ALPHABET, TFFM_KIND, LOGO_TYPE

            considered significant (given in this order).
        :rtype: tuple

        """

        pos_ic = self.get_positions_ic()
        first = 1
        last = len(self)
        while first <= last and pos_ic[first - 1] < threshold:
            first += 1
        while last > 0 and pos_ic[last - 1] < threshold:
            last -= 1
        return first, last

    def _get_posterior_proba(self, sequence_split):
        """
        Get the posterior probabilities at each nucleotide position given the
        TFFM.

        :arg sequence_split: The sequence splitted in subsequences to not
            consider non ACGT nucleotides.
        :type sequence_split: list

        :returns: The posterior probabilities at each position of the sequence.
        :rtype: list of list

        :note: One example of a sequence_split is ["ACT", "N", "ATC"].

        """


        ghmm_extended_alphabet = ghmm.Alphabet(EXTENDED_ALPHABET)