def plotPssm(pssm, fileName):
    dist = numpy.array( pssm.getMatrix(), numpy.float64 ) 
    data = LogoData.from_counts(corebio.seq.unambiguous_rna_alphabet, dist*100)
    options = LogoOptions()
    options.color_scheme = colorscheme.nucleotide
    format = LogoFormat(data, options)
    with open(fileName, 'w') as fout:
      fout.write(png_formatter(data, format))
def plotPssm(pssm, fileName):
    dist = numpy.array( pssm.getMatrix(), numpy.float64 ) 
    data = LogoData.from_counts(corebio.seq.unambiguous_dna_alphabet, dist*100)
    options = LogoOptions()
    options.color_scheme = colorscheme.nucleotide
    format = LogoFormat(data, options)
    fout = open(fileName, 'w')
    png_formatter(data, format, fout)
    fout.close()
def ic(pssm,norm=True):
    bgFreq = [0.21, 0.29, 0.29, 0.21]
    res=0
    pwm=pssm.getMatrix()
    for i in range(len(pwm)):
        res+=2
        for a in [0,1,2,3]:
            if pwm[i][a]!=0:
                if norm==True:
                    res+=pwm[i][a]*math.log(pwm[i][a]/bgFreq[a],2)
                else:
                    res+=pwm[i][a]*math.log(pwm[i][a],2)
    return res