Search in sources :

Example 1 with IElectronContainer

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

Example 2 with IElectronContainer

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());
}
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)

Example 3 with IElectronContainer

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());
}
Also used : IElectronContainer(org.openscience.cdk.interfaces.IElectronContainer) IElectronContainer(org.openscience.cdk.interfaces.IElectronContainer) Test(org.junit.Test) AbstractElectronContainerTest(org.openscience.cdk.test.interfaces.AbstractElectronContainerTest)

Example 4 with IElectronContainer

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());
}
Also used : IElectronContainer(org.openscience.cdk.interfaces.IElectronContainer) Test(org.junit.Test) AbstractElectronContainerTest(org.openscience.cdk.test.interfaces.AbstractElectronContainerTest)

Example 5 with IElectronContainer

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

Aggregations

IElectronContainer (org.openscience.cdk.interfaces.IElectronContainer)19 Test (org.junit.Test)14 IBond (org.openscience.cdk.interfaces.IBond)5 ArrayList (java.util.ArrayList)3 ILonePair (org.openscience.cdk.interfaces.ILonePair)3 AbstractElectronContainerTest (org.openscience.cdk.test.interfaces.AbstractElectronContainerTest)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 IAtom (org.openscience.cdk.interfaces.IAtom)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)2 SuppleAtomContainer (ambit2.core.groups.SuppleAtomContainer)1 AtomRef (org.openscience.cdk.AtomRef)1 IChemObjectBuilder (org.openscience.cdk.interfaces.IChemObjectBuilder)1 ChemObjectDifference (org.openscience.cdk.tools.diff.tree.ChemObjectDifference)1 IDifference (org.openscience.cdk.tools.diff.tree.IDifference)1 IDifferenceList (org.openscience.cdk.tools.diff.tree.IDifferenceList)1