public object Visit(ASTGroup node, object data) { IAtomContainer fullQuery = (IAtomContainer)data; if (fullQuery == null) { fullQuery = new QueryAtomContainer(builder); } // keeps track of component grouping var components = fullQuery.GetProperty <int[]>("COMPONENT.GROUPING", Array.Empty <int>()); int maxId = 0; if (components.Length > 0) { foreach (int id in components) { if (id > maxId) { maxId = id; } } } for (int i = 0; i < node.JjtGetNumChildren(); i++) { ASTSmarts smarts = (ASTSmarts)node.JjtGetChild(i); ringAtoms = new RingIdentifierAtom[10]; query = new QueryAtomContainer(builder); smarts.JjtAccept(this, null); // update component info if (components.Length > 0 || smarts.ComponentId > 0) { components = Arrays.CopyOf(components, 1 + fullQuery.Atoms.Count + query.Atoms.Count); int id = smarts.ComponentId; Arrays.Fill(components, fullQuery.Atoms.Count, components.Length, id); if (id > maxId) { maxId = id; } } fullQuery.Add(query); } // only store if there was a component grouping if (maxId > 0) { components[components.Length - 1] = maxId; // we left space to store how many groups there were fullQuery.SetProperty("COMPONENT.GROUPING", components); } // create tetrahedral elements foreach (var atom in neighbors.Keys) { IList <IAtom> localNeighbors = neighbors[atom]; if (localNeighbors.Count == 4) { fullQuery.StereoElements.Add(new TetrahedralChirality(atom, localNeighbors.ToArray(), TetrahedralStereo.Clockwise)); // <- to be modified later } else if (localNeighbors.Count == 5) { localNeighbors.Remove(atom); // remove central atom (which represented implicit part) fullQuery.StereoElements.Add(new TetrahedralChirality(atom, localNeighbors.ToArray(), TetrahedralStereo.Clockwise)); // <- to be modified later } } // for each double bond, find the stereo bonds. Currently doesn't // handle logical bonds i.e. C/C-,=C/C foreach (var bond in doubleBonds) { IAtom left = bond.Begin; IAtom right = bond.End; StereoBond leftBond = FindStereoBond(left); StereoBond rightBond = FindStereoBond(right); if (leftBond == null || rightBond == null) { continue; } DoubleBondConformation conformation = leftBond.GetDirection(left) == rightBond.GetDirection(right) ? DoubleBondConformation.Together : DoubleBondConformation.Opposite; fullQuery.StereoElements.Add(new DoubleBondStereochemistry(bond, new IBond[] { leftBond, rightBond }, conformation)); } return(fullQuery); }
public object Visit(ASTGroup node, object data) { return(node.JjtGetChild(0).JjtAccept(this, data)); }