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

WIP: Getting cleaner and less error prone HMM parsing ready #61

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

jamaliki
Copy link
Collaborator

@jamaliki jamaliki commented Aug 17, 2023

Hey @althonos

I'm not sure you remember, but we had a chat here about getting ModelAngelo's HMM parsing all done with pyhmmer's utilities: althonos/pyhmmer#40

I think it is close right now, but it seems to be having an issue with the consensus part of the HMM. Could you take a look if you have a chance? I get the following error:

Traceback (most recent call last):
  File "/Users/kiarash/Desktop/code/cambridge/3dem_model_angelo/model-angelo/model_angelo/utils/aa_probs_to_hmm_new.py", line 93, in <module>
    hmm = aa_log_probs_to_hmm("test", probs, confidence)
  File "/Users/kiarash/Desktop/code/cambridge/3dem_model_angelo/model-angelo/model_angelo/utils/aa_probs_to_hmm_new.py", line 83, in aa_log_probs_to_hmm
    hmm.validate()
  File "pyhmmer/plan7.pyx", line 3220, in pyhmmer.plan7.HMM.validate
  File "pyhmmer/plan7.pyx", line 3246, in pyhmmer.plan7.HMM.validate
ValueError: Invalid HMM: p7H_CONS flag down, but consensus string is present

There's quite a bit of code, but what is really important is line 66 onwards. If you wish, you can see how we do it in aa_probs_to_hmm.py

@althonos
Copy link

Hi @jamaliki,

This error was caused by an outdated fix (althonos/pyhmmer#5) which was causing the consensus flag to be always set. Since the update to v0.10.0 it shouldn't be needed anymore (but I forgot to remove it), so I'l make a new patch release. Make sure to require at least PyHMMER v0.10.1 and you should be all set! :)

@jamaliki
Copy link
Collaborator Author

Thanks, worked like a charm @althonos! Going to do some testing but it should be the same. Are there any ways to write the composition row as well?

@althonos
Copy link

You don't have to set it manually, it will be computed from the HMM occupancy, just call HMM.set_composition after you're done filling it (typically right before HMM.validate). Then the consensus attribute of the HMM will be a VectorF that you're free to edit if you want.

You can also call HMM.set_consensus if you wish to build or record a consensus.

@jamaliki
Copy link
Collaborator Author

Thanks @althonos, that's great!

@jamaliki jamaliki merged commit 66d9e78 into main Oct 11, 2023
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.

2 participants