Search in sources :

Example 1 with SuppleAtomContainer

use of ambit2.core.groups.SuppleAtomContainer 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)

Example 2 with SuppleAtomContainer

use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.

the class SuppleAtomContainerTest method testAddAtom_IAtom.

// @Test public void testSetElectronContainerCount_int() {
// IAtomContainer container = new SuppleAtomContainer();
// container.setElectronContainerCount(2);
// 
// Assert.assertEquals(2, container.getElectronContainerCount());
// }
// @Test public void testSetAtomCount_int() {
// IAtomContainer container = new SuppleAtomContainer();
// container.setAtomCount(2);
// 
// Assert.assertEquals(2, container.getAtomCount());
// }
// @Test public void testGetAtoms() {
// // 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);
// 
// Assert.assertEquals(4, acetone.getAtoms().length);
// }
@Test
public void testAddAtom_IAtom() {
    // 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);
    int counter = 0;
    for (IAtom atom : acetone.atoms()) {
        counter++;
    }
    Assert.assertEquals(4, counter);
    // test force growing of default arrays
    for (int i = 0; i < 11; i++) {
        acetone.addAtom(MoleculeTools.newAtom(builder));
        acetone.addBond(MoleculeTools.newBond(builder));
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 3 with SuppleAtomContainer

use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.

the class SuppleAtomContainerTest method testRemoveLonePair_ILonePair.

@Test
public void testRemoveLonePair_ILonePair() {
    IAtomContainer mol = new SuppleAtomContainer();
    IAtom c = MoleculeTools.newAtom(builder, "C");
    IAtom c1 = MoleculeTools.newAtom(builder, "C");
    mol.addAtom(c);
    mol.addAtom(c1);
    ILonePair lp = MoleculeTools.newLonePair(builder, c1);
    mol.addLonePair(lp);
    ILonePair lp1 = MoleculeTools.newLonePair(builder, c);
    mol.addLonePair(lp1);
    mol.removeLonePair(lp);
    Assert.assertEquals(1, mol.getLonePairCount());
    Assert.assertEquals(lp1, mol.getLonePair(0));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) ILonePair(org.openscience.cdk.interfaces.ILonePair) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 4 with SuppleAtomContainer

use of ambit2.core.groups.SuppleAtomContainer 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 SuppleAtomContainer

use of ambit2.core.groups.SuppleAtomContainer in project ambit-mirror by ideaconsult.

the class SuppleAtomContainerTest method testClone_IAtom2.

@Test
public void testClone_IAtom2() throws Exception {
    IAtomContainer molecule = new SuppleAtomContainer();
    IAtom carbon = MoleculeTools.newAtom(builder, "C");
    carbon.setPoint2d(new Point2d(2, 4));
    // 1
    molecule.addAtom(carbon);
    // test cloning of Atoms
    IAtomContainer clonedMol = (IAtomContainer) molecule.clone();
    carbon.setPoint2d(new Point2d(3, 1));
    Assert.assertEquals(clonedMol.getAtom(0).getPoint2d().x, 2.0, 0.001);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Point2d(javax.vecmath.Point2d) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Aggregations

SuppleAtomContainer (ambit2.core.groups.SuppleAtomContainer)104 Test (org.junit.Test)100 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)87 IAtom (org.openscience.cdk.interfaces.IAtom)81 IBond (org.openscience.cdk.interfaces.IBond)50 ILonePair (org.openscience.cdk.interfaces.ILonePair)21 IChemObject (org.openscience.cdk.interfaces.IChemObject)16 ISGroup (ambit2.core.groups.ISGroup)14 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)11 ComponentGroup (ambit2.core.groups.ComponentGroup)3 ContainerGroup (ambit2.core.groups.ContainerGroup)3 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)2 DataGroup (ambit2.core.groups.DataGroup)1 MonomerGroup (ambit2.core.groups.MonomerGroup)1 MultipleGroup (ambit2.core.groups.MultipleGroup)1 StructureRepeatingUnit (ambit2.core.groups.StructureRepeatingUnit)1 AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)1 MoleculeReader (ambit2.core.processors.structure.MoleculeReader)1 SmartsToChemObject (ambit2.smarts.SmartsToChemObject)1