Skip to content

Commit

Permalink
Log a warning if a query molecule is passed in to the atom-type matcher.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Sep 8, 2023
1 parent 29889a8 commit 4b191ba
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@
import org.openscience.cdk.interfaces.IElement;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.interfaces.ISingleElectron;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
import org.openscience.cdk.ringsearch.RingSearch;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.BondManipulator;

/**
Expand All @@ -66,6 +70,7 @@ public class CDKAtomTypeMatcher implements IAtomTypeMatcher {
private final static Object LOCK = new Object();

private static final Map<Integer, Map<IChemObjectBuilder, CDKAtomTypeMatcher>> factories = new ConcurrentHashMap<>(5);
private ILoggingTool logger = LoggingToolFactory.createLoggingTool(CDKAtomTypeMatcher.class);

private CDKAtomTypeMatcher(IChemObjectBuilder builder, int mode) {
factory = AtomTypeFactory.getInstance("org/openscience/cdk/dict/data/cdk-atom-types.owl", builder);
Expand Down Expand Up @@ -125,9 +130,10 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)

private IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom, RingSearch searcher, List<IBond> connectedBonds) throws CDKException {
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");
if (atom instanceof IPseudoAtom || atom.getAtomicNumber() == null)
return factory.getAtomType("X");
}
switch (atom.getAtomicNumber()) {
case IElement.C:
type = perceiveCarbons(atomContainer, atom, searcher, connectedBonds);
Expand Down Expand Up @@ -819,7 +825,7 @@ private IAtomType perceiveNitrogens(IAtomContainer atomContainer, IAtom atom,
if (hasOneSingleElectron(atomContainer, atom)) {
return perceiveNitrogenRadicals(atomContainer, atom);
}

if (connectedBonds == null) connectedBonds = atomContainer.getConnectedBondsList(atom);
if (hasHybridization(atom) && !isCharged(atom)) {
if (atom.getHybridization() == Hybridization.SP1) {
Expand Down

0 comments on commit 4b191ba

Please sign in to comment.