void append(Expr expr) { QueryAtom atom = new QueryAtom(mol.getBuilder()); atom.setExpression(expr); append(atom); }
private boolean parseAtomExpr() { QueryAtom atom = new QueryAtom(mol.getBuilder()); Expr expr = new Expr(Expr.Type.NONE); atom.setExpression(expr); if (!parseExplicitHydrogen(atom, expr) && !parseAtomExpr(atom, expr, '\0')) { error = "Invalid atom expression"; return false; } append(atom); return true; }
QueryAtom qatom = new QueryAtom(expr);
/** * Make a query atom that matches atomic number, h count, valence, and * connectivity. This effectively provides an exact match for that atom * type. * * @param mol molecule * @param atom atom of molecule * @return the query atom (null if attachment point) */ private IQueryAtom matchExact(final IAtomContainer mol, final IAtom atom) { final IChemObjectBuilder bldr = atom.getBuilder(); int elem = atom.getAtomicNumber(); // attach atom skipped if (elem == 0) return null; int hcnt = atom.getImplicitHydrogenCount(); int val = hcnt; int con = hcnt; for (IBond bond : mol.getConnectedBondsList(atom)) { val += bond.getOrder().numeric(); con++; if (bond.getOther(atom).getAtomicNumber() == 1) hcnt++; } Expr expr = new Expr(Expr.Type.ELEMENT, elem) .and(new Expr(Expr.Type.TOTAL_DEGREE, con)) .and(new Expr(Expr.Type.TOTAL_H_COUNT, hcnt)) .and(new Expr(Expr.Type.VALENCE, val)); return new QueryAtom(expr); }
/** * Make a query atom that matches atomic number, h count, valence, and * connectivity. This effectively provides an exact match for that atom * type. * * @param mol molecule * @param atom atom of molecule * @return the query atom (null if attachment point) */ private IQueryAtom matchExact(final IAtomContainer mol, final IAtom atom) { final IChemObjectBuilder bldr = atom.getBuilder(); int elem = atom.getAtomicNumber(); // attach atom skipped if (elem == 0) return null; int hcnt = atom.getImplicitHydrogenCount(); int val = hcnt; int con = hcnt; for (IBond bond : mol.getConnectedBondsList(atom)) { val += bond.getOrder().numeric(); con++; if (bond.getOther(atom).getAtomicNumber() == 1) hcnt++; } Expr expr = new Expr(Expr.Type.ELEMENT, elem) .and(new Expr(Expr.Type.TOTAL_DEGREE, con)) .and(new Expr(Expr.Type.TOTAL_H_COUNT, hcnt)) .and(new Expr(Expr.Type.VALENCE, val)); return new QueryAtom(expr); }