Skip to content

Commit

Permalink
Ensure component grouping is correctly initialised for reaction queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Sep 9, 2016
1 parent 35d5741 commit 7518992
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -275,8 +275,13 @@ public Object visit(ASTGroup node, Object data) {
fullQuery = new QueryAtomContainer(builder);

// keeps track of component grouping
int[] components = new int[0];
int[] components = fullQuery.getProperty(ComponentGrouping.KEY) != null ? fullQuery.getProperty(ComponentGrouping.KEY, int[].class)
: new int[0];
int maxId = 0;
if (components.length > 0) {
for (int id : components)
if (id > maxId) maxId = id;
}

for (int i = 0; i < node.jjtGetNumChildren(); i++) {
ASTSmarts smarts = (ASTSmarts) node.jjtGetChild(i);
Expand All @@ -286,7 +291,7 @@ public Object visit(ASTGroup node, Object data) {
smarts.jjtAccept(this, null);

// update component info
if (smarts.componentId() > 0) {
if (components.length > 0 || smarts.componentId() > 0) {
components = Arrays.copyOf(components, 1 + fullQuery.getAtomCount() + query.getAtomCount());
int id = smarts.componentId();
Arrays.fill(components, fullQuery.getAtomCount(), components.length, id);
Expand Down
Expand Up @@ -183,6 +183,12 @@ public void mismatchedQueryMapsIgnored() throws Exception {
is(2));
}

@Test public void CCBondForming() throws Exception {
assertThat(SmartsPattern.create("([C:1]).([C:2])>>[C:1][C:2]", null)
.matchAll(rsmi("[C-:13]#[N:14].[K+].[CH:3]1=[CH:4][C:5](=[CH:11][CH:12]=[C:2]1[CH2:1]Br)[C:6](=[O:10])[CH:7]2[CH2:8][CH2:9]2>>[CH:3]1=[CH:4][C:5](=[CH:11][CH:12]=[C:2]1[CH2:1][C:13]#[N:14])[C:6](=[O:10])[CH:7]2[CH2:8][CH2:9]2 |f:0.1|")).count(),
is(2));
}

@Test
public void stereo_ring_closures() throws Exception {
Pattern ptrn = SmartsPattern.create("[C@@]1(O[C@@]([C@@]([C@]([C@]1(C)O)(C)O)(O)C)(O)C)(O)C");
Expand Down

0 comments on commit 7518992

Please sign in to comment.