/** * Returns the atom at the last position in the container. * *@return The atom at the last position */ @Override public IAtom getLastAtom() { return getAtomCount() > 0 ? (IAtom) atoms[getAtomCount() - 1] : null; }
/** * True, if the AtomContainer contains the given atom object. * *@param atom the atom this AtomContainer is searched for *@return true if the AtomContainer contains the given atom object */ @Override public boolean contains(IAtom atom) { for (int i = 0; i < getAtomCount(); i++) { if (atoms[i].equals(atom)) return true; } return false; }
@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(); }
if (!tmp.contains(idx2)) tmp.add(idx2); if (tmp.size() == query.getAtomCount()) atomMapping.add(tmp);
for (List<Integer> fragment : uniqueSubgraphs) { for (QueryAtomContainer query : queries) { if (fragment.size() == query.getAtomCount()) { retValue.add(fragment); break;
for (List<Integer> fragment : uniqueSubgraphs) { for (QueryAtomContainer query : queries) { if (fragment.size() == query.getAtomCount()) { retValue.add(fragment); break;
/** * 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(); }
if (query.getAtomCount() == 1) {
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; }
@Test public void testItself() throws Exception { String smiles = "C1CCCCCCC1CC"; QueryAtomContainer query = QueryAtomContainerCreator.createAnyAtomContainer(new SmilesParser( DefaultChemObjectBuilder.getInstance()).parseSmiles(smiles), true); IAtomContainer ac = new SmilesParser(DefaultChemObjectBuilder.getInstance()).parseSmiles(smiles); if (standAlone) { System.out.println("AtomCount of query: " + query.getAtomCount()); System.out.println("AtomCount of target: " + ac.getAtomCount()); } boolean matched = uiTester.isSubgraph(ac, query); if (standAlone) System.out.println("QueryAtomContainer matched: " + matched); if (!standAlone) Assert.assertTrue(matched); }
for (int f = 0; f < getAtomCount(); f++) { clone.addAtom((IAtom) getAtom(f).clone());