/** * {@inheritDoc} */ @Override public IBond newBond() { return new Bond(); }
/** * Compares a bond with this bond. * * @param object Object of type Bond * @return true if the bond is equal to this bond */ @Override public boolean compare(Object object) { if (object instanceof IBond) { Bond bond = (Bond) object; for (IAtom atom : atoms) { if (!bond.contains(atom)) { return false; } } // not important ??!! //if (order==bond.order) // return false; return true; } return false; }
/** * Returns a one line string representation of this Container. This method is * conform RFC #9. * * @return The string representation of this Container */ @Override public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("Bond(").append(this.hashCode()); if (getOrder() != null) { resultString.append(", #O:").append(getOrder()); } resultString.append(", #S:").append(getStereo()); if (getAtomCount() > 0) { resultString.append(", #A:").append(getAtomCount()); for (int i = 0; i < atomCount; i++) { resultString.append(", ").append(atoms[i] == null ? "null" : atoms[i].toString()); } } resultString.append(", ").append(super.toString()); resultString.append(')'); return resultString.toString(); }
/** {@inheritDoc} */ @Override public boolean isInRing() { return getFlag(CDKConstants.ISINRING); }
/** * Returns the geometric 3D center of the bond. * * @return The geometric 3D center of the bond */ @Override public Point3d get3DCenter() { double xOfCenter = 0; double yOfCenter = 0; double zOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint3d().x; yOfCenter += atom.getPoint3d().y; zOfCenter += atom.getPoint3d().z; } return new Point3d(xOfCenter / getAtomCount(), yOfCenter / getAtomCount(), zOfCenter / getAtomCount()); }
/** {@inheritDoc} */ @Override public boolean isInRing() { return getFlag(CDKConstants.ISINRING); }
/** * Returns the geometric 2D center of the bond. * * @return The geometric 2D center of the bond */ @Override public Point2d get2DCenter() { double xOfCenter = 0; double yOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint2d().x; yOfCenter += atom.getPoint2d().y; } return new Point2d(xOfCenter / ((double) getAtomCount()), yOfCenter / ((double) getAtomCount())); }
/** * {@inheritDoc} */ @Override public IBond newBond() { return new Bond(); }
/** * Returns a one line string representation of this Container. This method is * conform RFC #9. * * @return The string representation of this Container */ @Override public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("Bond(").append(this.hashCode()); if (getOrder() != null) { resultString.append(", #O:").append(getOrder()); } resultString.append(", #S:").append(getStereo()); if (getAtomCount() > 0) { resultString.append(", #A:").append(getAtomCount()); for (int i = 0; i < atomCount; i++) { resultString.append(", ").append(atoms[i] == null ? "null" : atoms[i].toString()); } } resultString.append(", ").append(super.toString()); resultString.append(')'); return resultString.toString(); }
/** {@inheritDoc} */ @Override public boolean isAromatic() { return getFlag(CDKConstants.ISAROMATIC); }
/** * Returns the geometric 3D center of the bond. * * @return The geometric 3D center of the bond */ @Override public Point3d get3DCenter() { double xOfCenter = 0; double yOfCenter = 0; double zOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint3d().x; yOfCenter += atom.getPoint3d().y; zOfCenter += atom.getPoint3d().z; } return new Point3d(xOfCenter / getAtomCount(), yOfCenter / getAtomCount(), zOfCenter / getAtomCount()); }
/** * Compares a bond with this bond. * * @param object Object of type Bond * @return true if the bond is equal to this bond */ @Override public boolean compare(Object object) { if (object instanceof IBond) { Bond bond = (Bond) object; for (IAtom atom : atoms) { if (!bond.contains(atom)) { return false; } } // not important ??!! //if (order==bond.order) // return false; return true; } return false; }
@Override public IChemObject newTestObject() { return new Bond(); } });
/** {@inheritDoc} */ @Override public boolean isAromatic() { return getFlag(CDKConstants.ISAROMATIC); }
/** * Returns the geometric 2D center of the bond. * * @return The geometric 2D center of the bond */ @Override public Point2d get2DCenter() { double xOfCenter = 0; double yOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint2d().x; yOfCenter += atom.getPoint2d().y; } return new Point2d(xOfCenter / ((double) getAtomCount()), yOfCenter / ((double) getAtomCount())); }
/** * Constructs a ring that will have a certain number of atoms of the given elements. * * @param ringSize The number of atoms and bonds the ring will have * @param elementSymbol The element of the atoms the ring will have */ public Ring(int ringSize, String elementSymbol) { this(ringSize); super.atomCount = ringSize; super.bondCount = ringSize; atoms[0] = new Atom(elementSymbol); for (int i = 1; i < ringSize; i++) { atoms[i] = new Atom(elementSymbol); super.bonds[i - 1] = new Bond(atoms[i - 1], atoms[i], IBond.Order.SINGLE); } super.bonds[ringSize - 1] = new Bond(atoms[ringSize - 1], atoms[0], IBond.Order.SINGLE); }
/** * Constructs a ring that will have a certain number of atoms of the given elements. * * @param ringSize The number of atoms and bonds the ring will have * @param elementSymbol The element of the atoms the ring will have */ public Ring(int ringSize, String elementSymbol) { this(ringSize); super.atomCount = ringSize; super.bondCount = ringSize; atoms[0] = new Atom(elementSymbol); for (int i = 1; i < ringSize; i++) { atoms[i] = new Atom(elementSymbol); super.bonds[i - 1] = new Bond(atoms[i - 1], atoms[i], IBond.Order.SINGLE); } super.bonds[ringSize - 1] = new Bond(atoms[ringSize - 1], atoms[0], IBond.Order.SINGLE); }
@SuppressWarnings("unchecked") @Test(expected = CDKException.class) public void unsetBondOrder() throws Exception { IAtom u = mock(IAtom.class); IAtom v = mock(IAtom.class); IBond b = new Bond(u, v, IBond.Order.UNSET); Map<IAtom, Integer> mock = mock(Map.class); when(mock.get(u)).thenReturn(0); when(mock.get(v)).thenReturn(1); new CDKToBeam().toBeamEdge(b, mock); }
@SuppressWarnings("unchecked") @Test(expected = CDKException.class) public void undefBondOrder() throws Exception { IAtom u = mock(IAtom.class); IAtom v = mock(IAtom.class); IBond b = new Bond(u, v, null); Map<IAtom, Integer> mock = mock(Map.class); when(mock.get(u)).thenReturn(0); when(mock.get(v)).thenReturn(1); new CDKToBeam().toBeamEdge(b, mock); }
@SuppressWarnings("unchecked") @Test public void tripleBond() throws Exception { IAtom u = mock(IAtom.class); IAtom v = mock(IAtom.class); IBond b = new Bond(u, v, IBond.Order.TRIPLE); Map<IAtom, Integer> mock = mock(Map.class); when(mock.get(u)).thenReturn(0); when(mock.get(v)).thenReturn(1); CDKToBeam c2g = new CDKToBeam(); assertThat(c2g.toBeamEdge(b, mock), is(uk.ac.ebi.beam.Bond.TRIPLE.edge(0, 1))); }