use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testAddSingleElectron_ISingleElectron.
@Test
public void testAddSingleElectron_ISingleElectron() {
IAtomContainer acetone = new SuppleAtomContainer();
IAtom c = MoleculeTools.newAtom(builder, "C");
IAtom o = MoleculeTools.newAtom(builder, "O");
acetone.addAtom(c);
acetone.addAtom(o);
IBond b1 = MoleculeTools.newBond(builder, c, o, IBond.Order.DOUBLE);
acetone.addBond(b1);
ISingleElectron single1 = MoleculeTools.newSingleElectron(builder, c);
ISingleElectron single2 = MoleculeTools.newSingleElectron(builder, c);
ISingleElectron single3 = MoleculeTools.newSingleElectron(builder, o);
acetone.addSingleElectron(single1);
acetone.addSingleElectron(single2);
acetone.addSingleElectron(single3);
Assert.assertEquals(single1, (ISingleElectron) acetone.getConnectedSingleElectronsList(c).get(0));
Assert.assertEquals(single2, (ISingleElectron) acetone.getConnectedSingleElectronsList(c).get(1));
Assert.assertEquals(single3, (ISingleElectron) acetone.getConnectedSingleElectronsList(o).get(0));
}
use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testContains_IBond.
@Test
public void testContains_IBond() {
IAtomContainer acetone = new SuppleAtomContainer();
IAtom c = MoleculeTools.newAtom(builder, "C");
IAtom o = MoleculeTools.newAtom(builder, "O");
acetone.addAtom(c);
acetone.addAtom(o);
IBond b1 = MoleculeTools.newBond(builder, c, o, IBond.Order.DOUBLE);
acetone.addBond(b1);
IBond falseBond = MoleculeTools.newBond(builder);
Assert.assertTrue(acetone.contains(b1));
Assert.assertFalse(acetone.contains(falseBond));
}
use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testClone_IBond.
@Test
public void testClone_IBond() throws Exception {
IAtomContainer molecule = new SuppleAtomContainer();
// 1
molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
// 2
molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
// 3
molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
// 4
molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
// 1
molecule.addBond(0, 1, IBond.Order.DOUBLE);
// 2
molecule.addBond(1, 2, IBond.Order.SINGLE);
// 3
molecule.addBond(2, 3, IBond.Order.SINGLE);
IAtomContainer clonedMol = (IAtomContainer) molecule.clone();
Assert.assertNotNull(clonedMol);
Assert.assertEquals(molecule.getBondCount(), clonedMol.getBondCount());
for (int f = 0; f < molecule.getElectronContainerCount(); f++) {
for (int g = 0; g < clonedMol.getElectronContainerCount(); g++) {
Assert.assertNotNull(molecule.getBond(f));
Assert.assertNotNull(clonedMol.getBond(g));
Assert.assertNotSame(molecule.getBond(f), clonedMol.getBond(g));
}
}
}
use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testGetMaximumBondOrder_IAtom.
@Test
public void testGetMaximumBondOrder_IAtom() {
// acetone molecule
IAtomContainer acetone = new SuppleAtomContainer();
IAtom c1 = MoleculeTools.newAtom(builder, "C");
IAtom c2 = MoleculeTools.newAtom(builder, "C");
IAtom o = MoleculeTools.newAtom(builder, "O");
IAtom c3 = MoleculeTools.newAtom(builder, "C");
acetone.addAtom(c1);
acetone.addAtom(c2);
acetone.addAtom(c3);
acetone.addAtom(o);
acetone.addLonePair(2);
acetone.addLonePair(2);
IBond b1 = MoleculeTools.newBond(builder, c1, c2, IBond.Order.SINGLE);
IBond b2 = MoleculeTools.newBond(builder, c1, o, IBond.Order.DOUBLE);
IBond b3 = MoleculeTools.newBond(builder, c1, c3, IBond.Order.SINGLE);
acetone.addBond(b1);
acetone.addBond(b2);
acetone.addBond(b3);
Assert.assertEquals(IBond.Order.DOUBLE, acetone.getMaximumBondOrder(o));
Assert.assertEquals(IBond.Order.DOUBLE, acetone.getMaximumBondOrder(c1));
Assert.assertEquals(IBond.Order.SINGLE, acetone.getMaximumBondOrder(c2));
Assert.assertEquals(IBond.Order.SINGLE, acetone.getMaximumBondOrder(c3));
}
use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testRemoveAtomAndConnectedElectronContainers_IAtom.
@Test
public void testRemoveAtomAndConnectedElectronContainers_IAtom() {
// acetone molecule
IAtomContainer acetone = new SuppleAtomContainer();
IAtom c1 = MoleculeTools.newAtom(builder, "C");
IAtom c2 = MoleculeTools.newAtom(builder, "C");
IAtom o = MoleculeTools.newAtom(builder, "O");
IAtom c3 = MoleculeTools.newAtom(builder, "C");
acetone.addAtom(c1);
acetone.addAtom(c2);
acetone.addAtom(c3);
acetone.addAtom(o);
IBond b1 = MoleculeTools.newBond(builder, c1, c2, IBond.Order.SINGLE);
IBond b2 = MoleculeTools.newBond(builder, c1, o, IBond.Order.DOUBLE);
IBond b3 = MoleculeTools.newBond(builder, c1, c3, IBond.Order.SINGLE);
acetone.addBond(b1);
acetone.addBond(b2);
acetone.addBond(b3);
// add lone pairs on oxygen
ILonePair lp1 = MoleculeTools.newLonePair(builder, o);
ILonePair lp2 = MoleculeTools.newLonePair(builder, o);
acetone.addLonePair(lp1);
acetone.addLonePair(lp2);
// remove the oxygen
acetone.removeAtomAndConnectedElectronContainers(o);
Assert.assertEquals(3, acetone.getAtomCount());
Assert.assertEquals(2, acetone.getBondCount());
Assert.assertEquals(0, acetone.getLonePairCount());
}
Aggregations