CCMgen icon indicating copy to clipboard operation
CCMgen copied to clipboard

rectified matrianglify function

Open htalibart opened this issue 6 years ago • 1 comments

Dear all,

I noticed that the "matrianglify" function did not yield the correct output for the BLOSUM62 matrix given in the same file. It was a problem of indexes, so I rewrote the function. (I am not aware of a numpy function to do this so I used "for" loops, maybe there is a more optimal way to do it ?)

Hope this will be useful.

htalibart avatar Dec 16 '19 10:12 htalibart

Dear @htalibart,

sorry for the very late reply, I somehow completely missed the notification. Thanks for reporting the issue! You are right, the matrianglify does not return a symmetric matrix - a vectorized version of your bug fix would be:

def matrianglify_t(data, size=20):
    """ Make a symmetric size * size matrix out of an array of triangle array data"""
    mat = np.zeros((size, size))
    mat[np.tril_indices(size)] = data
    sym_mat = np.maximum(mat, mat.T)
    return sym_mat

croth1 avatar Jul 27 '20 08:07 croth1