mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

RDKit converter inferring

Open cbouy opened this issue 2 years ago • 13 comments
trafficstars

Fixes part of #3996

Changes made in this Pull Request:

  • Refactored the RDKit converter code to move the inferring code in a separate RDKitInferring module. The bond order and charges inferer has been move to a MDAnalysisInferer dataclass in there.
  • Renamed NoImplicit parameter to implicit_hydrogens and added a separate inferer argument (defaults to MDAnalysisInferer(). Passing NoImplicit to any of the relevant functions will issue a warning and make the necessary arrangements to execute the code in a backwards-compatible way (i.e. implicit_hydrogens=not NoImplicit and if NoImplicit is False: inferer=None).
  • Added TemplateInferer that wraps around RDKit's AssignBondOrdersFromTemplate. There's an additional adjust_hydrogens parameter that when set to True allows one to assign bond orders from a template molecule with implicit hydrogens to an input molecule with explicit hydrogens (which won't work with the base AssignBondOrdersFromTemplate for charged molecules where the charged atom has a hydrogen). I originally had this code in ProLIF for dealing with PDBQT inputs, figured it would be worth here as well.
  • Added RDKit's rdDetermineBonds inferring wrapper as showcased here.

PR Checklist

  • [x] Tests?
  • [x] Docs?
  • [x] CHANGELOG updated?
  • [x] Issue raised/referenced?

Developers certificate of origin


:books: Documentation preview :books:: https://mdanalysis--4305.org.readthedocs.build/en/4305/

cbouy avatar Sep 29 '23 15:09 cbouy

Hello @cbouy! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 67:80: E501 line too long (82 > 79 characters) Line 445:80: E501 line too long (80 > 79 characters)

Line 331:80: E501 line too long (104 > 79 characters) Line 333:80: E501 line too long (104 > 79 characters) Line 335:80: E501 line too long (104 > 79 characters) Line 337:80: E501 line too long (104 > 79 characters) Line 339:80: E501 line too long (104 > 79 characters) Line 341:80: E501 line too long (104 > 79 characters) Line 343:80: E501 line too long (104 > 79 characters) Line 345:80: E501 line too long (104 > 79 characters) Line 347:80: E501 line too long (104 > 79 characters) Line 349:80: E501 line too long (104 > 79 characters) Line 351:80: E501 line too long (104 > 79 characters) Line 353:80: E501 line too long (104 > 79 characters)

Line 476:80: E501 line too long (80 > 79 characters) Line 904:80: E501 line too long (85 > 79 characters) Line 905:80: E501 line too long (84 > 79 characters) Line 906:80: E501 line too long (80 > 79 characters) Line 907:80: E501 line too long (88 > 79 characters)

Comment last updated at 2024-08-26 15:54:51 UTC

pep8speaks avatar Sep 29 '23 15:09 pep8speaks

Linter Bot Results:

Hi @cbouy! Thanks for making this PR. We linted your code and found the following:

Some issues were found with the formatting of your code.

Code Location Outcome
main package ⚠️ Possible failure
testsuite ⚠️ Possible failure

Please have a look at the darker-main-code and darker-test-code steps here for more details: https://github.com/MDAnalysis/mdanalysis/actions/runs/10563005550/job/29262240571


Please note: The black linter is purely informational, you can safely ignore these outcomes if there are no flake8 failures!

github-actions[bot] avatar Sep 29 '23 15:09 github-actions[bot]

Codecov Report

Attention: Patch coverage is 98.49057% with 4 lines in your changes missing coverage. Please review.

Project coverage is 93.61%. Comparing base (d73995a) to head (31964b4).

Files Patch % Lines
package/MDAnalysis/converters/RDKit.py 95.91% 0 Missing and 2 partials :warning:
package/MDAnalysis/converters/RDKitInferring.py 99.06% 0 Missing and 2 partials :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4305      +/-   ##
===========================================
- Coverage    93.62%   93.61%   -0.01%     
===========================================
  Files          173      186      +13     
  Lines        21419    22575    +1156     
  Branches      3978     4004      +26     
===========================================
+ Hits         20053    21134    +1081     
- Misses         903      976      +73     
- Partials       463      465       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Sep 29 '23 16:09 codecov[bot]

Thanks @cbouy ! From a quick look this seems great, I'll try to review it at some point over the next week (unless someone gets to it first).

P.S. For others that might review here - codecov seems to be throwing a bunch of "uncovered code" messages (when they seem like they are). Cycling the PR might clear them, but I don't think it's a major necessity right now.

IAlibay avatar Dec 18 '23 14:12 IAlibay

@cbouy are you still working on the PR or is this ready for review?

orbeckst avatar Mar 29 '24 21:03 orbeckst

Should be ready for review, I'll just need to update the changelog when ready for merging

cbouy avatar Mar 30 '24 16:03 cbouy

That's great.

Can you please add the CHANGELOG update right away, even if it will require resolving a merge conflict later? The summary there tends to be really helpful for assessing a PR.... and typically no reviewer will green-light such a PR without the CHANGELOG in place anyway.

orbeckst avatar Mar 30 '24 17:03 orbeckst

@richardjgowers do you have capacity to shepherd the PR to completion? If not please let me know and un-assign yourself. Thanks!

orbeckst avatar Mar 30 '24 17:03 orbeckst

Sorry for the spam, should be good now!

cbouy avatar Apr 01 '24 19:04 cbouy

@richardjgowers are you able to review this PR yourself or is there someone you could ping? From my very cursory glance, this looks pretty much ready and would be good to get in, given our roadmap towards "better chemistry".

orbeckst avatar Jun 11 '24 04:06 orbeckst

Not sure why one of the azure test is timing out, or why the bot removed some of the tags but this is re-ready for review 😅

cbouy avatar Aug 26 '24 18:08 cbouy

/azp run

IAlibay avatar Aug 26 '24 19:08 IAlibay

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Aug 26 '24 19:08 azure-pipelines[bot]