CCMgen
CCMgen copied to clipboard
rectified matrianglify function
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.
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