# 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
    :arg name: Name of the TFFM (default: "TFFM")
    :type name: str
    :arg nb_res: Number of residues to be used to compute the
        background->foreground transition probabilities
        (default: 0 meaning that we will assume a 100nt length for the ChIP-seq
        used to derive the PFM)
    :type nb_residues: int
    :arg first_letters: Number of occurrences of ACGT at the begining of
        sequences in the background (default: default values will give
        equiprobabilities for A, C, G, and T
    :type first_letters: dic of str->int

    :returns: The TFFM initialized from the PFM
    :rtype: :class:`TFFM`

    :see also: :func:`tffm_from_meme`

    :note: As the PFM is used to initialize the TFFM, a pseudocount of 1 is
        added to all the values in the PFM

    """

    # extract the counts in the first column of the PFM
    first_counts = [count[0] for count in motif.counts.values()]
    nb_seq = reduce(lambda x, y: x + y, first_counts)
    if not first_letters:
        equi = nb_seq / 4
        first_letters = {'A': equi, 'C': equi, 'G': equi, 'T': equi}
    if not nb_res:
        nb_res = nb_seq * 100

# 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

    :arg name: Name of the TFFM (default: "TFFM")
    :type name: str
    :arg nb_res: Number of residues to be used to compute the
        background->foreground transition probabilities
        (default: 0 meaning that we will assume a 100nt length for the ChIP-seq
        used to derive the PFM)
    :type nb_residues: int
    :arg first_letters: Number of occurrences of ACGT at the begining of
        sequences in the background (default: default values will give
        equiprobabilities for A, C, G, and T
    :type first_letters: dic of str->int

    :returns: The TFFM initialized from the PFM
    :rtype: :class:`TFFM`

    :see also: :func:`tffm_from_meme`

    :note: As the PFM is used to initialize the TFFM, a pseudocount of 1 is
        added to all the values in the PFM

    """

    # extract the counts in the first column of the PFM
    first_counts = [count[0] for count in motif.counts.values()]
    nb_seq = reduce(lambda x, y: x + y, first_counts)
    if not first_letters:
        equi = nb_seq / 4
        first_letters = {'A': equi, 'C': equi, 'G': equi, 'T': equi}
    if not nb_res:
        nb_res = nb_seq * 100

    if kind == TFFM_KIND.FIRST_ORDER: