/** * {@inheritDoc} */ @Override public void removeAtom(int pos) { removeAtom(getAtom(pos)); }
/** * Removes all atoms and bond from this container. */ @Override public void removeAllElements() { removeAllElectronContainers(); for (int f = 0; f < getAtomCount(); f++) { getAtom(f).removeListener(this); } atoms = new IAtom[growArraySize]; atomCount = 0; notifyChanged(); }
clone.addAtom((IAtom) getAtom(f).clone());
@Override public String toString() { StringBuilder s = new StringBuilder(); s.append("QueryAtomContainer("); s.append(this.hashCode()); s.append(", #A:").append(getAtomCount()); s.append(", #EC:").append(getElectronContainerCount()); for (int i = 0; i < getAtomCount(); i++) { s.append(", ").append(getAtom(i).toString()); } for (int i = 0; i < getBondCount(); i++) { s.append(", ").append(getBond(i).toString()); } for (int i = 0; i < getLonePairCount(); i++) { s.append(", ").append(getLonePair(i).toString()); } for (int i = 0; i < getSingleElectronCount(); i++) { s.append(", ").append(getSingleElectron(i).toString()); } s.append(')'); return s.toString(); }
/** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder */ @Override public void addBond(int atom1, int atom2, IBond.Order order) { IBond bond = getBuilder().newInstance(IBond.class, getAtom(atom1), getAtom(atom2), order); if (bondCount >= bonds.length) { growBondArray(); } addBond(bond); /* * no notifyChanged() here because addBond(bond) does it already */ }
private TIntIntHashMap makeMapping() { final TIntIntHashMap mapping = new TIntIntHashMap(); for (int k=0; k < query.getAtomCount(); ++k) { final IQueryAtom atom = (IQueryAtom) query.getAtom(k); if (atom instanceof LogicalOperatorAtom) { LogicalOperatorAtom log = (LogicalOperatorAtom)atom; String op = log.getOperator(); if (op.equals("and")) { if (log.getRight() instanceof LogicalOperatorAtom) { IQueryAtom iq = ((LogicalOperatorAtom) log.getRight()).getLeft(); if (iq instanceof AtomicNumberAtom) { mapping.put(k, ((AtomicNumberAtom) iq).getAtomicNumber()-200); } } } } } return mapping; }
private void addTemplateMol(IAtomContainer mol) { templates.add(mol); QueryAtomContainer query = QueryAtomContainerCreator.createAnyAtomAnyBondContainer(mol, false); queries.add(query); for (int i = 0; i < mol.getAtomCount(); i++) { query.getAtom(i).setPoint3d(new Point3d(mol.getAtom(i).getPoint3d())); } patterns.add(Pattern.findSubstructure(query)); }
IQueryAtom queryAtom = (IQueryAtom) query.getAtom(0);
/** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder *@param stereo Stereochemical orientation */ @Override public void addBond(int atom1, int atom2, IBond.Order order, IBond.Stereo stereo) { IBond bond = getBuilder().newInstance(IBond.class, getAtom(atom1), getAtom(atom2), order, stereo); if (contains(bond)) { return; } if (bondCount >= bonds.length) { growBondArray(); } addBond(bond); /* * no notifyChanged() here because addBond(bond) does it already */ }
public static QueryAtomContainer createSymbolChargeIDQueryContainer(IAtomContainer container) { QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder()); for (int i = 0; i < container.getAtomCount(); i++) { queryContainer.addAtom(new SymbolChargeIDQueryAtom(container.getAtom(i))); } Iterator<IBond> bonds = container.bonds().iterator(); while (bonds.hasNext()) { IBond bond = bonds.next(); int index1 = container.indexOf(bond.getBegin()); int index2 = container.indexOf(bond.getEnd()); if (bond.isAromatic()) { QueryBond qbond = new QueryBond(queryContainer.getAtom(index1), queryContainer.getAtom(index2), Expr.Type.IS_AROMATIC); queryContainer.addBond(qbond); } else { QueryBond qbond = new QueryBond(queryContainer.getAtom(index1), queryContainer.getAtom(index2), Expr.Type.ORDER, bond.getOrder().numeric()); qbond.setOrder(bond.getOrder()); // backwards compatibility queryContainer.addBond(qbond); } } return queryContainer; }
@Test public void testAliphaticSymbols() { for (Elements e : Elements.values()) { int len = e.symbol().length(); if (len == 1 || len == 2) { String smarts = "[" + e.symbol() + "]"; QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(smarts, Smarts.parse(mol, smarts)); Expr expr = getAtomExpr(mol.getAtom(0)); assertThat(expr, anyOf(is(new Expr(ELEMENT, e.number())), is(new Expr(ALIPHATIC_ELEMENT, e.number())))); } } }