Search in sources :

Example 6 with AtomContainerSet

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

the class MoleculeSetManipulatorTest 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());
    MoleculeSetManipulator.removeElectronContainer(ms, otherBond);
    Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms));
    MoleculeSetManipulator.removeElectronContainer(ms, bond);
    Assert.assertEquals(0, MoleculeSetManipulator.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 7 with AtomContainerSet

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

the class SDFWriterTest method testWrite_IAtomContainerSet_SingleMolecule.

@Test
public void testWrite_IAtomContainerSet_SingleMolecule() throws Exception {
    StringWriter writer = new StringWriter();
    IAtomContainerSet molSet = new AtomContainerSet();
    IAtomContainer molecule = new AtomContainer();
    molecule.addAtom(new Atom("C"));
    molSet.addAtomContainer(molecule);
    SDFWriter sdfWriter = new SDFWriter(writer);
    sdfWriter.write(molSet);
    sdfWriter.close();
    Assert.assertTrue(writer.toString().contains("$$$$"));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) StringWriter(java.io.StringWriter) 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) IAtom(org.openscience.cdk.interfaces.IAtom) Atom(org.openscience.cdk.Atom) ChemObjectWriterTest(org.openscience.cdk.test.io.ChemObjectWriterTest) Test(org.junit.Test)

Example 8 with AtomContainerSet

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

the class CMLRoundTripTest method testChemModel.

/**
 * @cdk.bug 1455346
 */
@Test
public void testChemModel() throws Exception {
    ChemModel model = new ChemModel();
    IAtomContainerSet moleculeSet = new AtomContainerSet();
    IAtomContainer mol = new AtomContainer();
    PseudoAtom atom = new PseudoAtom("N");
    mol.addAtom(atom);
    moleculeSet.addAtomContainer(mol);
    model.setMoleculeSet(moleculeSet);
    IChemModel roundTrippedModel = CMLRoundTripTool.roundTripChemModel(convertor, model);
    IAtomContainerSet roundTrippedMolSet = roundTrippedModel.getMoleculeSet();
    Assert.assertNotNull(roundTrippedMolSet);
    Assert.assertEquals(1, roundTrippedMolSet.getAtomContainerCount());
    IAtomContainer roundTrippedMolecule = roundTrippedMolSet.getAtomContainer(0);
    Assert.assertNotNull(roundTrippedMolecule);
    Assert.assertEquals(1, roundTrippedMolecule.getAtomCount());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ChemModel(org.openscience.cdk.ChemModel) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IChemModel(org.openscience.cdk.interfaces.IChemModel) AtomContainerSet(org.openscience.cdk.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IPseudoAtom(org.openscience.cdk.interfaces.IPseudoAtom) PseudoAtom(org.openscience.cdk.PseudoAtom) Test(org.junit.Test)

Example 9 with AtomContainerSet

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

the class INChIHandler method startDocument.

@Override
public void startDocument() {
    chemFile = new ChemFile();
    chemSequence = new ChemSequence();
    chemModel = new ChemModel();
    setOfMolecules = new AtomContainerSet();
}
Also used : ChemSequence(org.openscience.cdk.ChemSequence) ChemModel(org.openscience.cdk.ChemModel) ChemFile(org.openscience.cdk.ChemFile) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) AtomContainerSet(org.openscience.cdk.AtomContainerSet)

Example 10 with AtomContainerSet

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

the class SMILESReaderTest method testReadingSmiFile_3.

@Test
public void testReadingSmiFile_3() throws Exception {
    String filename = "test3.smi";
    logger.info("Testing: " + filename);
    InputStream ins = this.getClass().getResourceAsStream(filename);
    SMILESReader reader = new SMILESReader(ins);
    IAtomContainerSet som = reader.read(new AtomContainerSet());
    Assert.assertEquals(5, som.getAtomContainerCount());
}
Also used : InputStream(java.io.InputStream) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IteratingSMILESReader(org.openscience.cdk.io.iterator.IteratingSMILESReader) AtomContainerSet(org.openscience.cdk.AtomContainerSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) SimpleChemObjectReaderTest(org.openscience.cdk.test.io.SimpleChemObjectReaderTest) Test(org.junit.Test)

Aggregations

AtomContainerSet (org.openscience.cdk.AtomContainerSet)30 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)30 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)26 Test (org.junit.Test)18 AtomContainer (org.openscience.cdk.AtomContainer)16 IAtom (org.openscience.cdk.interfaces.IAtom)12 Atom (org.openscience.cdk.Atom)11 InputStream (java.io.InputStream)6 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)6 StringWriter (java.io.StringWriter)5 ChemObjectWriterTest (org.openscience.cdk.test.io.ChemObjectWriterTest)5 BufferedReader (java.io.BufferedReader)4 FileReader (java.io.FileReader)4 ArrayList (java.util.ArrayList)4 ChemModel (org.openscience.cdk.ChemModel)4 CDKException (org.openscience.cdk.exception.CDKException)4 SDFWriter (org.openscience.cdk.io.SDFWriter)4 IteratingSMILESReader (org.openscience.cdk.io.iterator.IteratingSMILESReader)4 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3