Skip to content

Commit

Permalink
Copy across AAM idx to the resulting SMARTS Query Atoms.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Jun 3, 2016
1 parent f275cea commit 11c5235
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -241,9 +242,13 @@ public Object visit(ASTReaction node, Object data) {

if (roleQueryAtom != null) {
while (rollback < query.getAtomCount()) {
IAtom org = query.getAtom(rollback);
IAtom rep = LogicalOperatorAtom.and(roleQueryAtom, (IQueryAtom) org);
// ensure AAM is propagated
rep.setProperty(CDKConstants.ATOM_ATOM_MAPPING, org.getProperty(CDKConstants.ATOM_ATOM_MAPPING));
AtomContainerManipulator.replaceAtomByAtom(query,
query.getAtom(rollback),
LogicalOperatorAtom.and(roleQueryAtom, (IQueryAtom) query.getAtom(rollback)));
org,
rep);
rollback++;
}
}
Expand Down Expand Up @@ -621,7 +626,10 @@ public Object visit(ASTLowAndExpression node, Object data) {
return left;
}
IQueryAtom right = (IQueryAtom) node.jjtGetChild(1).jjtAccept(this, data);
return LogicalOperatorAtom.and((IQueryAtom) left, right);
IAtom res = LogicalOperatorAtom.and((IQueryAtom) left, right);
if (node.getMapIdx()>0)
res.setProperty(CDKConstants.ATOM_ATOM_MAPPING, node.getMapIdx());
return res;
}

public Object visit(ASTOrExpression node, Object data) {
Expand Down

0 comments on commit 11c5235

Please sign in to comment.