Skip to content

Query bond funcs - #938

Merged
egonw merged 2 commits into
mainfrom
query-bond-funcs
Sep 8, 2023
Merged

Query bond funcs#938
egonw merged 2 commits into
mainfrom
query-bond-funcs

Conversation

@johnmay

@johnmay johnmay commented Nov 27, 2022

Copy link
Copy Markdown
Member

At some point these went out of sync with the main AtomContainer, the order.numeric() should be compared and not the ordinal() since "unset" has the largest enum in the ordinal. We also make this function null safe since it's highly likely Query molecules have unset bond order.

Fixes #920.

I then was pondering an exception for providing a query molecule to the atom type matcher, but since we have the fall-back "X" atom type I think logging a warning makes most sense. If a caller wants to avoid the warning they should check if the molecule is a query before hand.

@sonarqubecloud

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@johnmay
johnmay requested a review from egonw September 8, 2023 06:55
@egonw egonw self-assigned this Sep 8, 2023

@egonw egonw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am happy with this patch. One thing I am wondering if it should not just fail when an IQueryAtomContainer is given.

IAtomType type;
if (atom instanceof IPseudoAtom || atom.getAtomicNumber() == null) {
if (atomContainer instanceof IQueryAtomContainer || atom instanceof IQueryAtom)
logger.warn("A query molecule/atom was provided to the atom type matcher");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch!

@egonw
egonw merged commit 4b191ba into main Sep 8, 2023
@johnmay

johnmay commented Sep 8, 2023

Copy link
Copy Markdown
Member Author

Possible but I didn't want to make that decision. I figurered warning that "things might not work as you expect" was a reasonable middle ground.

@johnmay
johnmay deleted the query-bond-funcs branch October 20, 2024 14:12
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.

NPE in CDKAtomTypeMatcher

2 participants