use of org.openscience.cdk.interfaces.ISingleElectron in project ambit-mirror by ideaconsult.
the class SuppleAtomContainer method removeAllElectronContainers.
public void removeAllElectronContainers() {
removeAllBonds();
for (ILonePair lp : lonePairs()) lp.removeListener(this);
for (ISingleElectron se : singleElectrons) se.removeListener(this);
lonePairs.clear();
singleElectrons.clear();
notifyChanged();
}
use of org.openscience.cdk.interfaces.ISingleElectron in project ambit-mirror by ideaconsult.
the class SuppleAtomContainer method addSingleElectron.
public void addSingleElectron(int atomID) {
ISingleElectron singleElectron = MoleculeTools.newSingleElectron(getBuilder(), getAtom(atomID));
singleElectron.addListener(this);
addSingleElectron(singleElectron);
}
use of org.openscience.cdk.interfaces.ISingleElectron in project ambit-mirror by ideaconsult.
the class SuppleAtomContainer method init.
protected void init() {
atoms = new FilteredList<IAtom>();
bonds = new FilteredList<IBond>();
lonePairs = new ArrayList<ILonePair>();
singleElectrons = new ArrayList<ISingleElectron>();
int atomCount = getAtomCount();
stereoElements = new HashSet<IStereoElement>(atomCount / 2);
for (IStereoElement element : stereoElements()) {
addStereoElement(element);
}
}
use of org.openscience.cdk.interfaces.ISingleElectron in project ambit-mirror by ideaconsult.
the class SuppleAtomContainerTest method testGetSingleElectronNumber_ISingleElectron.
@Test
public void testGetSingleElectronNumber_ISingleElectron() {
IAtomContainer mol = new SuppleAtomContainer();
IAtom c = MoleculeTools.newAtom(builder, "C");
IAtom c1 = MoleculeTools.newAtom(builder, "C");
mol.addAtom(c);
mol.addAtom(c1);
mol.addSingleElectron(1);
ISingleElectron se = MoleculeTools.newSingleElectron(builder, c);
mol.addSingleElectron(se);
Assert.assertEquals(1, mol.getSingleElectronNumber(se));
}
use of org.openscience.cdk.interfaces.ISingleElectron 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());
}
Aggregations