@Override public int compare(IRing object1, IRing object2) throws ClassCastException { int size1 = object1.getAtomCount(); int size2 = object2.getAtomCount(); if (size1 == size2) return 0; if (size1 > size2 && sortOrder == SMALL_FIRST) { return 1; } if (size1 > size2 && sortOrder == LARGE_FIRST) { return -1; } if (size1 < size2 && sortOrder == SMALL_FIRST) { return -1; } if (size1 < size2 && sortOrder == LARGE_FIRST) { return 1; } return 0; } }
/** * Returns the ring radius of a perfect polygons of size ring.getAtomCount() * The ring radius is the distance of each atom to the ringcenter. * * @param ring The ring for which the radius is to calculated * @param bondLength The bond length for each bond in the ring * @return The radius of the ring. */ public double getNativeRingRadius(IRing ring, double bondLength) { int size = ring.getAtomCount(); double radius = bondLength / (2 * Math.sin((Math.PI) / size)); return radius; }
/** * Returns the ring radius of a perfect polygons of size ring.getAtomCount() * The ring radius is the distance of each atom to the ringcenter. * * @param ring The ring for which the radius is to calculated * @param bondLength The bond length for each bond in the ring * @return The radius of the ring. */ public double getNativeRingRadius(IRing ring, double bondLength) { int size = ring.getAtomCount(); double radius = bondLength / (2 * Math.sin((Math.PI) / size)); return radius; }
/** * Calculated the center for the first ring so that it can * layed out. Only then, all other rings can be assigned * coordinates relative to it. * * @param ring The ring for which the center is to be calculated * @return A Vector2d pointing to the new ringcenter */ Vector2d getRingCenterOfFirstRing(IRing ring, Vector2d bondVector, double bondLength) { int size = ring.getAtomCount(); double radius = bondLength / (2 * Math.sin((Math.PI) / size)); double newRingPerpendicular = Math.sqrt(Math.pow(radius, 2) - Math.pow(bondLength / 2, 2)); /* get the angle between the x axis and the bond vector */ double rotangle = GeometryUtil.getAngle(bondVector.x, bondVector.y); /* * Add 90 Degrees to this angle, this is supposed to be the new * ringcenter vector */ rotangle += Math.PI / 2; return new Vector2d(Math.cos(rotangle) * newRingPerpendicular, Math.sin(rotangle) * newRingPerpendicular); }
static boolean isAromaticRing(IRing ring) { for (int i = 0; i < ring.getAtomCount(); i++) if (!ring.getAtom(i).getFlag(CDKConstants.ISAROMATIC)) return (false); return (true); }
private String getRingcode(IAtom root, IAtomContainer ac) { if (ac != acold) { soar = Cycles.sssr(ac).toRingSet(); } boolean[] bool = new boolean[1000]; StringBuffer sb = new StringBuffer(); for (int i = 0; i < soar.getRings(root).getAtomContainerCount(); i++) { if (((IRing) soar.getRings(root).getAtomContainer(i)).getAtomCount() < bool.length) bool[((IRing) soar.getRings(root).getAtomContainer(i)).getAtomCount()] = true; } for (int i = 0; i < bool.length; i++) { if (bool[i]) sb.append(i + ""); } if (sb.toString().isEmpty()) return ""; else return "-" + sb.toString(); }
@Test public void testRing_int() { IRing r = new Ring(5); // This does not create a ring! Assert.assertEquals(0, r.getAtomCount()); Assert.assertEquals(0, r.getBondCount()); }
@Test public void testDebugRing_int() { IRing r = new DebugRing(5); Assert.assertEquals(0, r.getAtomCount()); Assert.assertEquals(0, r.getBondCount()); }
@Test public void testRing_int_String() { IRing r = new Ring(5, "C"); Assert.assertEquals(5, r.getAtomCount()); Assert.assertEquals(5, r.getBondCount()); }
@Test public void testRing_int_String() { IRing r = new Ring(5, "C"); Assert.assertEquals(5, r.getAtomCount()); Assert.assertEquals(5, r.getBondCount()); }
@Test public void testRing_int() { IRing r = new Ring(5); // This does not create a ring! Assert.assertEquals(0, r.getAtomCount()); Assert.assertEquals(0, r.getBondCount()); }
@Test public void testDebugRing_int_String() { IRing r = new DebugRing(5, "C"); Assert.assertEquals(5, r.getAtomCount()); Assert.assertEquals(5, r.getBondCount()); }
private boolean inSameAromaticRing(IAtomContainer atomContainer, IAtom atom1, IAtom atom2, IRingSet rs) { boolean sameRing = false; for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) { IRing r = (IRing) rs.getAtomContainer(i); if (!r.getFlag(CDKConstants.ISAROMATIC)) continue; // ArrayList al=new ArrayList(); boolean haveOne = false; boolean haveTwo = false; for (int j = 0; j <= r.getAtomCount() - 1; j++) { if (atomContainer.indexOf(r.getAtom(j)) == atomContainer.indexOf(atom1)) haveOne = true; if (atomContainer.indexOf(r.getAtom(j)) == atomContainer.indexOf(atom2)) haveTwo = true; } if (haveOne && haveTwo) { sameRing = true; return sameRing; } } // end ring for loop return sameRing; }
private boolean inSameAromaticRing(IAtomContainer atomContainer, IAtom atom1, IAtom atom2, IRingSet rs) { boolean sameRing = false; for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) { IRing r = (IRing) rs.getAtomContainer(i); if (!r.getFlag(CDKConstants.ISAROMATIC)) continue; // ArrayList al=new ArrayList(); boolean haveOne = false; boolean haveTwo = false; for (int j = 0; j <= r.getAtomCount() - 1; j++) { if (atomContainer.indexOf(r.getAtom(j)) == atomContainer.indexOf(atom1)) haveOne = true; if (atomContainer.indexOf(r.getAtom(j)) == atomContainer.indexOf(atom2)) haveTwo = true; } if (haveOne && haveTwo) { sameRing = true; return sameRing; } } // end ring for loop return sameRing; }
@Test public void testDebugRing() { IRing ring = new DebugRing(); Assert.assertNotNull(ring); Assert.assertEquals(0, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); }
@Test public void testRing() { IRing ring = new Ring(); Assert.assertNotNull(ring); Assert.assertEquals(0, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); }
@Test public void testRing() { IRing ring = new Ring(); Assert.assertNotNull(ring); Assert.assertEquals(0, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); }
@Test public void testRing_IAtomContainer() { IAtomContainer container = new org.openscience.cdk.AtomContainer(); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IRing ring = new Ring(container); Assert.assertNotNull(ring); Assert.assertEquals(2, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); }
@Test public void testRing_IAtomContainer() { IAtomContainer container = newChemObject().getBuilder().newInstance(IAtomContainer.class); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IRing ring = new Ring(container); Assert.assertNotNull(ring); Assert.assertEquals(2, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); }
@Test public void testDebugRing_IAtomContainer() { IAtomContainer container = newChemObject().getBuilder().newInstance(IAtomContainer.class); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); container.addAtom(container.getBuilder().newInstance(IAtom.class, "C")); IRing ring = new DebugRing(container); Assert.assertNotNull(ring); Assert.assertEquals(2, ring.getAtomCount()); Assert.assertEquals(0, ring.getBondCount()); } }