/**
  * Adds 3D coordinates for singly-bonded ligands of a reference atom (A). Initially designed for
  * hydrogens. The ligands of refAtom are identified and those with 3D coordinates used to generate
  * the new points. (This allows structures with partially known 3D coordinates to be used, as when
  * groups are added.) "Bent" and "non-planar" groups can be formed by taking a subset of the
  * calculated points. Thus R-NH2 could use 2 of the 3 points calculated from (1,iii) nomenclature:
  * A is point to which new ones are "attached". A may have ligands B, C... B may have ligands J,
  * K.. points X1, X2... are returned The cases (see individual routines, which use idealised
  * geometry by default): (0) zero ligands of refAtom. The resultant points are randomly oriented:
  * (i) 1 points required; +x,0,0 (ii) 2 points: use +x,0,0 and -x,0,0 (iii) 3 points: equilateral
  * triangle in xy plane (iv) 4 points x,x,x, x,-x,-x, -x,x,-x, -x,-x,x (1a) 1 ligand(B) of refAtom
  * which itself has a ligand (J) (i) 1 points required; vector along AB vector (ii) 2 points: 2
  * vectors in ABJ plane, staggered and eclipsed wrt J (iii) 3 points: 1 staggered wrt J, the
  * others +- gauche wrt J (1b) 1 ligand(B) of refAtom which has no other ligands. A random J is
  * generated and (1a) applied (2) 2 ligands(B, C) of refAtom A (i) 1 points required; vector in
  * ABC plane bisecting AB, AC. If ABC is linear, no points (ii) 2 points: 2 vectors at angle ang,
  * whose resultant is 2i (3) 3 ligands(B, C, D) of refAtom A (i) 1 points required; if A, B, C, D
  * coplanar, no points. else vector is resultant of BA, CA, DA
  *
  * <p>fails if atom itself has no coordinates or >4 ligands
  *
  * @param atomContainer describing the ligands of refAtom. It could be the whole molecule, or
  *     could be a selected subset of ligands
  * @param refAtom (A) to which new ligands coordinates could be added
  * @param length A-X length
  * @param angle B-A-X angle (used in certain cases)
  * @return Point3D[] points calculated. If request could not be fulfilled (e.g. too many atoms, or
  *     strange geometry, returns empty array (zero length, not null)
  * @cdk.keyword coordinate generation
  */
 public static Point3d[] calculate3DCoordinatesForLigands(
     AtomContainer atomContainer, IAtom refAtom, int nwanted, double length, double angle) {
   Point3d newPoints[] = new Point3d[0];
   Point3d aPoint = refAtom.getPoint3d();
   // get ligands
   List connectedAtoms = atomContainer.getConnectedAtomsList(refAtom);
   if (connectedAtoms == null) {
     return newPoints;
   }
   int nligands = connectedAtoms.size();
   AtomContainer ligandsWithCoords = new AtomContainer();
   for (int i = 0; i < nligands; i++) {
     Atom ligand = (Atom) connectedAtoms.get(i);
     if (ligand.getPoint3d() != null) {
       ligandsWithCoords.addAtom(ligand);
     }
   }
   int nwithCoords = ligandsWithCoords.getAtomCount();
   // too many ligands at present
   if (nwithCoords > 3) {
     return newPoints;
   }
   if (nwithCoords == 0) {
     newPoints = calculate3DCoordinates0(refAtom.getPoint3d(), nwanted, length);
   } else if (nwithCoords == 1) {
     // ligand on A
     IAtom bAtom = ligandsWithCoords.getAtom(0);
     connectedAtoms = ligandsWithCoords.getConnectedAtomsList(bAtom);
     // does B have a ligand (other than A)
     Atom jAtom = null;
     for (int i = 0; i < connectedAtoms.size(); i++) {
       Atom connectedAtom = (Atom) connectedAtoms.get(i);
       if (!connectedAtom.equals(refAtom)) {
         jAtom = connectedAtom;
         break;
       }
     }
     newPoints =
         calculate3DCoordinates1(
             aPoint,
             bAtom.getPoint3d(),
             (jAtom != null) ? jAtom.getPoint3d() : null,
             nwanted,
             length,
             angle);
   } else if (nwithCoords == 2) {
     Point3d bPoint = ligandsWithCoords.getAtom(0).getPoint3d();
     Point3d cPoint = ligandsWithCoords.getAtom(1).getPoint3d();
     newPoints = calculate3DCoordinates2(aPoint, bPoint, cPoint, nwanted, length, angle);
   } else if (nwithCoords == 3) {
     Point3d bPoint = ligandsWithCoords.getAtom(0).getPoint3d();
     Point3d cPoint = ligandsWithCoords.getAtom(1).getPoint3d();
     Point3d dPoint = ligandsWithCoords.getAtom(2).getPoint3d();
     newPoints = new Point3d[1];
     newPoints[0] = calculate3DCoordinates3(aPoint, bPoint, cPoint, dPoint, length);
   }
   return newPoints;
 }
 public void remove(IAtomContainer atomContainer) {
   logger.debug("Removing atom container: ", atomContainer);
   super.remove(atomContainer);
 }
示例#3
0
  /**
   * Create a benzene molecule with 2 residues and 2 charge groups
   *
   * @return
   */
  public MDMolecule makeMDBenzene() {

    MDMolecule mol = new MDMolecule();
    mol.addAtom(new Atom("C")); // 0
    mol.addAtom(new Atom("C")); // 1
    mol.addAtom(new Atom("C")); // 2
    mol.addAtom(new Atom("C")); // 3
    mol.addAtom(new Atom("C")); // 4
    mol.addAtom(new Atom("C")); // 5

    mol.addBond(0, 1, IBond.Order.SINGLE); // 1
    mol.addBond(1, 2, IBond.Order.DOUBLE); // 2
    mol.addBond(2, 3, IBond.Order.SINGLE); // 3
    mol.addBond(3, 4, IBond.Order.DOUBLE); // 4
    mol.addBond(4, 5, IBond.Order.SINGLE); // 5
    mol.addBond(5, 0, IBond.Order.DOUBLE); // 6

    // Create 2 residues
    AtomContainer ac = new AtomContainer();
    ac.addAtom(mol.getAtom(0));
    ac.addAtom(mol.getAtom(1));
    ac.addAtom(mol.getAtom(2));
    Residue res1 = new Residue(ac, 0, mol);
    res1.setName("myResidue1");
    mol.addResidue(res1);

    AtomContainer ac2 = new AtomContainer();
    ac2.addAtom(mol.getAtom(3));
    ac2.addAtom(mol.getAtom(4));
    ac2.addAtom(mol.getAtom(5));
    Residue res2 = new Residue(ac2, 1, mol);
    res2.setName("myResidue2");
    mol.addResidue(res2);

    // Create 2 chargegroups
    AtomContainer ac3 = new AtomContainer();
    ac3.addAtom(mol.getAtom(0));
    ac3.addAtom(mol.getAtom(1));
    ChargeGroup chg1 = new ChargeGroup(ac3, 2, mol);
    chg1.setSwitchingAtom(mol.getAtom(1));
    mol.addChargeGroup(chg1);

    AtomContainer ac4 = new AtomContainer();
    ac4.addAtom(mol.getAtom(2));
    ac4.addAtom(mol.getAtom(3));
    ac4.addAtom(mol.getAtom(4));
    ac4.addAtom(mol.getAtom(5));
    ChargeGroup chg2 = new ChargeGroup(ac4, 3, mol);
    chg2.setSwitchingAtom(mol.getAtom(4));
    mol.addChargeGroup(chg2);

    return mol;
  }
 public void setAtoms(IAtom[] atoms) {
   logger.debug("Setting atoms: ", atoms.length);
   super.setAtoms(atoms);
 }
 public void setFlags(boolean[] flagsNew) {
   logger.debug("Setting flags:", flagsNew.length);
   super.setFlags(flagsNew);
 }
 public void setFlag(int flag_type, boolean flag_value) {
   logger.debug("Setting flag: ", flag_type + "=" + flag_value);
   super.setFlag(flag_type, flag_value);
 }
 public void removeProperty(Object description) {
   logger.debug("Removing property: ", description);
   super.removeProperty(description);
 }
 public void notifyChanged(IChemObjectChangeEvent evt) {
   logger.debug("Notifying changed event: ", evt);
   super.notifyChanged(evt);
 }
 public void removeAtomAndConnectedElectronContainers(IAtom atom) {
   logger.debug("Removing atom and connected electron containers: ", atom);
   super.removeAtomAndConnectedElectronContainers(atom);
 }
 public void removeSingleElectron(ISingleElectron ec) {
   logger.debug("Removing bond=" + ec);
   super.removeSingleElectron(ec);
 }
 public void removeLonePair(ILonePair ec) {
   logger.debug("Removing bond=" + ec);
   super.removeLonePair(ec);
 }
 public void removeBond(IBond bond) {
   logger.debug("Removing bond=" + bond);
   super.removeBond(bond);
 }
 public void removeAtom(IAtom atom) {
   logger.debug("Removing atom: ", atom);
   super.removeAtom(atom);
 }
 public void removeAtom(int position) {
   logger.debug("Removing atom: ", position);
   super.removeAtom(position);
 }
 public void removeElectronContainer(IElectronContainer electronContainer) {
   logger.debug("Removing electron container: ", electronContainer);
   super.removeElectronContainer(electronContainer);
 }
 public void removeListener(IChemObjectListener col) {
   logger.debug("Removing listener: ", col);
   super.removeListener(col);
 }
 public void notifyChanged() {
   logger.debug("Notifying changed");
   super.notifyChanged();
 }
 public void removeAllElements() {
   logger.debug("Removing all elements");
   super.removeAllElements();
 }
 public void setProperty(Object description, Object property) {
   logger.debug("Setting property: ", description + "=" + property);
   super.setProperty(description, property);
 }
 public void removeAllElectronContainers() {
   logger.debug("Removing all electron containers");
   super.removeAllElectronContainers();
 }
 public void setID(String identifier) {
   logger.debug("Setting ID: ", identifier);
   super.setID(identifier);
 }
 public void removeAllBonds() {
   logger.debug("Removing all bonds");
   super.removeAllBonds();
 }
 public void setProperties(Map<Object, Object> properties) {
   logger.debug("Setting properties: ", properties);
   super.setProperties(properties);
 }
 public void addBond(int atom1, int atom2, IBond.Order order) {
   logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order);
   super.addBond(atom1, atom2, order);
 }
 public void addAtomParity(IAtomParity parity) {
   logger.debug("Adding atom parity: ", parity);
   super.addAtomParity(parity);
 }
 public void addLonePair(int atomID) {
   logger.debug("Adding lone pair: ", atomID);
   super.addLonePair(atomID);
 }
 public void setAtom(int number, IAtom atom) {
   logger.debug("Setting atom at: pos=" + number, " atom=" + atom);
   super.setAtom(number, atom);
 }
 public void addSingleElectron(int atomID) {
   logger.debug("Adding single electron: ", atomID);
   super.addSingleElectron(atomID);
 }
示例#29
0
  /** Test an MDMolecule with residues and charge groups */
  @Test
  public void testMDMolecule() {

    MDMolecule mol = new MDMolecule();
    mol.addAtom(new Atom("C")); // 0
    mol.addAtom(new Atom("C")); // 1
    mol.addAtom(new Atom("C")); // 2
    mol.addAtom(new Atom("C")); // 3
    mol.addAtom(new Atom("C")); // 4
    mol.addAtom(new Atom("C")); // 5

    mol.addBond(0, 1, IBond.Order.SINGLE); // 1
    mol.addBond(1, 2, IBond.Order.DOUBLE); // 2
    mol.addBond(2, 3, IBond.Order.SINGLE); // 3
    mol.addBond(3, 4, IBond.Order.DOUBLE); // 4
    mol.addBond(4, 5, IBond.Order.SINGLE); // 5
    mol.addBond(5, 0, IBond.Order.DOUBLE); // 6

    // Create 2 residues
    AtomContainer ac = new AtomContainer();
    ac.addAtom(mol.getAtom(0));
    ac.addAtom(mol.getAtom(1));
    ac.addAtom(mol.getAtom(2));
    Residue res1 = new Residue(ac, 0, mol);
    res1.setName("myResidue1");
    mol.addResidue(res1);

    AtomContainer ac2 = new AtomContainer();
    ac2.addAtom(mol.getAtom(3));
    ac2.addAtom(mol.getAtom(4));
    ac2.addAtom(mol.getAtom(5));
    Residue res2 = new Residue(ac2, 1, mol);
    res2.setName("myResidue2");
    mol.addResidue(res2);

    // Test residue creation
    Assert.assertEquals(res1.getParentMolecule(), mol);
    Assert.assertEquals(res2.getParentMolecule(), mol);
    Assert.assertEquals(res1.getAtomCount(), 3);
    Assert.assertEquals(res2.getAtomCount(), 3);
    Assert.assertEquals(res1.getName(), "myResidue1");
    Assert.assertEquals(res2.getName(), "myResidue2");
    Assert.assertNotNull(mol.getResidues());
    Assert.assertEquals(mol.getResidues().size(), 2);
    Assert.assertEquals(mol.getResidues().get(0), res1);
    Assert.assertEquals(mol.getResidues().get(1), res2);

    // Create 2 chargegroups
    AtomContainer ac3 = new AtomContainer();
    ac3.addAtom(mol.getAtom(0));
    ac3.addAtom(mol.getAtom(1));
    ChargeGroup chg1 = new ChargeGroup(ac3, 0, mol);
    mol.addChargeGroup(chg1);

    AtomContainer ac4 = new AtomContainer();
    ac4.addAtom(mol.getAtom(2));
    ac4.addAtom(mol.getAtom(3));
    ac4.addAtom(mol.getAtom(4));
    ac4.addAtom(mol.getAtom(5));
    ChargeGroup chg2 = new ChargeGroup(ac4, 1, mol);
    mol.addChargeGroup(chg2);

    // Test chargegroup creation
    Assert.assertEquals(chg1.getParentMolecule(), mol);
    Assert.assertEquals(chg2.getParentMolecule(), mol);
    Assert.assertEquals(chg1.getAtomCount(), 2);
    Assert.assertEquals(chg2.getAtomCount(), 4);

    Assert.assertNotNull(mol.getChargeGroups());
    Assert.assertEquals(mol.getChargeGroups().size(), 2);
    Assert.assertEquals(mol.getChargeGroups().get(0), chg1);
    Assert.assertEquals(mol.getChargeGroups().get(1), chg2);
  }
 public void addListener(IChemObjectListener col) {
   logger.debug("Adding listener: ", col);
   super.addListener(col);
 }