Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated and corrected new AtomPlacer3D Test class by danielszisz

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information...
commit ea2b55e55b90fa6ca91d242fe71ae2c85cf66238 1 parent d83c937
danielszisz authored rajarshi committed
378 src/test/org/openscience/cdk/modeling/builder3d/FurtherAtomPlacer3DTest.java
View
@@ -1,17 +1,34 @@
+/* Copyright (C) 2000-2012 Christoph Steinbeck, Egon Willighagen
+ *
+ * Contact: cdk-devel@lists.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ * All we ask is that proper credit is given for our work, which includes
+ * - but is not limited to - adding the above copyright notice to the beginning
+ * of your source code files, and to any copyright notice that you may distribute
+ * with programs based on this work.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.openscience.cdk.modeling.builder3d;
import javax.vecmath.Point3d;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.ArrayList;
+
import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
-import org.openscience.cdk.exception.InvalidSmilesException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
@@ -23,32 +40,23 @@
/**
* Tests not-yet-tested functionalities of {@link AtomPlacer3D}.
*
- * @author danielszisz
+ * @author danielszisz
* @cdk.module test-builder3d
- * @created 04/27/2012
- * @version 04/20/2012
+ * @created 04/10/2012
+ * @version 04/22/2012
*/
public class FurtherAtomPlacer3DTest extends AtomPlacer3DTest {
@Test
- public void testAllHeavyAtomsPlaced_IAtomContainer() {
+ public void testAllHeavyAtomsPlaced_benzene() {
AtomPlacer3D atmplacer=new AtomPlacer3D();
- List<IAtomContainer> molecules = new ArrayList<IAtomContainer>();
- molecules.add(MoleculeFactory.makeAlkane(5));
- molecules.add(MoleculeFactory.makeBenzene());
- molecules.add(MoleculeFactory.makePhenylAmine());
- molecules.add(MoleculeFactory.makeCyclobutadiene());
- for(IAtomContainer ac : molecules) {
- Assert.assertFalse(atmplacer.allHeavyAtomsPlaced(ac));
- }
- for(IAtomContainer ac : molecules) {
- for(IAtom atom : ac.atoms()) {
+ IAtomContainer benzene = MoleculeFactory.makeBenzene();
+ for(IAtom atom : benzene.atoms()) {
atom.setFlag(CDKConstants.ISPLACED, true);
}
- Assert.assertTrue(new AtomPlacer3D().allHeavyAtomsPlaced(ac));
+ Assert.assertTrue(atmplacer.allHeavyAtomsPlaced(benzene));
}
- }
@Test
public void testNumberOfUnplacedHeavyAtoms_IAtomContainer() {
@@ -62,230 +70,240 @@ public void testNumberOfUnplacedHeavyAtoms_IAtomContainer() {
@Test
public void testGetPlacedHeavyAtoms_IAtomContainer_IAtom() {
- AtomPlacer3D placer = new AtomPlacer3D();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
IAtomContainer molecule = MoleculeFactory.makeBenzene();
for(int j=0; j < 3; j++) {
(molecule.getAtom(j)).setFlag(CDKConstants.ISPLACED, true) ;
}
- IAtomContainer placed1 = placer.getPlacedHeavyAtoms(molecule, molecule.getAtom(1));
- IAtomContainer placed2 = placer.getPlacedHeavyAtoms(molecule, molecule.getAtom(2));
- IAtomContainer placed4 = placer.getPlacedHeavyAtoms(molecule, molecule.getAtom(4));
-
- IAtomContainer p1 = molecule.getBuilder().newInstance(IAtomContainer.class);
- p1.addAtom(molecule.getAtom(0));
- p1.addAtom(molecule.getAtom(2));
-
- IAtomContainer p2 = molecule.getBuilder().newInstance(IAtomContainer.class);
- p2.addAtom(molecule.getAtom(1));
+ IAtomContainer placedAndConnectedTo1 = atmplacer.getPlacedHeavyAtoms(molecule, molecule.getAtom(1));
+ IAtomContainer placedAndConnectedTo2 = atmplacer.getPlacedHeavyAtoms(molecule, molecule.getAtom(2));
+ IAtomContainer placedAndConnectedTo4 = atmplacer.getPlacedHeavyAtoms(molecule, molecule.getAtom(4));
- Assert.assertEquals(2, placed1.getAtomCount());
- Assert.assertEquals(1, placed2.getAtomCount());
- Assert.assertEquals(0, placed4.getAtomCount());
+ Assert.assertEquals(2, placedAndConnectedTo1.getAtomCount());
+ Assert.assertEquals(1, placedAndConnectedTo2.getAtomCount());
+ Assert.assertEquals(0, placedAndConnectedTo4.getAtomCount());
}
@Test
public void testGetPlacedHeavyAtom_IAtomContainer_IAtom_IAtom() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeAlkane(7);
- for(int j =0; j< 5; j++) {
- m.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeAlkane(7);
+ for(int j = 0; j< 5; j++) {
+ molecule.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
}
- IAtom c = ap.getPlacedHeavyAtom(m, m.getAtom(1), m.getAtom(0));
- IAtom d = ap.getPlacedHeavyAtom(m, m.getAtom(2), m.getAtom(1));
- IAtom e = ap.getPlacedHeavyAtom(m, m.getAtom(0), m.getAtom(1));
+ IAtom atom2 = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(1), molecule.getAtom(0));
+ IAtom atom3 = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(2), molecule.getAtom(1));
+ IAtom nullAtom = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(0), molecule.getAtom(1));
- Assert.assertEquals(c, m.getAtom(2));
- Assert.assertEquals(d, m.getAtom(3));
- Assert.assertNull(e);
+ Assert.assertEquals(atom2, molecule.getAtom(2));
+ Assert.assertEquals(atom3, molecule.getAtom(3));
+ Assert.assertNull(nullAtom);
}
-
@Test
public void testGetPlacedHeavyAtom_IAtomContainer_IAtom() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeCyclohexane();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeCyclohexane();
// for(IAtom a : m.atoms()) a.setFlag(CDKConstants.ISPLACED, true);
- for(int i=0; i< 3; i++) m.getAtom(i).setFlag(CDKConstants.ISPLACED, true);
+ for(int i=0; i< 3; i++) {
+ molecule.getAtom(i).setFlag(CDKConstants.ISPLACED, true);
+ }
- IAtom a = ap.getPlacedHeavyAtom(m, m.getAtom(0));
- Assert.assertEquals(a, m.getAtom(1));
- IAtom b = ap.getPlacedHeavyAtom(m, m.getAtom(2));
- Assert.assertEquals(b, m.getAtom(1));
- IAtom c = ap.getPlacedHeavyAtom(m, m.getAtom(4));
- Assert.assertNull(c);
+ IAtom atom1 = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(0));
+ Assert.assertEquals(atom1, molecule.getAtom(1));
+ IAtom atom2 = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(2));
+ Assert.assertEquals(atom2, molecule.getAtom(1));
+ IAtom atom3 = atmplacer.getPlacedHeavyAtom(molecule, molecule.getAtom(4));
+ Assert.assertNull(atom3);
}
@Test
public void testGeometricCenterAllPlacedAtoms_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeAlkane(2);
- for(IAtom a : m.atoms()) {
- a.setFlag(CDKConstants.ISPLACED, true);
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeAlkane(2);
+ for(IAtom atom : molecule.atoms()) {
+ atom.setFlag(CDKConstants.ISPLACED, true);
}
- m.getAtom(0).setPoint3d(new Point3d(-1.0, 0.0, 0.0));
- m.getAtom(1).setPoint3d(new Point3d(1.0, 0.0, 0.0));
+ molecule.getAtom(0).setPoint3d(new Point3d(-1.0, 0.0, 0.0));
+ molecule.getAtom(1).setPoint3d(new Point3d(1.0, 0.0, 0.0));
- Point3d c = ap.geometricCenterAllPlacedAtoms(m);
- Assert.assertEquals(0.0, c.x, 0.01);
- Assert.assertEquals(0.0, c.y, 0.01);
- Assert.assertEquals(0.0, c.z, 0.01);
+ Point3d center = atmplacer.geometricCenterAllPlacedAtoms(molecule);
+ Assert.assertEquals(0.0, center.x, 0.01);
+ Assert.assertEquals(0.0, center.y, 0.01);
+ Assert.assertEquals(0.0, center.z, 0.01);
}
@Test
public void testGetUnplacedRingHeavyAtom_IAtomContainer_IAtom() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeCyclopentane();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeCyclopentane();
- for(IAtom a : m.atoms()) a.setFlag(CDKConstants.ISINRING, true);
+ for(IAtom atom : molecule.atoms()) atom.setFlag(CDKConstants.ISINRING, true);
for(int j=0; j < 2; j++) {
- m.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
+ molecule.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
}
- IAtom a1 = m.getAtom(0);
- IAtom a2 = m.getAtom(1);
- IAtom n = m.getAtom(4);
+ IAtom atom0 = molecule.getAtom(0);
+ IAtom atom1 = molecule.getAtom(1);
+ IAtom natom = molecule.getAtom(4);
- IAtom b1 = ap.getUnplacedRingHeavyAtom(m, a1);
- IAtom b2 = ap.getUnplacedRingHeavyAtom(m, a2);
- IAtom nn = ap.getUnplacedRingHeavyAtom(m, n);
+ IAtom atom0pair = atmplacer.getUnplacedRingHeavyAtom(molecule, atom0);
+ IAtom atom1pair = atmplacer.getUnplacedRingHeavyAtom(molecule, atom1);
+ IAtom natompair = atmplacer.getUnplacedRingHeavyAtom(molecule, natom);
- Assert.assertEquals(b1, m.getAtom(4));
- Assert.assertEquals(b2, m.getAtom(2));
+ Assert.assertEquals(atom0pair, molecule.getAtom(4));
+ Assert.assertEquals(atom1pair, molecule.getAtom(2));
+ Assert.assertEquals(atom0.getFlag(CDKConstants.ISPLACED), true);
- Assert.assertEquals(m.getAtom(0).getFlag(CDKConstants.ISPLACED), true);
- for(IBond b : m.bonds()) {
- if(b.getConnectedAtom(m.getAtom(4)) != null &&
- !b.getConnectedAtom(m.getAtom(4)).getFlag(CDKConstants.ISPLACED)){
-
- nn = b.getConnectedAtom(m.getAtom(4));
+ for(IBond bond : molecule.bonds()) {
+ if(bond.getConnectedAtom(molecule.getAtom(4)) != null &&
+ !bond.getConnectedAtom(molecule.getAtom(4)).getFlag(CDKConstants.ISPLACED))
+ {
+ natompair = bond.getConnectedAtom(molecule.getAtom(4));
}
}
- Assert.assertEquals(nn, m.getAtom(3));
+ Assert.assertEquals(natompair, molecule.getAtom(3));
}
@Test
public void testGetFarthestAtom_Point3d_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeBenzene();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeBenzene();
- m.getAtom(0).setPoint3d(new Point3d(0.0, 0.0, 0.0));
- m.getAtom(1).setPoint3d(new Point3d(1.0, 1.0, 1.0));
- m.getAtom(4).setPoint3d(new Point3d(3.0, 2.0, 1.0));
- m.getAtom(5).setPoint3d(new Point3d(4.0, 4.0, 4.0));
+ molecule.getAtom(0).setPoint3d(new Point3d(0.0, 0.0, 0.0));
+ molecule.getAtom(1).setPoint3d(new Point3d(1.0, 1.0, 1.0));
+ molecule.getAtom(4).setPoint3d(new Point3d(3.0, 2.0, 1.0));
+ molecule.getAtom(5).setPoint3d(new Point3d(4.0, 4.0, 4.0));
- IAtom a = ap.getFarthestAtom(m.getAtom(0).getPoint3d(), m);
- IAtom b = ap.getFarthestAtom(m.getAtom(4).getPoint3d(), m);
+ IAtom farthestFromAtoma = atmplacer.getFarthestAtom(molecule.getAtom(0).getPoint3d(), molecule);
+ IAtom farthestFromAtomb = atmplacer.getFarthestAtom(molecule.getAtom(4).getPoint3d(), molecule);
- Assert.assertEquals(m.getAtom(5), a);
- Assert.assertEquals(m.getAtom(0), b);
+ Assert.assertEquals(molecule.getAtom(5), farthestFromAtoma);
+ Assert.assertEquals(molecule.getAtom(0), farthestFromAtomb);
}
@Test
public void testGetNextPlacedHeavyAtomWithUnplacedRingNeighbour_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m1 = MoleculeFactory.makeAlkane(3);
- IAtomContainer m2 = MoleculeFactory.makeCyclopentane();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer acyclicAlkane = MoleculeFactory.makeAlkane(3);
+ IAtomContainer cycloPentane = MoleculeFactory.makeCyclopentane();
//MoleculeFactory does not set ISINRING flags for cyclic molecules
- Assert.assertEquals(false, m2.getAtom(0).getFlag(CDKConstants.ISINRING));
- for(IAtom a : m2.atoms()) a.setFlag(CDKConstants.ISINRING, true);
+ Assert.assertEquals(false, cycloPentane.getAtom(0).getFlag(CDKConstants.ISINRING));
+ for(IAtom atom : cycloPentane.atoms()) {
+ atom.setFlag(CDKConstants.ISINRING, true);
+ }
//acyclic molecule so null is expected
- for(IAtom a : m1.atoms()) a.setFlag(CDKConstants.ISPLACED, true);
- Assert.assertNull(ap.getNextPlacedHeavyAtomWithUnplacedRingNeighbour(m1));
+ for(IAtom atom : acyclicAlkane.atoms()) {
+ atom.setFlag(CDKConstants.ISPLACED, true);
+ }
+ Assert.assertNull(atmplacer.getNextPlacedHeavyAtomWithUnplacedRingNeighbour(acyclicAlkane));
- //this method loops on the edges this is why it does not find 0 as the
- //next atom which is placed and has an unplaced ring atom neighbour, but
- //atom number 2
- for(int j=0; j < 3; j++) m2.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
- Assert.assertEquals(m2.getAtom(2), ap.getNextPlacedHeavyAtomWithUnplacedRingNeighbour(m2));
+ for(int j=0; j < 3; j++) {
+ cycloPentane.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
+ }
+ Assert.assertEquals(cycloPentane.getAtom(2), atmplacer.getNextPlacedHeavyAtomWithUnplacedRingNeighbour(cycloPentane));
-
}
@Test
public void testGetNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m1 = MoleculeFactory.makeBenzene();
- IAtomContainer m2 = MoleculeFactory.makeAlkane(5);
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer benzene = MoleculeFactory.makeBenzene();
+ IAtomContainer acyclicAlkane = MoleculeFactory.makeAlkane(5);
- for(IAtom a : m1.atoms()) a.setFlag(CDKConstants.ISINRING, true);
- for(IAtom a : m2.atoms() ) a.setFlag(CDKConstants.ISALIPHATIC, true);
+ for(IAtom atom : benzene.atoms()) atom.setFlag(CDKConstants.ISINRING, true);
+ for(IAtom atom : acyclicAlkane.atoms()) atom.setFlag(CDKConstants.ISALIPHATIC, true);
- for(int j=0; j< 3; j++) m1.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
- IAtom searchedatom1 = ap.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(m1);
+ for(int j=0; j< 3; j++) benzene.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
+ IAtom searchedatom1 = atmplacer.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(benzene);
Assert.assertNull(searchedatom1);
- for(IAtom a : m1.atoms()) {
- if(!a.getFlag(CDKConstants.ISPLACED)) a.setFlag(CDKConstants.ISPLACED, true);
+ for(IAtom atom : benzene.atoms()) {
+ if(!atom.getFlag(CDKConstants.ISPLACED)) {
+ atom.setFlag(CDKConstants.ISPLACED, true);
+ }
}
- IAtom searchedatom2 = ap.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(m1);
+ IAtom searchedatom2 = atmplacer.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(benzene);
Assert.assertNull(searchedatom2);
- for(int k=0; k < 3; k++) m2.getAtom(k).setFlag(CDKConstants.ISPLACED, true);
- IAtom a = ap.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(m2);
- Assert.assertEquals(m2.getAtom(2), a);
-
+ for(int k=0; k < 3; k++) {
+ acyclicAlkane.getAtom(k).setFlag(CDKConstants.ISPLACED, true);
+ }
+ IAtom nextAtom = atmplacer.getNextPlacedHeavyAtomWithUnplacedAliphaticNeighbour(acyclicAlkane);
+ Assert.assertEquals(acyclicAlkane.getAtom(2), nextAtom);
}
@Test
public void testGetNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m1 = MoleculeFactory.makeCyclobutane();
- IAtomContainer m2 = MoleculeFactory.makeAlkane(6);
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer cyclobutane = MoleculeFactory.makeCyclobutane();
+ IAtomContainer acyclicAlkane = MoleculeFactory.makeAlkane(6);
- for(IAtom a : m1.atoms()) a.setFlag(CDKConstants.ISINRING, true);
- for(IAtom a : m2.atoms()) a.setFlag(CDKConstants.ISALIPHATIC, true);
-
- for(int j=0; j < 3; j++) m1.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
- IAtom s1 = ap.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(m1);
- Assert.assertNull(s1);
+ for(IAtom atom : cyclobutane.atoms()) {
+ atom.setFlag(CDKConstants.ISINRING, true);
+ }
+ for(IAtom atom : acyclicAlkane.atoms()) {
+ atom.setFlag(CDKConstants.ISALIPHATIC, true);
+ }
+ for(int j=0; j < 3; j++) {
+ cyclobutane.getAtom(j).setFlag(CDKConstants.ISPLACED, true);
+ }
+ IAtom nextHeavyAtom = atmplacer.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(cyclobutane);
+ Assert.assertNull(nextHeavyAtom);
- for(IAtom a : m1.atoms()) {
- if(!a.getFlag(CDKConstants.ISPLACED)) a.setFlag(CDKConstants.ISPLACED, true);
+ for(IAtom atom : cyclobutane.atoms()) {
+ if(!atom.getFlag(CDKConstants.ISPLACED)) {
+ atom.setFlag(CDKConstants.ISPLACED, true);
+ }
}
- IAtom s2 = ap.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(m1);
- Assert.assertNull(s2);
+ IAtom nextHeavyAtom2 = atmplacer.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(cyclobutane);
+ Assert.assertNull(nextHeavyAtom2);
- for(int k=0; k < 3; k++) m2.getAtom(k).setFlag(CDKConstants.ISPLACED, true);
- IAtom a = ap.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(m2);
- Assert.assertEquals(m2.getAtom(3), a);
+ for(int k=0; k < 3; k++) {
+ acyclicAlkane.getAtom(k).setFlag(CDKConstants.ISPLACED, true);
+ }
+ IAtom nextSuchUnPlacedHeavyAtom = atmplacer.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(acyclicAlkane);
+ Assert.assertEquals(acyclicAlkane.getAtom(3), nextSuchUnPlacedHeavyAtom);
- for(IAtom atom : m2.atoms()) atom.setFlag(CDKConstants.ISPLACED, true);
- IAtom s3 = ap.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(m2);
- Assert.assertNull(s3);
+ for(IAtom atom : acyclicAlkane.atoms()) {
+ atom.setFlag(CDKConstants.ISPLACED, true);
+ }
+ nextSuchUnPlacedHeavyAtom = atmplacer.getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(acyclicAlkane);
+ Assert.assertNull(nextSuchUnPlacedHeavyAtom);
}
@Test
public void testGetAngleValue_String_String_String() throws Exception {
- SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- String smiles = "CCCCCC";
- IAtomContainer molecule = sp.parseSmiles(smiles);
- Assert.assertNotNull(molecule);
- ForceFieldConfigurator ffc= new ForceFieldConfigurator();
- ffc.setForceFieldConfigurator("mmff94");
- AtomPlacer3D atomPlacer3d= new AtomPlacer3D();
- atomPlacer3d.initilize(ffc.getParameterSet());
- ffc.assignAtomTyps(molecule);
-
- String id1 = molecule.getAtom(1).getAtomTypeName();
- String id2 = molecule.getAtom(2).getAtomTypeName();
- String id3 = molecule.getAtom(3).getAtomTypeName();
-
- double anglev = atomPlacer3d.getAngleValue(id1, id2, id3);
- Assert.assertTrue(anglev==109.608);
-
+ SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
+ String smiles = "CCCCCC";
+ IAtomContainer molecule = parser.parseSmiles(smiles);
+ Assert.assertNotNull(molecule);
+ ForceFieldConfigurator ffc= new ForceFieldConfigurator();
+ ffc.setForceFieldConfigurator("mmff94");
+ AtomPlacer3D atomPlacer3d= new AtomPlacer3D();
+ atomPlacer3d.initilize(ffc.getParameterSet());
+ ffc.assignAtomTyps(molecule);
+
+ String id1 = molecule.getAtom(1).getAtomTypeName();
+ String id2 = molecule.getAtom(2).getAtomTypeName();
+ String id3 = molecule.getAtom(3).getAtomTypeName();
+
+ double anglev = atomPlacer3d.getAngleValue(id1, id2, id3);
+ Assert.assertEquals(109.608, anglev, 0.001);
+
}
@Test
public void testGetBondLengthValue_String_String() throws Exception {
- SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
+ SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
String smiles = "CCCCCC";
- IAtomContainer molecule = sp.parseSmiles(smiles);
+ IAtomContainer molecule = parser.parseSmiles(smiles);
Assert.assertNotNull(molecule);
ForceFieldConfigurator ffc= new ForceFieldConfigurator();
ffc.setForceFieldConfigurator("mmff94");
@@ -301,35 +319,37 @@ public void testGetBondLengthValue_String_String() throws Exception {
Assert.assertNotSame(mmff94id2, id2);
double bondlength = atomPlacer3d.getBondLengthValue(id1, id2);
- Assert.assertTrue(bondlength==1.508);
+ Assert.assertEquals(1.508, bondlength, 0.001);
}
@Test
public void testMarkPlaced_IAtomContainer() {
- AtomPlacer3D ap = new AtomPlacer3D();
- IAtomContainer m = MoleculeFactory.makeAlkane(5);
- IAtomContainer pm = ap.markPlaced(m);
- for(IAtom a : pm.atoms()) Assert.assertTrue(a.getFlag(CDKConstants.ISPLACED));
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
+ IAtomContainer molecule = MoleculeFactory.makeAlkane(5);
+ IAtomContainer placedMolecule = atmplacer.markPlaced(molecule);
+ for(IAtom atom : placedMolecule.atoms()) {
+ Assert.assertTrue(atom.getFlag(CDKConstants.ISPLACED));
+ }
}
@Test
public void testZmatrixChainToCartesian_IAtomContainer_boolean() throws CDKException {
- AtomPlacer3D ap = new AtomPlacer3D();
+ AtomPlacer3D atmplacer = new AtomPlacer3D();
ForceFieldConfigurator ffc= new ForceFieldConfigurator();
ffc.setForceFieldConfigurator("mmff92");
- SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- String s1 = "CCCCCCCCCCCCCCCCCC";
- String s2 = "CCCCCC(CCCC)CCCC";
- IAtomContainer m1 = sp.parseSmiles(s1);
- IAtomContainer m2 = sp.parseSmiles(s2);
- ffc.assignAtomTyps(m1);
- ffc.assignAtomTyps(m2);
- ap.placeAliphaticHeavyChain(m1, m1);
- ap.placeAliphaticHeavyChain(m2, m2);
- ap.zmatrixChainToCartesian(m1, false);
- ap.zmatrixChainToCartesian(m2, true);
- ModelBuilder3DTest.checkAverageBondLength(m1);
- ModelBuilder3DTest.checkAverageBondLength(m2);
+ SmilesParser parser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
+ String smiles1 = "CCCCCCCCCCCCCCCCCC";
+ String smiles2 = "CCCCCC(CCCC)CCCC";
+ IAtomContainer notBranchedAlkane = parser.parseSmiles(smiles1);
+ IAtomContainer branchedAlkane = parser.parseSmiles(smiles2);
+ ffc.assignAtomTyps(notBranchedAlkane);
+ ffc.assignAtomTyps(branchedAlkane);
+ atmplacer.placeAliphaticHeavyChain(branchedAlkane, branchedAlkane);
+ atmplacer.placeAliphaticHeavyChain(notBranchedAlkane, notBranchedAlkane);
+ atmplacer.zmatrixChainToCartesian(notBranchedAlkane, false);
+ atmplacer.zmatrixChainToCartesian(branchedAlkane, true);
+ ModelBuilder3DTest.checkAverageBondLength(notBranchedAlkane);
+ ModelBuilder3DTest.checkAverageBondLength(branchedAlkane);
}
Please sign in to comment.
Something went wrong with that request. Please try again.