Search in sources :

Example 21 with SuppleAtomContainer

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

the class SuppleAtomContainerTest method testAddSingleElectron_ISingleElectron.

@Test
public void testAddSingleElectron_ISingleElectron() {
    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);
    ISingleElectron single1 = MoleculeTools.newSingleElectron(builder, c);
    ISingleElectron single2 = MoleculeTools.newSingleElectron(builder, c);
    ISingleElectron single3 = MoleculeTools.newSingleElectron(builder, o);
    acetone.addSingleElectron(single1);
    acetone.addSingleElectron(single2);
    acetone.addSingleElectron(single3);
    Assert.assertEquals(single1, (ISingleElectron) acetone.getConnectedSingleElectronsList(c).get(0));
    Assert.assertEquals(single2, (ISingleElectron) acetone.getConnectedSingleElectronsList(c).get(1));
    Assert.assertEquals(single3, (ISingleElectron) acetone.getConnectedSingleElectronsList(o).get(0));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 22 with SuppleAtomContainer

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

the class SuppleAtomContainerTest method testContains_IBond.

@Test
public void testContains_IBond() {
    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);
    IBond falseBond = MoleculeTools.newBond(builder);
    Assert.assertTrue(acetone.contains(b1));
    Assert.assertFalse(acetone.contains(falseBond));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 23 with SuppleAtomContainer

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

the class SuppleAtomContainerTest method testClone_IBond.

@Test
public void testClone_IBond() throws Exception {
    IAtomContainer molecule = new SuppleAtomContainer();
    // 1
    molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
    // 2
    molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
    // 3
    molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
    // 4
    molecule.addAtom(MoleculeTools.newAtom(builder, "C"));
    // 1
    molecule.addBond(0, 1, IBond.Order.DOUBLE);
    // 2
    molecule.addBond(1, 2, IBond.Order.SINGLE);
    // 3
    molecule.addBond(2, 3, IBond.Order.SINGLE);
    IAtomContainer clonedMol = (IAtomContainer) molecule.clone();
    Assert.assertNotNull(clonedMol);
    Assert.assertEquals(molecule.getBondCount(), clonedMol.getBondCount());
    for (int f = 0; f < molecule.getElectronContainerCount(); f++) {
        for (int g = 0; g < clonedMol.getElectronContainerCount(); g++) {
            Assert.assertNotNull(molecule.getBond(f));
            Assert.assertNotNull(clonedMol.getBond(g));
            Assert.assertNotSame(molecule.getBond(f), clonedMol.getBond(g));
        }
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) Test(org.junit.Test)

Example 24 with SuppleAtomContainer

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

the class SuppleAtomContainerTest method testGetMaximumBondOrder_IAtom.

@Test
public void testGetMaximumBondOrder_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);
    acetone.addLonePair(2);
    acetone.addLonePair(2);
    IBond b1 = MoleculeTools.newBond(builder, c1, c2, IBond.Order.SINGLE);
    IBond b2 = MoleculeTools.newBond(builder, c1, o, IBond.Order.DOUBLE);
    IBond b3 = MoleculeTools.newBond(builder, c1, c3, IBond.Order.SINGLE);
    acetone.addBond(b1);
    acetone.addBond(b2);
    acetone.addBond(b3);
    Assert.assertEquals(IBond.Order.DOUBLE, acetone.getMaximumBondOrder(o));
    Assert.assertEquals(IBond.Order.DOUBLE, acetone.getMaximumBondOrder(c1));
    Assert.assertEquals(IBond.Order.SINGLE, acetone.getMaximumBondOrder(c2));
    Assert.assertEquals(IBond.Order.SINGLE, acetone.getMaximumBondOrder(c3));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 25 with SuppleAtomContainer

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

the class SuppleAtomContainerTest method testRemoveAtomAndConnectedElectronContainers_IAtom.

@Test
public void testRemoveAtomAndConnectedElectronContainers_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);
    IBond b1 = MoleculeTools.newBond(builder, c1, c2, IBond.Order.SINGLE);
    IBond b2 = MoleculeTools.newBond(builder, c1, o, IBond.Order.DOUBLE);
    IBond b3 = MoleculeTools.newBond(builder, c1, c3, IBond.Order.SINGLE);
    acetone.addBond(b1);
    acetone.addBond(b2);
    acetone.addBond(b3);
    // add lone pairs on oxygen
    ILonePair lp1 = MoleculeTools.newLonePair(builder, o);
    ILonePair lp2 = MoleculeTools.newLonePair(builder, o);
    acetone.addLonePair(lp1);
    acetone.addLonePair(lp2);
    // remove the oxygen
    acetone.removeAtomAndConnectedElectronContainers(o);
    Assert.assertEquals(3, acetone.getAtomCount());
    Assert.assertEquals(2, acetone.getBondCount());
    Assert.assertEquals(0, acetone.getLonePairCount());
}
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

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