Search in sources :

Example 21 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class AtomContainerSetManipulatorTest method testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom.

@Test
public void testRemoveAtomAndConnectedElectronContainers_IAtomContainerSet_IAtom() {
    IAtomContainerSet ms = new AtomContainerSet();
    IAtomContainer mol = new AtomContainer();
    mol.addAtom(new Atom("O"));
    mol.addAtom(new Atom("O"));
    mol.addBond(0, 1, IBond.Order.DOUBLE);
    IAtom atom = mol.getAtom(0);
    ms.addAtomContainer(mol);
    IAtom otherAtom = new Atom("O");
    AtomContainerSetManipulator.removeAtomAndConnectedElectronContainers(ms, otherAtom);
    Assert.assertEquals(1, AtomContainerSetManipulator.getBondCount(ms));
    Assert.assertEquals(2, AtomContainerSetManipulator.getAtomCount(ms));
    AtomContainerSetManipulator.removeAtomAndConnectedElectronContainers(ms, atom);
    Assert.assertEquals(0, AtomContainerSetManipulator.getBondCount(ms));
    Assert.assertEquals(1, AtomContainerSetManipulator.getAtomCount(ms));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) AtomContainerSet(org.openscience.cdk.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 22 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class AtomContainerSetManipulatorTest method testRemoveElectronContainer_IAtomContainerSet_IElectronContainer.

@Test
public void testRemoveElectronContainer_IAtomContainerSet_IElectronContainer() {
    IAtomContainerSet ms = new AtomContainerSet();
    IAtomContainer mol = new AtomContainer();
    mol.addAtom(new Atom("O"));
    mol.addAtom(new Atom("O"));
    mol.addBond(0, 1, IBond.Order.DOUBLE);
    IBond bond = mol.getBond(0);
    ms.addAtomContainer(mol);
    IBond otherBond = new Bond(new Atom(), new Atom());
    AtomContainerSetManipulator.removeElectronContainer(ms, otherBond);
    Assert.assertEquals(1, AtomContainerSetManipulator.getBondCount(ms));
    AtomContainerSetManipulator.removeElectronContainer(ms, bond);
    Assert.assertEquals(0, AtomContainerSetManipulator.getBondCount(ms));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IBond(org.openscience.cdk.interfaces.IBond) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) AtomContainerSet(org.openscience.cdk.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 23 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class ChemModelManipulatorTest method setUp.

@Before
public void setUp() {
    molecule1 = new AtomContainer();
    atomInMol1 = new Atom("Cl");
    atomInMol1.setCharge(-1.0);
    atomInMol1.setFormalCharge(-1);
    atomInMol1.setImplicitHydrogenCount(1);
    molecule1.addAtom(atomInMol1);
    molecule1.addAtom(new Atom("Cl"));
    bondInMol1 = new Bond(atomInMol1, molecule1.getAtom(1));
    molecule1.addBond(bondInMol1);
    molecule2 = new AtomContainer();
    atomInMol2 = new Atom("O");
    atomInMol2.setImplicitHydrogenCount(2);
    molecule2.addAtom(atomInMol2);
    moleculeSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
    moleculeSet.addAtomContainer(molecule1);
    moleculeSet.addAtomContainer(molecule2);
    reaction = new Reaction();
    reaction.addReactant(molecule1);
    reaction.addProduct(molecule2);
    reactionSet = new ReactionSet();
    reactionSet.addReaction(reaction);
    chemModel = new ChemModel();
    chemModel.setMoleculeSet(moleculeSet);
    chemModel.setReactionSet(reactionSet);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) ReactionSet(org.openscience.cdk.ReactionSet) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) Reaction(org.openscience.cdk.Reaction) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Before(org.junit.Before)

Example 24 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class ChemModelManipulatorTest method testNewChemModel_IAtomContainer.

@Test
public void testNewChemModel_IAtomContainer() {
    IAtomContainer ac = new AtomContainer();
    ac.addAtom(new Atom("C"));
    IChemModel model = ChemModelManipulator.newChemModel(ac);
    IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0);
    Assert.assertNotNull(mol);
    Assert.assertEquals(ac.getAtomCount(), mol.getAtomCount());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Test(org.junit.Test)

Example 25 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class ChemModelManipulatorTest method testRemoveElectronContainer_IChemModel_IElectronContainer.

@Test
public void testRemoveElectronContainer_IChemModel_IElectronContainer() {
    IAtomContainer mol1 = new AtomContainer();
    mol1.addAtom(new Atom("Cl"));
    mol1.addAtom(new Atom("Cl"));
    IBond bond1 = new Bond(mol1.getAtom(0), mol1.getAtom(1));
    mol1.addBond(bond1);
    IAtomContainer mol2 = new AtomContainer();
    mol2.addAtom(new Atom("I"));
    mol2.addAtom(new Atom("I"));
    IBond bond2 = new Bond(mol2.getAtom(0), mol2.getAtom(1));
    mol2.addBond(bond2);
    IAtomContainerSet molSet = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainerSet.class);
    molSet.addAtomContainer(mol1);
    IReaction r = new Reaction();
    r.addProduct(mol2);
    IReactionSet rSet = new ReactionSet();
    rSet.addReaction(r);
    IChemModel model = new ChemModel();
    model.setMoleculeSet(molSet);
    model.setReactionSet(rSet);
    IBond otherBond = new Bond();
    Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
    ChemModelManipulator.removeElectronContainer(model, otherBond);
    Assert.assertEquals(2, ChemModelManipulator.getBondCount(model));
    ChemModelManipulator.removeElectronContainer(model, bond1);
    Assert.assertEquals(1, ChemModelManipulator.getBondCount(model));
    ChemModelManipulator.removeElectronContainer(model, bond2);
    Assert.assertEquals(0, ChemModelManipulator.getBondCount(model));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) ReactionSet(org.openscience.cdk.ReactionSet) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IBond(org.openscience.cdk.interfaces.IBond) IChemModel(org.openscience.cdk.interfaces.IChemModel) IReaction(org.openscience.cdk.interfaces.IReaction) Bond(org.openscience.cdk.Bond) IBond(org.openscience.cdk.interfaces.IBond) Reaction(org.openscience.cdk.Reaction) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) Test(org.junit.Test)

Aggregations

AtomContainer (org.openscience.cdk.AtomContainer)743 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)730 Test (org.junit.Test)641 IAtom (org.openscience.cdk.interfaces.IAtom)556 Atom (org.openscience.cdk.Atom)523 PseudoAtom (org.openscience.cdk.PseudoAtom)206 IBond (org.openscience.cdk.interfaces.IBond)136 Bond (org.openscience.cdk.Bond)90 Point2d (javax.vecmath.Point2d)86 InputStream (java.io.InputStream)80 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)61 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)57 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)44 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)43 ByteArrayInputStream (java.io.ByteArrayInputStream)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)32 SlowTest (org.openscience.cdk.test.SlowTest)32 Point3d (javax.vecmath.Point3d)30 IPseudoAtom (org.openscience.cdk.interfaces.IPseudoAtom)29 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)23