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

Fix error handling in MEGAN #29

Merged
merged 5 commits into from
Sep 12, 2023
Merged

Conversation

kmaziarz
Copy link
Contributor

In search experiments, it can be observed that MEGAN sometimes produces odd molecules containing C+ atoms, which violate valence despite being accepted as valid by rdkit. These molecules fail sanitization through MEGAN's fix_explicit_hs utility, and so far our wrapper has been ignoring this and passing the molecule through to the model to propose reactions (likely pushing the problematic C+ atom to reactants). In this PR, the underlying model is not called on inputs which fail fix_explicit_hs, and rather an empty list of reactions is returned in this case. Relatedly, I also silenced some of the other internal warnings produced by the MEGAN model by applying a (now improved) suppress_outputs context manager.

Copy link
Collaborator

@AustinT AustinT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (although I only checked it superficially). It's nice to see a TODO comment in the code get dealt with!

syntheseus/reaction_prediction/inference/megan.py Outdated Show resolved Hide resolved
@kmaziarz kmaziarz merged commit 8516d31 into main Sep 12, 2023
3 checks passed
@kmaziarz kmaziarz deleted the kmaziarz/fix-megan-error-handling branch September 12, 2023 20:14
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