Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 7 commits
  • 10 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 13, 2011
@egonw egonw Added a unit test for a phosphor without explicit or implicit hydrogens
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
5e980dd
Julio Peironcely Added the unit test phosphine for bug #3190151
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
740e4a5
@egonw egonw Added the Co(3+) atom type (fixes #3093644)
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
67d5625
@egonw egonw Fixed the use of the proper Convertor
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
2f19e98
@egonw egonw Updated to the 1.4.x API c5443a7
@egonw egonw Added two new authors 833a9ac
@egonw egonw Fixed a concurrency error, caused by the use of a static field which …
…was not supposed to be static, as the classes are instantiated just to allow customization

Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
c0ede3f
View
2 AUTHORS
@@ -1,5 +1,6 @@
Sam Adams
Rich Apodaca
+Saravanaraj N Ayyampalayam
Ulrich Bauer
Arvid Berg
Ed Cannon
@@ -30,6 +31,7 @@ Peter Murray-Rust
Irilenia Nobeli
Niels Out
Jerome Pansanel
+Julio Peironcely
Chris Pudney
Jonathan Rienstra-Kiracofe
Mark Rijnbeek
View
4 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -1234,6 +1234,10 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
atom.getFormalCharge() == +2)) {
IAtomType type = getAtomType("Co.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
+ } else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
+ atom.getFormalCharge() == +3)) {
+ IAtomType type = getAtomType("Co.3plus");
+ if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Co.metallic");
View
7 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1227,6 +1227,13 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>
+ <at:AtomType rdf:ID="Co.3plus">
+ <at:formalCharge>3</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Co"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
<at:AtomType rdf:ID="Co.metallic">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
View
2 src/main/org/openscience/cdk/io/CMLWriter.java
@@ -126,7 +126,7 @@
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(CMLWriter.class);
- private static List<ICMLCustomizer> customizers = null;
+ private List<ICMLCustomizer> customizers = null;
/**
* Constructs a new CMLWriter class. Output will be stored in the Writer
View
2 src/main/org/openscience/cdk/libio/cml/Convertor.java
@@ -101,7 +101,7 @@
LoggingToolFactory.createLoggingTool(Convertor.class);
private final static String CUSTOMIZERS_LIST = "libio-cml-customizers.set";
- private static Map<String, ICMLCustomizer> customizers = null;
+ private Map<String, ICMLCustomizer> customizers = null;
private boolean useCMLIDs;
private String prefix;
View
19 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherSMILESTest.java
@@ -108,7 +108,24 @@
Assert.assertNotNull(type.getAtomTypeName());
}
}
-
+
+ /**
+ * @cdk.bug 3093644
+ */
+ @Test public void testBug3093644() throws Exception {
+ String smiles1 =
+ "[H]C5(CCC(N)=O)(C=1N=C(C=C4N=C(C(C)=C3[N-]C(C)(C2N=C(C=1(C))C(C)" +
+ "(CCC(=O)NCC(C)O)C2([H])(CC(N)=O))C(C)(CC(N)=O)C3([H])(CCC(N)=O))" +
+ "C(C)(CC(N)=O)C4([H])(CCC(N)=O))C5(C)(C)).[H][C-]([H])C3([H])(OC([H])" +
+ "(N2C=NC=1C(N)=NC=NC=12)C([H])(O)C3([H])(O)).[Co+3]";
+
+ IMolecule mol1 = smilesParser.parseSmiles(smiles1);
+ IAtomType[] types1 = atomTypeMatcher.findMatchingAtomType(mol1);
+ for (IAtomType type : types1) {
+ Assert.assertNotNull(type.getAtomTypeName());
+ }
+ }
+
@Test public void testPlatinum4() throws Exception {
String smiles1 = "Cl[Pt]1(Cl)(Cl)(Cl)NC2CCCCC2N1";
View
52 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -1,7 +1,5 @@
-/* $Revision$ $Author$ $Date$
- *
- * Copyright (C) 2007 Egon Willighagen <egonw@users.sf.net>
- * 2007 Rajarshi Guha
+/* Copyright (C) 2007-2011 Egon Willighagen <egonw@users.sf.net>
+ * 2007 Rajarshi Guha
*
* Contact: cdk-devel@lists.sourceforge.net
*
@@ -35,17 +33,21 @@
import org.openscience.cdk.PseudoAtom;
import org.openscience.cdk.Ring;
import org.openscience.cdk.config.AtomTypeFactory;
+import org.openscience.cdk.config.Elements;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
-import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
-import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IAtomType.Hybridization;
+import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IBond.Order;
+import org.openscience.cdk.interfaces.IMolecule;
+import org.openscience.cdk.nonotify.NNAtom;
+import org.openscience.cdk.nonotify.NNAtomType;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.templates.MoleculeFactory;
import org.openscience.cdk.tools.periodictable.PeriodicTable;
+import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;
/**
* This class tests the matching of atom types defined in the
@@ -1619,6 +1621,13 @@ public void testTetrahydropyran() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
mol = new Molecule();
+ atom = new Atom("Co");
+ atom.setFormalCharge(+3);
+ mol.addAtom(atom);
+ expectedTypes = new String[]{"Co.3plus"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+
+ mol = new Molecule();
atom = new Atom("Cu");
atom.setFormalCharge(+2);
mol.addAtom(atom);
@@ -3347,6 +3356,37 @@ public void testNOxide() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
+ /**
+ * @cdk.bug 3190151
+ */
+ public void testP() throws Exception {
+ IAtom atomP = new NNAtom("P");
+ IAtomContainer mol = new Molecule();
+ mol.addAtom(atomP);
+ String[] expectedTypes = {"P.ine"};
+
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ /**
+ * @cdk.bug 3190151
+ */
+ public void testPine() throws Exception {
+ IAtom atomP = new NNAtom(Elements.PHOSPHORUS);
+ IAtomType atomTypeP = new NNAtomType(Elements.PHOSPHORUS);
+ AtomTypeManipulator.configure(atomP, atomTypeP);
+
+ IAtomContainer ac = atomP.getBuilder().newInstance(IAtomContainer.class);
+ ac.addAtom(atomP);
+ IAtomType type = null;
+ for (IAtom atom : ac.atoms()) {
+ type = CDKAtomTypeMatcher.getInstance(
+ ac.getBuilder()
+ ).findMatchingAtomType(ac, atom);
+ Assert.assertNotNull(type);
+ }
+ }
+
@Test public void countTestedAtomTypes() {
super.countTestedAtomTypes(testedAtomTypes);
}
View
45 src/test/org/openscience/cdk/io/cml/CDKRoundTripTest.java
@@ -34,8 +34,9 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
-import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
+import org.openscience.cdk.interfaces.IMolecule;
+import org.openscience.cdk.libio.cml.Convertor;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.tools.diff.AtomDiff;
@@ -46,11 +47,13 @@
private static IChemObjectBuilder builder = NoNotificationChemObjectBuilder.getInstance();
+ private static Convertor convertor = new Convertor(false, "");
+
@Test public void testIElement_Symbol() throws Exception {
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom atom = builder.newInstance(IAtom.class,"C");
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -60,7 +63,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setAtomicNumber(6);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -70,7 +73,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setNaturalAbundance(99.);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -80,7 +83,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setExactMass(12.);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -90,7 +93,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setMassNumber(13);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -100,7 +103,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setAtomTypeName("C.sp3");
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -110,7 +113,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setMaxBondOrder(IBond.Order.TRIPLE);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -120,7 +123,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setBondOrderSum(4.);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -130,7 +133,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setFormalCharge(+1);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -140,7 +143,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setFormalNeighbourCount(4);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -150,7 +153,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setHybridization(IAtomType.Hybridization.SP3);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -160,7 +163,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setCovalentRadius(1.5d);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -170,7 +173,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setValency(4);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -180,7 +183,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setCharge(0.3);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -190,7 +193,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setImplicitHydrogenCount(4);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -200,7 +203,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setPoint2d(new Point2d(1.0, 2.0));
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -210,7 +213,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setPoint3d(new Point3d(1.0, 2.0, 3.0));
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -220,7 +223,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setFractionalPoint3d(new Point3d(1.0, 2.0, 3.0));
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -232,7 +235,7 @@
atom.setPoint3d(new Point3d(-1.0, -2.0, -3.0));
atom.setFractionalPoint3d(new Point3d(1.0, 2.0, 3.0));
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
@@ -242,7 +245,7 @@
IAtom atom = builder.newInstance(IAtom.class,"C");
atom.setStereoParity(-1);
mol.addAtom(atom);
- IMolecule copy = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule copy = CMLRoundTripTool.roundTripMolecule(convertor, mol);
String difference = AtomDiff.diff(atom, copy.getAtom(0));;
Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length());
}
View
72 src/test/org/openscience/cdk/io/cml/CMLRoundTripTest.java
@@ -88,7 +88,7 @@
Atom atom = new Atom("N");
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -101,7 +101,7 @@
atom.setID("N1");
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -115,7 +115,7 @@
atom.setPoint2d(p2d);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -129,7 +129,7 @@
atom.setPoint3d(p3d);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -145,7 +145,7 @@
atom.setPoint3d(p3d);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -160,7 +160,7 @@
atom.setFractionalPoint3d(p3d);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -173,7 +173,7 @@
atom.setLabel("Glu55");
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -194,7 +194,7 @@
moleculeSet.addAtomContainer(mol);
model.setMoleculeSet(moleculeSet);
- IChemModel roundTrippedModel = CMLRoundTripTool.roundTripChemModel(model);
+ IChemModel roundTrippedModel = CMLRoundTripTool.roundTripChemModel(convertor, model);
IMoleculeSet roundTrippedMolSet = roundTrippedModel.getMoleculeSet();
Assert.assertNotNull(roundTrippedMolSet);
@@ -211,7 +211,7 @@
atom.setFormalCharge(formalCharge);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -227,7 +227,7 @@
atom.setImplicitHydrogenCount(3);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -243,7 +243,7 @@
atom.setImplicitHydrogenCount((Integer)CDKConstants.UNSET);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -258,7 +258,7 @@ public void testAtomPartialCharge() throws Exception {
atom.setCharge(partialCharge);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -273,7 +273,7 @@ public void testAtomStereoParity() throws Exception {
atom.setStereoParity(stereo);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -285,7 +285,7 @@ public void testAtomStereoParity() throws Exception {
Atom atom = new Atom("C");
atom.setMassNumber(13);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -300,7 +300,7 @@ public void testAtomStereoParity() throws Exception {
Atom atom = new Atom("C");
atom.setExactMass(13.0);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -315,7 +315,7 @@ public void testAtomStereoParity() throws Exception {
Atom atom = new Atom("C");
atom.setNaturalAbundance(1.0);
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -333,7 +333,7 @@ public void testAtomStereoParity() throws Exception {
mol.addAtom(atom);
Assert.assertEquals( 12, atom.getMassNumber().intValue() );
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -350,7 +350,7 @@ public void testAtomStereoParity() throws Exception {
Bond bond = new Bond(atom, atom2, IBond.Order.SINGLE);
mol.addBond(bond);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(2, roundTrippedMol.getAtomCount());
Assert.assertEquals(1, roundTrippedMol.getBondCount());
@@ -371,7 +371,7 @@ public void testAtomStereoParity() throws Exception {
bond.setID("b1");
mol.addBond(bond);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
IBond roundTrippedBond = roundTrippedMol.getBond(0);
Assert.assertEquals(bond.getID(), roundTrippedBond.getID());
}
@@ -387,7 +387,7 @@ public void testAtomStereoParity() throws Exception {
bond.setStereo(stereo);
mol.addBond(bond);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(2, roundTrippedMol.getAtomCount());
Assert.assertEquals(1, roundTrippedMol.getBondCount());
@@ -406,7 +406,7 @@ public void testAtomStereoParity() throws Exception {
bond.setFlag(CDKConstants.ISAROMATIC, true);
mol.addBond(bond);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(2, roundTrippedMol.getAtomCount());
Assert.assertEquals(1, roundTrippedMol.getBondCount());
@@ -429,7 +429,7 @@ public void testAtomStereoParity() throws Exception {
bond.setFlag(CDKConstants.ISAROMATIC, true);
mol.addBond(bond);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(2, roundTrippedMol.getAtomCount());
Assert.assertEquals(1, roundTrippedMol.getBondCount());
@@ -445,7 +445,7 @@ public void testAtomStereoParity() throws Exception {
double charge = -0.267;
atom.setCharge(charge);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
@@ -457,7 +457,7 @@ public void testAtomStereoParity() throws Exception {
String inchi = "InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)";
mol.setProperty(CDKConstants.INCHI, inchi);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertNotNull(roundTrippedMol);
Assert.assertEquals(inchi, roundTrippedMol.getProperty(CDKConstants.INCHI));
@@ -469,7 +469,7 @@ public void testAtomStereoParity() throws Exception {
mol.addAtom(atom);
mol.addSingleElectron(new SingleElectron(atom));
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
Assert.assertEquals(1, roundTrippedMol.getElectronContainerCount());
@@ -499,7 +499,7 @@ public void testAtomStereoParity() throws Exception {
agent.addAtom(atom);
reaction.addAgent(agent);
- IReaction roundTrippedReaction = CMLRoundTripTool.roundTripReaction(reaction);
+ IReaction roundTrippedReaction = CMLRoundTripTool.roundTripReaction(convertor, reaction);
Assert.assertNotNull(roundTrippedReaction);
Assert.assertEquals("reaction.1", roundTrippedReaction.getID());
@@ -533,10 +533,12 @@ public void testAtomStereoParity() throws Exception {
DescriptorValue originalValue = null;
originalValue = descriptor.calculate(molecule);
molecule.setProperty(originalValue.getSpecification(), originalValue);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(molecule);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);
Assert.assertEquals(1, roundTrippedMol.getProperties().size());
+ System.out.println("" + roundTrippedMol.getProperties().keySet());
Object object = roundTrippedMol.getProperties().keySet().toArray()[0];
+ System.out.println("" + object);
Assert.assertTrue(object instanceof DescriptorSpecification);
DescriptorSpecification spec = (DescriptorSpecification)object;
Assert.assertEquals(descriptor.getSpecification().getSpecificationReference(),
@@ -566,7 +568,7 @@ public void testAtomStereoParity() throws Exception {
for (int i=0; i < propertyName.length;i++)
molecule.setProperty(propertyName[i], propertyValue[i]);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(molecule);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);
for (int i=0; i < propertyName.length;i++) {
Assert.assertNotNull(roundTrippedMol.getProperty(propertyName[i]));
@@ -585,7 +587,7 @@ public void testAtomStereoParity() throws Exception {
bond.setFlag(CDKConstants.ISAROMATIC, true);
}
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(molecule);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);
Iterator<IBond> bonds = roundTrippedMol.bonds().iterator();
double orderSum = BondManipulator.getSingleBondEquivalentSum(bonds);
while (bonds.hasNext()) {
@@ -600,7 +602,7 @@ public void testAtomStereoParity() throws Exception {
atom.setFlag(CDKConstants.ISAROMATIC, true);
}
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(molecule);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, molecule);
for (IAtom atom : roundTrippedMol.atoms()) {
Assert.assertTrue(atom.getFlag(CDKConstants.ISAROMATIC));
}
@@ -623,7 +625,7 @@ public void testAtomStereoParity() throws Exception {
a.setProperty(key[i], value[i]);
}
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
//Assert.assertEquals(convertor.cdkMoleculeToCMLMolecule(mol).toXML(),
// convertor.cdkMoleculeToCMLMolecule(roundTrippedMol).toXML());
@@ -653,7 +655,7 @@ public void testAtomStereoParity() throws Exception {
b.setProperty(key[i], value[i]);
}
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
//Assert.assertEquals(convertor.cdkMoleculeToCMLMolecule(mol).toXML(),
// convertor.cdkMoleculeToCMLMolecule(roundTrippedMol).toXML());
@@ -681,7 +683,7 @@ public void testAtomStereoParity() throws Exception {
for (int i=0; i < key.length;i++) {
mol.setProperty(key[i], value[i]);
}
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
//Assert.assertEquals(convertor.cdkMoleculeToCMLMolecule(mol).toXML(),
// convertor.cdkMoleculeToCMLMolecule(roundTrippedMol).toXML());
for (int i=0; i < key.length;i++) {
@@ -698,7 +700,7 @@ public void testAtomStereoParity() throws Exception {
IChemModel model = new ChemModel();
model.setMoleculeSet(list);
- IChemModel roundTripped = CMLRoundTripTool.roundTripChemModel(model);
+ IChemModel roundTripped = CMLRoundTripTool.roundTripChemModel(convertor, model);
IMoleculeSet newList = roundTripped.getMoleculeSet();
Assert.assertNotNull(newList);
Assert.assertEquals(2, newList.getAtomContainerCount());
@@ -731,7 +733,7 @@ public void testAtomStereoParity() throws Exception {
Assert.assertNull(atom.getImplicitHydrogenCount());
mol.addAtom(atom);
- IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(mol);
+ IMolecule roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol);
Assert.assertEquals(1, roundTrippedMol.getAtomCount());
IAtom roundTrippedAtom = roundTrippedMol.getAtom(0);
View
7 src/test/org/openscience/cdk/io/cml/CMLRoundTripTool.java
@@ -53,7 +53,6 @@
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(CMLRoundTripTool.class);
- private static Convertor convertor = new Convertor(true, null);
/**
* Convert a Molecule to CML and back to a Molecule again.
@@ -62,7 +61,7 @@
*
* @see org.openscience.cdk.CMLFragmentsTest
*/
- public static IMolecule roundTripMolecule(IMolecule mol) throws Exception {
+ public static IMolecule roundTripMolecule(Convertor convertor, IMolecule mol) throws Exception {
String cmlString = "<!-- failed -->";
Element cmlDOM = convertor.cdkMoleculeToCMLMolecule(mol);
cmlString = cmlDOM.toXML();
@@ -88,7 +87,7 @@ public static IMolecule roundTripMolecule(IMolecule mol) throws Exception {
return roundTrippedMol;
}
- public static IChemModel roundTripChemModel(IChemModel model) throws Exception {
+ public static IChemModel roundTripChemModel(Convertor convertor, IChemModel model) throws Exception {
String cmlString = "<!-- failed -->";
Element cmlDOM = convertor.cdkChemModelToCMLList(model);
cmlString = cmlDOM.toXML();
@@ -108,7 +107,7 @@ public static IChemModel roundTripChemModel(IChemModel model) throws Exception {
return chemModel;
}
- public static IReaction roundTripReaction(IReaction reaction) throws Exception {
+ public static IReaction roundTripReaction(Convertor convertor, IReaction reaction) throws Exception {
String cmlString = "<!-- failed -->";
Element cmlDOM = convertor.cdkReactionToCMLReaction(reaction);
cmlString = cmlDOM.toXML();

No commit comments for this range

Something went wrong with that request. Please try again.