def transformByDistance(wV, subModel, alphabetSize=4):
    """
    transform wV by given substitution matrix
    """
    nc = [0.0]*alphabetSize
    for i in xrange(0, alphabetSize):
        j = wV[i]
        k = subModel[i]
        for l in xrange(0, alphabetSize):
            nc[l] += j * k[l]
    return nc
transform wV by given substitution matrix