Example #1
0
  /**
   * Constructs an AtomContainer with a copy of the atoms and electronContainers of another
   * AtomContainer (A shallow copy, i.e., with the same objects as in the original AtomContainer).
   *
   * @param container An AtomContainer to copy the atoms and electronContainers from
   */
  public AtomContainer(IAtomContainer container) {
    this.atomCount = container.getAtomCount();
    this.bondCount = container.getBondCount();
    this.lonePairCount = container.getLonePairCount();
    this.singleElectronCount = container.getSingleElectronCount();
    this.atoms = new IAtom[this.atomCount];
    this.bonds = new IBond[this.bondCount];
    this.lonePairs = new ILonePair[this.lonePairCount];
    this.singleElectrons = new ISingleElectron[this.singleElectronCount];

    stereoElements = new HashSet<IStereoElement>(atomCount / 2);

    for (IStereoElement element : container.stereoElements()) {
      addStereoElement(element);
    }

    for (int f = 0; f < container.getAtomCount(); f++) {
      atoms[f] = container.getAtom(f);
      container.getAtom(f).addListener(this);
    }
    for (int f = 0; f < this.bondCount; f++) {
      bonds[f] = container.getBond(f);
      container.getBond(f).addListener(this);
    }
    for (int f = 0; f < this.lonePairCount; f++) {
      lonePairs[f] = container.getLonePair(f);
      container.getLonePair(f).addListener(this);
    }
    for (int f = 0; f < this.singleElectronCount; f++) {
      singleElectrons[f] = container.getSingleElectron(f);
      container.getSingleElectron(f).addListener(this);
    }
  }
Example #2
0
  /**
   * Adds all atoms and electronContainers of a given atomcontainer to this container.
   *
   * @param atomContainer The atomcontainer to be added
   */
  public void add(IAtomContainer atomContainer) {
    for (int f = 0; f < atomContainer.getAtomCount(); f++) {
      if (!contains(atomContainer.getAtom(f))) {
        addAtom(atomContainer.getAtom(f));
      }
    }
    for (int f = 0; f < atomContainer.getBondCount(); f++) {
      if (!contains(atomContainer.getBond(f))) {
        addBond(atomContainer.getBond(f));
      }
    }
    for (int f = 0; f < atomContainer.getLonePairCount(); f++) {
      if (!contains(atomContainer.getLonePair(f))) {
        addLonePair(atomContainer.getLonePair(f));
      }
    }
    for (int f = 0; f < atomContainer.getSingleElectronCount(); f++) {
      if (!contains(atomContainer.getSingleElectron(f))) {
        addSingleElectron(atomContainer.getSingleElectron(f));
      }
    }

    for (IStereoElement se : atomContainer.stereoElements()) stereoElements.add(se);

    notifyChanged();
  }
Example #3
0
  /**
   * Convenience method for labelling all stereo elements. The {@link CIP_CHIRALITY} is determined
   * for each element and stored as as {@link String} on the {@link CDKConstants#CIP_DESCRIPTOR}
   * property key. Atoms/bonds that are not stereocenters have no label assigned and the property
   * will be null.
   *
   * @param container structure to label
   */
  public static void label(IAtomContainer container) {

    for (IStereoElement stereoElement : container.stereoElements()) {
      if (stereoElement instanceof ITetrahedralChirality) {
        ITetrahedralChirality tc = (ITetrahedralChirality) stereoElement;
        tc.getChiralAtom()
            .setProperty(CDKConstants.CIP_DESCRIPTOR, getCIPChirality(container, tc).toString());
      } else if (stereoElement instanceof IDoubleBondStereochemistry) {
        IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) stereoElement;
        dbs.getStereoBond()
            .setProperty(CDKConstants.CIP_DESCRIPTOR, getCIPChirality(container, dbs).toString());
      }
    }
  }