StructureResonanceGenerator { public IAtomContainer getContainer(IAtomContainer molecule, IAtom atom) { IAtomContainerSet setOfCont = getContainers(molecule); if (setOfCont == null) return null; for (IAtomContainer container : setOfCont.atomContainers()) { if (container.contains(atom)) return container; } return null; } StructureResonanceGenerator();  StructureResonanceGenerator(boolean lookingSymmetry); void setReactions(List<IReactionProcess> newReactionsList); List<IReactionProcess> getReactions(); void setMaximalStructures(int maxStruct); int getMaximalStructures(); void setDefaultReactions(); IAtomContainerSet getStructures(IAtomContainer molecule); IAtomContainerSet getContainers(IAtomContainer molecule); IAtomContainer getContainer(IAtomContainer molecule, IAtom atom); IAtomContainer getContainer(IAtomContainer molecule, IBond bond);  }
@Test @Category(SlowTest.class) public void testFluorobenzeneContainer() throws Exception { IAtomContainer molecule = builder.newInstance(IAtomContainer.class); molecule.addAtom(builder.newInstance(IAtom.class, "F")); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(0, 1, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(1, 2, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(2, 3, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(3, 4, IBond.Order.DOUBLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(4, 5, IBond.Order.SINGLE); molecule.addAtom(builder.newInstance(IAtom.class, "C")); molecule.addBond(5, 6, IBond.Order.DOUBLE); molecule.addBond(6, 1, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); StructureResonanceGenerator gRI = new StructureResonanceGenerator(); IAtomContainer container = gRI.getContainer(molecule, molecule.getAtom(0)); Assert.assertEquals(7, container.getAtomCount()); }
@Test @Category(SlowTest.class) public void testGetContainer_IAtomContainer_IAtom() throws Exception { IAtomContainer molecule = builder.newInstance(IAtomContainer.class); IAtom atom1 = builder.newInstance(IAtom.class, "C"); atom1.setID("atom1"); molecule.addAtom(atom1); IAtom atom2 = builder.newInstance(IAtom.class, "C"); atom2.setID("atom2"); molecule.addAtom(atom2); molecule.addBond(0, 1, IBond.Order.SINGLE); IAtom atom3 = builder.newInstance(IAtom.class, "C"); atom3.setID("atom3"); molecule.addAtom(atom3); molecule.addBond(1, 2, IBond.Order.DOUBLE); IAtom atom4 = builder.newInstance(IAtom.class, "C"); atom4.setID("atom4"); molecule.addAtom(atom4); atom4.setFormalCharge(+1); molecule.addBond(2, 3, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(3, 4, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(4, 5, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(5, 6, IBond.Order.DOUBLE); molecule.addAtom(new Atom("C")); molecule.getAtom(7).setFormalCharge(+1); molecule.addBond(6, 7, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); StructureResonanceGenerator sRG = new StructureResonanceGenerator(); IAtomContainer container = sRG.getContainer(molecule, atom4); Assert.assertEquals(3, container.getAtomCount()); Assert.assertEquals(2, container.getBondCount()); Assert.assertTrue(container.contains(atom4)); }
@Test @Category(SlowTest.class) public void testGetContainer_IAtomContainer_IBond() throws Exception { IAtomContainer molecule = builder.newInstance(IAtomContainer.class); IAtom atom1 = builder.newInstance(IAtom.class, "C"); atom1.setID("atom1"); molecule.addAtom(atom1); IAtom atom2 = builder.newInstance(IAtom.class, "C"); atom2.setID("atom2"); molecule.addAtom(atom2); molecule.addBond(0, 1, IBond.Order.SINGLE); IAtom atom3 = builder.newInstance(IAtom.class, "C"); atom3.setID("atom3"); molecule.addAtom(atom3); molecule.addBond(1, 2, IBond.Order.DOUBLE); IAtom atom4 = builder.newInstance(IAtom.class, "C"); atom4.setID("atom4"); molecule.addAtom(atom4); atom4.setFormalCharge(+1); molecule.addBond(2, 3, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(3, 4, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(4, 5, IBond.Order.SINGLE); molecule.addAtom(new Atom("C")); molecule.addBond(5, 6, IBond.Order.DOUBLE); molecule.addAtom(new Atom("C")); molecule.getAtom(7).setFormalCharge(+1); molecule.addBond(6, 7, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); StructureResonanceGenerator sRG = new StructureResonanceGenerator(); IAtomContainer container = sRG.getContainer(molecule, molecule.getBond(1)); Assert.assertEquals(3, container.getAtomCount()); Assert.assertEquals(2, container.getBondCount()); Assert.assertTrue(container.contains(molecule.getBond(1))); }
@Test @Category(SlowTest.class) public void testGetID() throws Exception { IAtomContainer molecule = builder.newInstance(IAtomContainer.class); IAtom atom1 = builder.newInstance(IAtom.class, "C"); atom1.setID("atom1"); molecule.addAtom(atom1); IAtom atom2 = builder.newInstance(IAtom.class, "C"); atom2.setID("atom2"); molecule.addAtom(atom2); molecule.addBond(0, 1, IBond.Order.SINGLE); IAtom atom3 = builder.newInstance(IAtom.class, "C"); atom3.setID("atom3"); molecule.addAtom(atom3); molecule.addBond(1, 2, IBond.Order.DOUBLE); IAtom atom4 = builder.newInstance(IAtom.class, "C"); atom4.setID("atom4"); molecule.addAtom(atom4); atom4.setFormalCharge(+1); molecule.addBond(2, 3, IBond.Order.SINGLE); IAtom atom5 = builder.newInstance(IAtom.class, "C"); atom5.setID("atom5"); molecule.addAtom(atom5); molecule.addBond(3, 4, IBond.Order.SINGLE); IAtom atom6 = builder.newInstance(IAtom.class, "C"); atom6.setID("atom6"); molecule.addAtom(atom6); molecule.addBond(4, 5, IBond.Order.SINGLE); IAtom atom7 = builder.newInstance(IAtom.class, "C"); atom7.setID("atom7"); molecule.addAtom(atom7); molecule.addBond(5, 6, IBond.Order.DOUBLE); IAtom atom8 = builder.newInstance(IAtom.class, "C"); atom8.setID("atom8"); molecule.addAtom(atom8); atom8.setFormalCharge(+1); molecule.addBond(6, 7, IBond.Order.SINGLE); addExplicitHydrogens(molecule); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule); lpcheck.saturate(molecule); StructureResonanceGenerator sRG = new StructureResonanceGenerator(); IAtomContainer container = sRG.getContainer(molecule, atom4); Assert.assertNotNull(atom2.getID()); Assert.assertNotNull(atom3.getID()); Assert.assertNotNull(atom4.getID()); Assert.assertEquals(atom2.getID(), container.getAtom(0).getID()); Assert.assertEquals(atom3.getID(), container.getAtom(1).getID()); Assert.assertEquals(atom4.getID(), container.getAtom(2).getID()); }