/** * Returns a vector of all rings that this atom is part of. * * @param atom The atom to be checked * @return A vector of all rings that this bond is part of */ @Override public IRingSet getRings(IAtom atom) { IRingSet rings = new RingSet(); IRing ring; for (int i = 0; i < getAtomContainerCount(); i++) { ring = (Ring) getAtomContainer(i); if (ring.contains(atom)) { rings.addAtomContainer(ring); } } return rings; }
/** * Checks for presence of a ring in this RingSet. * * @param ring The ring to check * @return true if ring is part of RingSet * */ @Override public boolean contains(IAtomContainer ring) { for (int i = 0; i < getAtomContainerCount(); i++) { if (ring == getAtomContainer(i)) { return true; } } return false; }
@Override public IChemObject newTestObject() { return new RingSet(); } });
/** * Adds all rings of another RingSet if they are not already part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ @Override public void add(IRingSet ringSet) { for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { if (!contains(ringSet.getAtomContainer(f))) { addAtomContainer(ringSet.getAtomContainer(f)); } } }
/** * Returns the String representation of this RingSet. * * @return The String representation of this RingSet */ @Override public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("RingSet("); buffer.append(this.hashCode()); if (getAtomContainerCount() > 0) { buffer.append(", R=").append(getAtomContainerCount()).append(", "); for (int i = 0; i < atomContainerCount; i++) { IRing possibleRing = (IRing) atomContainers[i]; buffer.append(possibleRing.toString()); if (i + 1 < atomContainerCount) { buffer.append(", "); } } } buffer.append(')'); return buffer.toString(); }
@BeforeClass public static void setUp() { setTestObjectBuilder(new ITestObjectBuilder() { @Override public IChemObject newTestObject() { return new RingSet(); } }); }
/** * Checks for presence of a ring in this RingSet. * * @param ring The ring to check * @return true if ring is part of RingSet * */ @Override public boolean contains(IAtomContainer ring) { for (int i = 0; i < getAtomContainerCount(); i++) { if (ring == getAtomContainer(i)) { return true; } } return false; }
/** * Adds all rings of another RingSet if they are not already part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ @Override public void add(IRingSet ringSet) { for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { if (!contains(ringSet.getAtomContainer(f))) { addAtomContainer(ringSet.getAtomContainer(f)); } } }
/** * Returns the String representation of this RingSet. * * @return The String representation of this RingSet */ @Override public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("RingSet("); buffer.append(this.hashCode()); if (getAtomContainerCount() > 0) { buffer.append(", R=").append(getAtomContainerCount()).append(", "); for (int i = 0; i < atomContainerCount; i++) { IRing possibleRing = (IRing) atomContainers[i]; buffer.append(possibleRing.toString()); if (i + 1 < atomContainerCount) { buffer.append(", "); } } } buffer.append(')'); return buffer.toString(); }
/** * Returns a vector of all rings that this atom is part of. * * @param atom The atom to be checked * @return A vector of all rings that this bond is part of */ @Override public IRingSet getRings(IAtom atom) { IRingSet rings = new RingSet(); IRing ring; for (int i = 0; i < getAtomContainerCount(); i++) { ring = (Ring) getAtomContainer(i); if (ring.contains(atom)) { rings.addAtomContainer(ring); } } return rings; }
@Test public void testRingSet() { IRingSet rs = new RingSet(); Assert.assertNotNull(rs); }
/** * True, if at least one of the rings in the ringset contains * the given atom. * * @param atom Atom to check * @return true, if the ringset contains the atom */ @Override public boolean contains(IAtom atom) { for (int i = 0; i < getAtomContainerCount(); i++) { if (getAtomContainer(i).contains(atom)) { return true; } } return false; }
/** * * @param ringBond * @param singleRings * @return */ public static IRingSet getSmallestRingSet(IBond ringBond, IRingSet singleRings) { IRingSet rs = new RingSet(); for (IAtomContainer ring : singleRings.atomContainers()) { if (ring.contains(ringBond.getAtom(0)) && ring.contains(ringBond.getAtom(1))) { if (rs.getAtomContainerCount() == 0) { rs.addAtomContainer(ring); continue; } for (IAtomContainer smallestRing : rs.atomContainers()) { if (ring.getAtomCount() == smallestRing.getAtomCount()) { if (!rs.contains(ring)) { rs.addAtomContainer(ring); } } else if (ring.getAtomCount() < smallestRing.getAtomCount()) { rs.removeAllAtomContainers(); rs.addAtomContainer(ring); } } } } return rs; }
/** * True, if at least one of the rings in the ringset contains * the given atom. * * @param atom Atom to check * @return true, if the ringset contains the atom */ @Override public boolean contains(IAtom atom) { for (int i = 0; i < getAtomContainerCount(); i++) { if (getAtomContainer(i).contains(atom)) { return true; } } return false; }
/** * Returns a vector of all rings that this bond is part of. * * @param bond The bond to be checked * @return A vector of all rings that this bond is part of */ @Override public IRingSet getRings(IBond bond) { IRingSet rings = bond.getBuilder().newInstance(IRingSet.class); Ring ring; for (int i = 0; i < getAtomContainerCount(); i++) { ring = (Ring) getAtomContainer(i); if (ring.contains(bond)) { rings.addAtomContainer(ring); } } return rings; }
/** * Returns a vector of all rings that this bond is part of. * * @param bond The bond to be checked * @return A vector of all rings that this bond is part of */ @Override public IRingSet getRings(IBond bond) { IRingSet rings = bond.getBuilder().newInstance(IRingSet.class); Ring ring; for (int i = 0; i < getAtomContainerCount(); i++) { ring = (Ring) getAtomContainer(i); if (ring.contains(bond)) { rings.addAtomContainer(ring); } } return rings; }
/** * Returns all the rings in the RingSet that share * one or more atoms with a given ring. * * @param ring A ring with which all return rings must share one or more atoms * @return All the rings that share one or more atoms with a given ring. */ @Override public IRingSet getConnectedRings(IRing ring) { IRingSet connectedRings = ring.getBuilder().newInstance(IRingSet.class); IRing tempRing; IAtom atom; for (int i = 0; i < ring.getAtomCount(); i++) { atom = ring.getAtom(i); for (int j = 0; j < getAtomContainerCount(); j++) { tempRing = (IRing) getAtomContainer(j); if (tempRing != ring && !connectedRings.contains(tempRing) && tempRing.contains(atom)) { connectedRings.addAtomContainer(tempRing); } } } return connectedRings; }
/** * Returns all the rings in the RingSet that share * one or more atoms with a given ring. * * @param ring A ring with which all return rings must share one or more atoms * @return All the rings that share one or more atoms with a given ring. */ @Override public IRingSet getConnectedRings(IRing ring) { IRingSet connectedRings = ring.getBuilder().newInstance(IRingSet.class); IRing tempRing; IAtom atom; for (int i = 0; i < ring.getAtomCount(); i++) { atom = ring.getAtom(i); for (int j = 0; j < getAtomContainerCount(); j++) { tempRing = (IRing) getAtomContainer(j); if (tempRing != ring && !connectedRings.contains(tempRing) && tempRing.contains(atom)) { connectedRings.addAtomContainer(tempRing); } } } return connectedRings; }