use of org.openscience.cdk.interfaces.IElectronContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainer method removeElectronContainer.
public IElectronContainer removeElectronContainer(int number) {
IElectronContainer el = getElectronContainer(number);
removeElectronContainer(el);
/*
* if (number < this.bondCount) return removeBond(number); number -=
* this.bondCount; if (number < this.lonePairCount) return
* removeLonePair(number); number -= this.lonePairCount; if (number <
* this.singleElectronCount) return removeSingleElectron(number);
*/
return el;
}
use of org.openscience.cdk.interfaces.IElectronContainer in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testElectronContainers.
@Test
public void testElectronContainers() {
// 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 bond1 = MoleculeTools.newBond(builder, c1, c2, IBond.Order.SINGLE);
IBond bond2 = MoleculeTools.newBond(builder, c2, o, IBond.Order.DOUBLE);
IBond bond3 = MoleculeTools.newBond(builder, c2, c3, IBond.Order.SINGLE);
acetone.addBond(bond1);
acetone.addBond(bond2);
acetone.addBond(bond3);
ISingleElectron se1 = MoleculeTools.newSingleElectron(builder, c1);
ISingleElectron se2 = MoleculeTools.newSingleElectron(builder, c2);
acetone.addSingleElectron(se1);
acetone.addSingleElectron(se2);
ILonePair lp1 = MoleculeTools.newLonePair(builder, o);
ILonePair lp2 = MoleculeTools.newLonePair(builder, o);
acetone.addLonePair(lp1);
acetone.addLonePair(lp2);
java.util.Iterator<IElectronContainer> electronContainers = acetone.electronContainers().iterator();
Assert.assertNotNull(electronContainers);
Assert.assertTrue(electronContainers.hasNext());
electronContainers.next();
electronContainers.next();
IElectronContainer ec = (IElectronContainer) electronContainers.next();
Assert.assertTrue(ec instanceof IBond);
Assert.assertEquals(bond3, ec);
electronContainers.next();
ILonePair lp = (ILonePair) electronContainers.next();
Assert.assertTrue(lp instanceof ILonePair);
Assert.assertEquals(lp2, lp);
electronContainers.remove();
ISingleElectron se = (ISingleElectron) electronContainers.next();
Assert.assertTrue(se instanceof ISingleElectron);
Assert.assertEquals(se1, se);
Assert.assertTrue(electronContainers.hasNext());
se = (ISingleElectron) electronContainers.next();
Assert.assertTrue(se instanceof ISingleElectron);
Assert.assertEquals(se2, se);
Assert.assertFalse(electronContainers.hasNext());
}
use of org.openscience.cdk.interfaces.IElectronContainer in project cdk by cdk.
the class ElectronContainerTest method testElectronContainer.
@Test
public void testElectronContainer() {
IElectronContainer ec = new ElectronContainer();
Assert.assertNotNull(ec);
Assert.assertEquals(0, ec.getElectronCount().intValue());
}
use of org.openscience.cdk.interfaces.IElectronContainer in project cdk by cdk.
the class DebugElectronContainerTest method testDebugElectronContainer.
@Test
public void testDebugElectronContainer() {
IElectronContainer ec = new DebugElectronContainer();
Assert.assertNotNull(ec);
Assert.assertEquals(0, ec.getElectronCount().intValue());
}
use of org.openscience.cdk.interfaces.IElectronContainer in project cdk by cdk.
the class AbstractElectronContainerTest method testToString.
/**
* Method to test whether the class complies with RFC #9.
*/
@Test
public void testToString() {
IElectronContainer at = (IElectronContainer) newChemObject();
String description = at.toString();
for (int i = 0; i < description.length(); i++) {
Assert.assertTrue(description.charAt(i) != '\n');
Assert.assertTrue(description.charAt(i) != '\r');
}
}
Aggregations