Search in sources :

Example 1 with ISingleElectron

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();
}
Also used : ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) ILonePair(org.openscience.cdk.interfaces.ILonePair)

Example 2 with ISingleElectron

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);
}
Also used : ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron)

Example 3 with ISingleElectron

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);
    }
}
Also used : ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) ILonePair(org.openscience.cdk.interfaces.ILonePair) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) IStereoElement(org.openscience.cdk.interfaces.IStereoElement)

Example 4 with ISingleElectron

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));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 5 with ISingleElectron

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());
}
Also used : IElectronContainer(org.openscience.cdk.interfaces.IElectronContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) ILonePair(org.openscience.cdk.interfaces.ILonePair) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Aggregations

ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)90 IAtom (org.openscience.cdk.interfaces.IAtom)66 Test (org.junit.Test)43 IBond (org.openscience.cdk.interfaces.IBond)42 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)40 ILonePair (org.openscience.cdk.interfaces.ILonePair)32 IStereoElement (org.openscience.cdk.interfaces.IStereoElement)19 Sgroup (org.openscience.cdk.sgroup.Sgroup)13 HashMap (java.util.HashMap)12 SuppleAtomContainer (ambit2.core.groups.SuppleAtomContainer)11 ArrayList (java.util.ArrayList)9 IChemObject (org.openscience.cdk.interfaces.IChemObject)9 AbstractSingleElectronTest (org.openscience.cdk.test.interfaces.AbstractSingleElectronTest)6 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)5 IReaction (org.openscience.cdk.interfaces.IReaction)5 CDKAtomTypeMatcher (org.openscience.cdk.atomtype.CDKAtomTypeMatcher)4 CDKException (org.openscience.cdk.exception.CDKException)4 IAtomType (org.openscience.cdk.interfaces.IAtomType)4 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)4 IMapping (org.openscience.cdk.interfaces.IMapping)4