(infile=None, counts=None)
return motif_scores, motif_scores_agg, pfm, counts
Load motifs file
Load motifs file
Load motifs file
def load_motif(infile=None, counts=None):
    """Load motifs file
    """
    if not counts:
        A, C, G, T = np.loadtxt(infile, unpack=True)
        # Add psuedocounts
        A = np.array(A)  #+ 1
        C = np.array(C)  #+ 1
        G = np.array(G)  #+ 1
        T = np.array(T)  #+ 1
        counts = OrderedDict({'A': A, 'C': C, 'G': G, 'T': T})
    pfm, n_occur = calc_pfm(counts)
    ic = calc_relative_information(pfm, n_occur)

    motif_scores = []
    motif_scores_agg = []
    for i in range(0, len(counts['A'])):
        scores = [(b, ic[b][i]) for b in bases]
        scores.sort(key=lambda t: t[1])
        motif_scores.append(scores)
        motif_scores_agg.append(np.sum([ic[b][i] for b in bases]))
    return motif_scores, motif_scores_agg, pfm, counts
def load_motif ( infile = None , counts = None ) : if not counts : A , C , G , T = np . loadtxt ( infile , unpack = True ) # Add psuedocounts A = np . array ( A ) #+ 1 C = np . array ( C ) #+ 1 G = np . array ( G ) #+ 1 T = np . array ( T ) #+ 1 counts = OrderedDict ( { 'A' : A , 'C' : C , 'G' : G , 'T' : T } ) pfm , n_occur = calc_pfm ( counts ) ic = calc_relative_information ( pfm , n_occur ) motif_scores = [ ] motif_scores_agg = [ ] for i in range ( 0 , len ( counts [ 'A' ] ) ) : scores = [ ( b , ic [ b ] [ i ] ) for b in bases ] scores . sort ( key = lambda t : t [ 1 ] ) motif_scores . append ( scores ) motif_scores_agg . append ( np . sum ( [ ic [ b ] [ i ] for b in bases ] ) ) return motif_scores , motif_scores_agg , pfm , counts