Search in sources :

Example 1 with ILonePair

use of org.openscience.cdk.interfaces.ILonePair in project ambit-mirror by ideaconsult.

the class SuppleAtomContainer method getConnectedLonePairsList.

public List<ILonePair> getConnectedLonePairsList(IAtom atom) {
    List<ILonePair> lps = new ArrayList<ILonePair>();
    Iterator<ILonePair> lp = lonePairs.iterator();
    while (lp.hasNext()) {
        ILonePair p = lp.next();
        if (p.contains(atom))
            lps.add(p);
    }
    return lps;
}
Also used : ILonePair(org.openscience.cdk.interfaces.ILonePair) ArrayList(java.util.ArrayList)

Example 2 with ILonePair

use of org.openscience.cdk.interfaces.ILonePair in project ambit-mirror by ideaconsult.

the class SuppleAtomContainer method removeLonePair.

public ILonePair removeLonePair(int position) {
    ILonePair lp = lonePairs.get(position);
    lp.removeListener(this);
    lonePairs.remove(lp);
    notifyChanged();
    return lp;
}
Also used : ILonePair(org.openscience.cdk.interfaces.ILonePair)

Example 3 with ILonePair

use of org.openscience.cdk.interfaces.ILonePair 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 4 with ILonePair

use of org.openscience.cdk.interfaces.ILonePair 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 5 with ILonePair

use of org.openscience.cdk.interfaces.ILonePair in project ambit-mirror by ideaconsult.

the class SuppleAtomContainerTest method testAddLonePair_ILonePair.

@Test
public void testAddLonePair_ILonePair() {
    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);
    ILonePair lp1 = MoleculeTools.newLonePair(builder, o);
    ILonePair lp2 = MoleculeTools.newLonePair(builder, o);
    acetone.addLonePair(lp1);
    acetone.addLonePair(lp2);
    Assert.assertEquals(2, acetone.getConnectedLonePairsCount(o));
    Assert.assertEquals(0, acetone.getConnectedLonePairsCount(c));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) 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

ILonePair (org.openscience.cdk.interfaces.ILonePair)112 IAtom (org.openscience.cdk.interfaces.IAtom)85 Test (org.junit.Test)63 IBond (org.openscience.cdk.interfaces.IBond)63 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)59 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)32 SuppleAtomContainer (ambit2.core.groups.SuppleAtomContainer)21 IStereoElement (org.openscience.cdk.interfaces.IStereoElement)18 Sgroup (org.openscience.cdk.sgroup.Sgroup)12 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 IChemObject (org.openscience.cdk.interfaces.IChemObject)6 IAtomType (org.openscience.cdk.interfaces.IAtomType)5 IReaction (org.openscience.cdk.interfaces.IReaction)5 AbstractLonePairTest (org.openscience.cdk.test.interfaces.AbstractLonePairTest)5 CDKAtomTypeMatcher (org.openscience.cdk.atomtype.CDKAtomTypeMatcher)4 CDKException (org.openscience.cdk.exception.CDKException)4 IMapping (org.openscience.cdk.interfaces.IMapping)4 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)3 IElectronContainer (org.openscience.cdk.interfaces.IElectronContainer)3