use of org.openscience.cdk.AtomContainer in project cdk by cdk.
the class AtomContainerSetManipulatorTest method testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom.
@Test
public void testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom() {
IAtomContainerSet ms = new AtomContainerSet();
IAtomContainer mol = new AtomContainer();
mol.addAtom(new Atom("O"));
mol.addAtom(new Atom("O"));
mol.addBond(0, 1, IBond.Order.DOUBLE);
IAtom atom = mol.getAtom(0);
ms.addAtomContainer(mol);
IAtom otherAtom = new Atom("O");
AtomContainerSetManipulator.removeAtomAndConnectedElectronContainers(ms, otherAtom);
Assert.assertEquals(1, AtomContainerSetManipulator.getBondCount(ms));
Assert.assertEquals(2, AtomContainerSetManipulator.getAtomCount(ms));
AtomContainerSetManipulator.removeAtomAndConnectedElectronContainers(ms, atom);
Assert.assertEquals(0, AtomContainerSetManipulator.getBondCount(ms));
Assert.assertEquals(1, AtomContainerSetManipulator.getAtomCount(ms));
}
use of org.openscience.cdk.AtomContainer in project cdk by cdk.
the class AtomContainerSetManipulatorTest method testRemoveElectronContainer_IAtomContainerSet_IElectronContainer.
@Test
public void testRemoveElectronContainer_IAtomContainerSet_IElectronContainer() {
IAtomContainerSet ms = new AtomContainerSet();
IAtomContainer mol = new AtomContainer();
mol.addAtom(new Atom("O"));
mol.addAtom(new Atom("O"));
mol.addBond(0, 1, IBond.Order.DOUBLE);
IBond bond = mol.getBond(0);
ms.addAtomContainer(mol);
IBond otherBond = new Bond(new Atom(), new Atom());
AtomContainerSetManipulator.removeElectronContainer(ms, otherBond);
Assert.assertEquals(1, AtomContainerSetManipulator.getBondCount(ms));
AtomContainerSetManipulator.removeElectronContainer(ms, bond);
Assert.assertEquals(0, AtomContainerSetManipulator.getBondCount(ms));
}
use of org.openscience.cdk.AtomContainer in project cdk by cdk.
the class ChemModelManipulatorTest method setUp.
@Before
public void setUp() {
molecule1 = new AtomContainer();
atomInMol1 = new Atom("Cl");
atomInMol1.setCharge(-1.0);
atomInMol1.setFormalCharge(-1);
atomInMol1.setImplicitHydrogenCount(1);
molecule1.addAtom(atomInMol1);
molecule1.addAtom(new Atom("Cl"));
bondInMol1 = new Bond(atomInMol1, molecule1.getAtom(1));
molecule1.addBond(bondInMol1);
molecule2 = new AtomContainer();
atomInMol2 = new Atom("O");
atomInMol2.setImplicitHydrogenCount(2);
molecule2.addAtom(atomInMol2);
moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
moleculeSet.addAtomContainer(molecule1);
moleculeSet.addAtomContainer(molecule2);
reaction = new Reaction();
reaction.addReactant(molecule1);
reaction.addProduct(molecule2);
reactionSet = new ReactionSet();
reactionSet.addReaction(reaction);
chemModel = new ChemModel();
chemModel.setMoleculeSet(moleculeSet);
chemModel.setReactionSet(reactionSet);
}
use of org.openscience.cdk.AtomContainer in project cdk by cdk.
the class ChemModelManipulatorTest method testNewChemModel_IAtomContainer.
@Test
public void testNewChemModel_IAtomContainer() {
IAtomContainer ac = new AtomContainer();
ac.addAtom(new Atom("C"));
IChemModel model = ChemModelManipulator.newChemModel(ac);
IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0);
Assert.assertNotNull(mol);
Assert.assertEquals(ac.getAtomCount(), mol.getAtomCount());
}
use of org.openscience.cdk.AtomContainer in project cdk by cdk.
the class ChemModelManipulatorTest method testRemoveElectronContainer_IChemModel_IElectronContainer.
@Test
public void testRemoveElectronContainer_IChemModel_IElectronContainer() {
IAtomContainer mol1 = new AtomContainer();
mol1.addAtom(new Atom("Cl"));
mol1.addAtom(new Atom("Cl"));
IBond bond1 = new Bond(mol1.getAtom(0), mol1.getAtom(1));
mol1.addBond(bond1);
IAtomContainer mol2 = new AtomContainer();
mol2.addAtom(new Atom("I"));
mol2.addAtom(new Atom("I"));
IBond bond2 = new Bond(mol2.getAtom(0), mol2.getAtom(1));
mol2.addBond(bond2);
IAtomContainerSet molSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
molSet.addAtomContainer(mol1);
IReaction r = new Reaction();
r.addProduct(mol2);
IReactionSet rSet = new ReactionSet();
rSet.addReaction(r);
IChemModel model = new ChemModel();
model.setMoleculeSet(molSet);
model.setReactionSet(rSet);
IBond otherBond = new Bond();
Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, otherBond);
Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, bond1);
Assert.assertEquals(1, ChemModelManipulator.getBondCount(model));
ChemModelManipulator.removeElectronContainer(model, bond2);
Assert.assertEquals(0, ChemModelManipulator.getBondCount(model));
}
Aggregations