Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rectified matrianglify function #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

htalibart
Copy link

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.

@croth1
Copy link

croth1 commented Jul 27, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants