Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Deprecate MoleculeFactory and replace all test usage with TestMolecul…
…eFactory. The only non-test usage was in the legacy module where the required methods were lifted out.
  • Loading branch information
johnmay committed Jan 7, 2016
1 parent fcac95e commit a6195f1
Show file tree
Hide file tree
Showing 63 changed files with 407 additions and 286 deletions.
7 changes: 7 additions & 0 deletions base/reaction/pom.xml
Expand Up @@ -81,6 +81,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cdk-data</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cdk-testdata</artifactId>
Expand Down
Expand Up @@ -46,7 +46,7 @@
import org.openscience.cdk.reaction.type.parameters.IParameterReact;
import org.openscience.cdk.reaction.type.parameters.SetReactionCenter;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.templates.MoleculeFactory;
import org.openscience.cdk.templates.TestMoleculeFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.util.ArrayList;
Expand Down Expand Up @@ -1116,7 +1116,7 @@ public void testPreservingAromaticity() throws Exception {
@Test
public void testCyclobutadiene() throws Exception {
// anti-aromatic
IAtomContainer molecule = MoleculeFactory.makeCyclobutadiene();
IAtomContainer molecule = TestMoleculeFactory.makeCyclobutadiene();
addExplicitHydrogens(molecule);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
lpcheck.saturate(molecule);
Expand All @@ -1135,7 +1135,7 @@ public void testCyclobutadiene() throws Exception {
*/
@Test
public void testBenzene() throws Exception {
IAtomContainer molecule = MoleculeFactory.makeBenzene();
IAtomContainer molecule = TestMoleculeFactory.makeBenzene();
addExplicitHydrogens(molecule);
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
lpcheck.saturate(molecule);
Expand Down
7 changes: 7 additions & 0 deletions base/test-atomtype/pom.xml
Expand Up @@ -88,6 +88,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cdk-data</artifactId>
<version>${project.parent.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -40,7 +40,7 @@
import org.openscience.cdk.interfaces.IBond.Order;
import org.openscience.cdk.io.Mol2Reader;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.templates.MoleculeFactory;
import org.openscience.cdk.templates.TestMoleculeFactory;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ public void testGetInstance_IChemObjectBuilder() {
public void testFindMatchingAtomType_IAtomContainer_IAtom() throws Exception {
IAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(SilentChemObjectBuilder.getInstance());
Assert.assertNotNull(matcher);
IAtomContainer ethane = MoleculeFactory.makeAlkane(2);
IAtomContainer ethane = TestMoleculeFactory.makeAlkane(2);
String[] expectedTypes = {"C.3", "C.3"};
assertAtomTypes(testedAtomTypes, expectedTypes, ethane);
}
Expand Down Expand Up @@ -128,7 +128,7 @@ public void testAtomTyping() throws Exception {
*/
@Test
public void testBenzene() throws Exception {
IAtomContainer benzene = MoleculeFactory.makeBenzene();
IAtomContainer benzene = TestMoleculeFactory.makeBenzene();

// test if the perceived atom types match that
SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(benzene.getBuilder());
Expand All @@ -140,7 +140,7 @@ public void testBenzene() throws Exception {

@Test
public void testAdenine() throws Exception {
IAtomContainer mol = MoleculeFactory.makeAdenine();
IAtomContainer mol = TestMoleculeFactory.makeAdenine();
String[] expectedTypes = {"C.ar", "C.ar", "C.ar", "N.ar", "N.ar", "N.ar", "N.ar", "N.3", "C.ar", "C.ar"};
SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(mol.getBuilder());
IAtomType[] types = matcher.findMatchingAtomTypes(mol);
Expand All @@ -154,7 +154,7 @@ public void testAdenine() throws Exception {
*/
@Test
public void testBenzene_AtomContainer() throws Exception {
IAtomContainer benzene = MoleculeFactory.makeBenzene();
IAtomContainer benzene = TestMoleculeFactory.makeBenzene();

// test if the perceived atom types match that
SybylAtomTypeMatcher matcher = SybylAtomTypeMatcher.getInstance(benzene.getBuilder());
Expand Down Expand Up @@ -752,7 +752,7 @@ public void testHCN() throws Exception {

@Test
public void testAniline() throws Exception {
IAtomContainer benzene = MoleculeFactory.makeBenzene();
IAtomContainer benzene = TestMoleculeFactory.makeBenzene();
IAtom nitrogen = benzene.getBuilder().newInstance(IAtom.class, "N");
benzene.addAtom(nitrogen);
benzene.addBond(benzene.getBuilder().newInstance(IBond.class, benzene.getAtom(0), nitrogen, IBond.Order.SINGLE));
Expand Down
Expand Up @@ -47,7 +47,7 @@
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.silent.AtomType;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.templates.MoleculeFactory;
import org.openscience.cdk.templates.TestMoleculeFactory;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;
import org.openscience.cdk.tools.periodictable.PeriodicTable;
Expand Down Expand Up @@ -491,14 +491,14 @@ public void testEthene_withHybridInfo() throws Exception {

@Test
public void testPiperidine() throws Exception {
IAtomContainer molecule = MoleculeFactory.makePiperidine();
IAtomContainer molecule = TestMoleculeFactory.makePiperidine();
String[] expectedTypes = {"N.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "H"};
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testTetrahydropyran() throws Exception {
IAtomContainer molecule = MoleculeFactory.makeTetrahydropyran();
IAtomContainer molecule = TestMoleculeFactory.makeTetrahydropyran();
String[] expectedTypes = {"O.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}
Expand Down Expand Up @@ -779,7 +779,7 @@ public void testThioAmide() throws Exception {

@Test
public void testAdenine() throws Exception {
IAtomContainer mol = MoleculeFactory.makeAdenine();
IAtomContainer mol = TestMoleculeFactory.makeAdenine();
String[] expectedTypes = {"C.sp2", "C.sp2", "C.sp2", "N.sp2", "N.sp2", "N.planar3", "N.sp2", "N.sp3", "C.sp2",
"C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
Expand Down Expand Up @@ -2141,7 +2141,7 @@ public void testOxide() throws Exception {

@Test
public void testAzulene() throws Exception {
IAtomContainer molecule = MoleculeFactory.makeAzulene();
IAtomContainer molecule = TestMoleculeFactory.makeAzulene();
String[] expectedTypes = new String[]{"C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2",
"C.sp2", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
Expand All @@ -2150,7 +2150,7 @@ public void testAzulene() throws Exception {
@Test
public void testIndole() throws Exception {
String[] expectedTypes = {"C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "N.planar3"};
IAtomContainer molecule = MoleculeFactory.makeIndole();
IAtomContainer molecule = TestMoleculeFactory.makeIndole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

Expand All @@ -2160,7 +2160,7 @@ public void testIndole() throws Exception {
@Test
public void testno937() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "C.sp2", "N.sp2", "C.sp2", "C.sp3"};
IAtomContainer molecule = MoleculeFactory.makePyrrole();
IAtomContainer molecule = TestMoleculeFactory.makePyrrole();
molecule.getAtom(3).setSymbol("N");
molecule.addAtom(molecule.getBuilder().newInstance(IAtom.class, "C"));
molecule.addBond(1, 5, IBond.Order.SINGLE);
Expand Down Expand Up @@ -2199,14 +2199,14 @@ public void testBenzene_SingleOrDouble() throws Exception {
@Test
public void testPyrrole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyrrole();
IAtomContainer molecule = TestMoleculeFactory.makePyrrole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testPyrrole_SingleOrDouble() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyrrole();
IAtomContainer molecule = TestMoleculeFactory.makePyrrole();
for (IBond bond : molecule.bonds()) {
bond.setOrder(IBond.Order.UNSET);
bond.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
Expand All @@ -2220,56 +2220,56 @@ public void testPyrrole_SingleOrDouble() throws Exception {
@Test
public void testPyrroleAnion() throws Exception {
String[] expectedTypes = {"C.sp2", "N.minus.planar3", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyrroleAnion();
IAtomContainer molecule = TestMoleculeFactory.makePyrroleAnion();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testImidazole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "C.sp2", "N.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeImidazole();
IAtomContainer molecule = TestMoleculeFactory.makeImidazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testPyrazole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "N.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyrazole();
IAtomContainer molecule = TestMoleculeFactory.makePyrazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void test124Triazole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "N.sp2", "C.sp2", "N.sp2"};
IAtomContainer molecule = MoleculeFactory.make124Triazole();
IAtomContainer molecule = TestMoleculeFactory.make124Triazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void test123Triazole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.planar3", "N.sp2", "N.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.make123Triazole();
IAtomContainer molecule = TestMoleculeFactory.make123Triazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testTetrazole() throws Exception {
String[] expectedTypes = {"N.sp2", "N.planar3", "N.sp2", "N.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeTetrazole();
IAtomContainer molecule = TestMoleculeFactory.makeTetrazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testOxazole() throws Exception {
String[] expectedTypes = {"C.sp2", "O.planar3", "C.sp2", "N.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeOxazole();
IAtomContainer molecule = TestMoleculeFactory.makeOxazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testIsoxazole() throws Exception {
String[] expectedTypes = {"C.sp2", "O.planar3", "N.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeIsoxazole();
IAtomContainer molecule = TestMoleculeFactory.makeIsoxazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

Expand All @@ -2278,35 +2278,35 @@ public void testIsoxazole() throws Exception {
@Test
public void testIsothiazole() throws Exception {
String[] expectedTypes = {"C.sp2", "S.planar3", "N.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeIsothiazole();
IAtomContainer molecule = TestMoleculeFactory.makeIsothiazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testThiadiazole() throws Exception {
String[] expectedTypes = {"C.sp2", "S.planar3", "C.sp2", "N.sp2", "N.sp2"};
IAtomContainer molecule = MoleculeFactory.makeThiadiazole();
IAtomContainer molecule = TestMoleculeFactory.makeThiadiazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testOxadiazole() throws Exception {
String[] expectedTypes = {"C.sp2", "O.planar3", "C.sp2", "N.sp2", "N.sp2"};
IAtomContainer molecule = MoleculeFactory.makeOxadiazole();
IAtomContainer molecule = TestMoleculeFactory.makeOxadiazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testPyridine() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyridine();
IAtomContainer molecule = TestMoleculeFactory.makePyridine();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testPyridine_SingleOrDouble() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyridine();
IAtomContainer molecule = TestMoleculeFactory.makePyridine();
for (IBond bond : molecule.bonds()) {
bond.setOrder(IBond.Order.UNSET);
bond.setFlag(CDKConstants.SINGLE_OR_DOUBLE, true);
Expand Down Expand Up @@ -2376,7 +2376,7 @@ public void testPyridineWithSP2() throws Exception {
@Test
public void testChargedSulphurSpecies() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "C.sp2", "S.plus", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyridine();
IAtomContainer molecule = TestMoleculeFactory.makePyridine();
molecule.getAtom(4).setSymbol("S");
molecule.getAtom(4).setFormalCharge(+1);
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
Expand All @@ -2385,7 +2385,7 @@ public void testChargedSulphurSpecies() throws Exception {
@Test
public void testPyridineOxide_Charged() throws Exception {
String[] expectedTypes = {"C.sp2", "N.plus.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "O.minus"};
IAtomContainer molecule = MoleculeFactory.makePyridineOxide();
IAtomContainer molecule = TestMoleculeFactory.makePyridineOxide();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

Expand Down Expand Up @@ -2445,7 +2445,7 @@ public void testPyridineOxide_SP2() throws Exception {
@Test
public void testPyridineOxideCharged_SP2() throws Exception {
String[] expectedTypes = {"C.sp2", "N.plus.sp2", "C.sp2", "C.sp2", "C.sp2", "C.sp2", "O.minus"};
IAtomContainer molecule = MoleculeFactory.makePyridineOxide();
IAtomContainer molecule = TestMoleculeFactory.makePyridineOxide();
Iterator<IBond> bonds = molecule.bonds().iterator();
while (bonds.hasNext())
bonds.next().setOrder(Order.SINGLE);
Expand All @@ -2458,28 +2458,28 @@ public void testPyridineOxideCharged_SP2() throws Exception {
@Test
public void testPyrimidine() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "N.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyrimidine();
IAtomContainer molecule = TestMoleculeFactory.makePyrimidine();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testPyridazine() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "N.sp2", "C.sp2", "C.sp2", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makePyridazine();
IAtomContainer molecule = TestMoleculeFactory.makePyridazine();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testTriazine() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "N.sp2", "C.sp2", "N.sp2"};
IAtomContainer molecule = MoleculeFactory.makeTriazine();
IAtomContainer molecule = TestMoleculeFactory.makeTriazine();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

@Test
public void testThiazole() throws Exception {
String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "S.planar3", "C.sp2"};
IAtomContainer molecule = MoleculeFactory.makeThiazole();
IAtomContainer molecule = TestMoleculeFactory.makeThiazole();
assertAtomTypes(testedAtomTypes, expectedTypes, molecule);
}

Expand Down Expand Up @@ -3414,7 +3414,7 @@ public void testChiPathFail() throws Exception {
*/
@Test
public void testIodosobenzene() throws Exception {
IAtomContainer mol = MoleculeFactory.makeBenzene();
IAtomContainer mol = TestMoleculeFactory.makeBenzene();
IAtom iodine = mol.getBuilder().newInstance(IAtom.class, "I");
IAtom oxygen = mol.getBuilder().newInstance(IAtom.class, "O");
mol.addAtom(iodine);
Expand All @@ -3431,7 +3431,7 @@ public void testIodosobenzene() throws Exception {
*/
@Test
public void testIodoxybenzene() throws Exception {
IAtomContainer mol = MoleculeFactory.makeBenzene();
IAtomContainer mol = TestMoleculeFactory.makeBenzene();
IAtom iodine = mol.getBuilder().newInstance(IAtom.class, "I");
IAtom oxygen1 = mol.getBuilder().newInstance(IAtom.class, "O");
IAtom oxygen2 = mol.getBuilder().newInstance(IAtom.class, "O");
Expand All @@ -3451,7 +3451,7 @@ public void testIodoxybenzene() throws Exception {
*/
@Test
public void testThiobenzamideSOxide() throws Exception {
IAtomContainer mol = MoleculeFactory.makeBenzene();
IAtomContainer mol = TestMoleculeFactory.makeBenzene();
IAtom carbon = mol.getBuilder().newInstance(IAtom.class, "C");
IAtom sulphur = mol.getBuilder().newInstance(IAtom.class, "S");
IAtom oxygen = mol.getBuilder().newInstance(IAtom.class, "O");
Expand Down

0 comments on commit a6195f1

Please sign in to comment.