Search in sources :

Example 1 with ChemModel

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

the class ChemModelManipulatorTest method testCreateNewMolecule_IChemModel.

@Test
public void testCreateNewMolecule_IChemModel() {
    IChemModel model = new ChemModel();
    IAtomContainer ac = ChemModelManipulator.createNewMolecule(model);
    Assert.assertEquals(1, model.getMoleculeSet().getAtomContainerCount());
    Assert.assertEquals(ac, model.getMoleculeSet().getAtomContainer(0));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) Test(org.junit.Test)

Example 2 with ChemModel

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

the class ChemModelManipulatorTest method testGetAllAtomContainers_IChemModel.

@Test
public void testGetAllAtomContainers_IChemModel() throws Exception {
    String filename = "a-pinene.mol";
    logger.info("Testing: " + filename);
    InputStream ins = this.getClass().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins);
    ChemModel chemFile = (ChemModel) reader.read((ChemObject) new ChemModel());
    Assert.assertNotNull(chemFile);
    List<IAtomContainer> containersList = ChemModelManipulator.getAllAtomContainers(chemFile);
    Assert.assertEquals(1, containersList.size());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) ChemObject(org.openscience.cdk.ChemObject) IChemObject(org.openscience.cdk.interfaces.IChemObject) InputStream(java.io.InputStream) MDLV2000Reader(org.openscience.cdk.io.MDLV2000Reader) Test(org.junit.Test)

Example 3 with ChemModel

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

use of org.openscience.cdk.ChemModel 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)

Example 5 with ChemModel

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

the class ChemSequenceManipulatorTest method setUp.

@Before
public void setUp() {
    molecule1 = new AtomContainer();
    atomInMol1 = new Atom("Cl");
    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);
    chemModel1 = new ChemModel();
    chemModel1.setMoleculeSet(moleculeSet);
    chemModel2 = new ChemModel();
    chemModel2.setReactionSet(reactionSet);
    chemSequence = new ChemSequence();
    chemSequence.addChemModel(chemModel1);
    chemSequence.addChemModel(chemModel2);
}
Also used : ChemSequence(org.openscience.cdk.ChemSequence) IChemSequence(org.openscience.cdk.interfaces.IChemSequence) 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)

Aggregations

ChemModel (org.openscience.cdk.ChemModel)16 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)12 IChemModel (org.openscience.cdk.interfaces.IChemModel)12 AtomContainer (org.openscience.cdk.AtomContainer)10 Test (org.junit.Test)9 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)9 Reaction (org.openscience.cdk.Reaction)8 InputStream (java.io.InputStream)6 IReaction (org.openscience.cdk.interfaces.IReaction)6 Atom (org.openscience.cdk.Atom)5 Bond (org.openscience.cdk.Bond)5 ChemFile (org.openscience.cdk.ChemFile)5 ReactionSet (org.openscience.cdk.ReactionSet)5 IAtom (org.openscience.cdk.interfaces.IAtom)5 IBond (org.openscience.cdk.interfaces.IBond)5 IChemObject (org.openscience.cdk.interfaces.IChemObject)5 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)5 AtomContainerSet (org.openscience.cdk.AtomContainerSet)4 Before (org.junit.Before)3 ChemObject (org.openscience.cdk.ChemObject)3