use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class SDFWriterTest method testWrite_IAtomContainerSet_Properties.
@Test
public void testWrite_IAtomContainerSet_Properties() throws Exception {
StringWriter writer = new StringWriter();
IAtomContainerSet molSet = new AtomContainerSet();
IAtomContainer molecule = new AtomContainer();
molecule.addAtom(new Atom("C"));
molecule.setProperty("foo", "bar");
molSet.addAtomContainer(molecule);
SDFWriter sdfWriter = new SDFWriter(writer);
sdfWriter.write(molSet);
sdfWriter.close();
Assert.assertTrue(writer.toString().contains("<foo>"));
Assert.assertTrue(writer.toString().contains("bar"));
}
use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class SDFWriterTest method testWrite_IAtomContainerSet_MultIAtomContainer.
@Test
public void testWrite_IAtomContainerSet_MultIAtomContainer() throws Exception {
StringWriter writer = new StringWriter();
IAtomContainerSet molSet = new AtomContainerSet();
IAtomContainer molecule = new AtomContainer();
molecule.addAtom(new Atom("C"));
molSet.addAtomContainer(molecule);
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("$$$$"));
}
use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class MoleculeSetManipulatorTest 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");
MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, otherAtom);
Assert.assertEquals(1, MoleculeSetManipulator.getBondCount(ms));
Assert.assertEquals(2, MoleculeSetManipulator.getAtomCount(ms));
MoleculeSetManipulator.removeAtomAndConnectedElectronContainers(ms, atom);
Assert.assertEquals(0, MoleculeSetManipulator.getBondCount(ms));
Assert.assertEquals(1, MoleculeSetManipulator.getAtomCount(ms));
}
use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class ChemFileManipulatorTest 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 = new AtomContainerSet();
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);
chemSequence1 = new ChemSequence();
chemSequence1.addChemModel(chemModel);
chemSequence2 = new ChemSequence();
chemFile = new ChemFile();
chemFile.addChemSequence(chemSequence1);
chemFile.addChemSequence(chemSequence2);
}
use of org.openscience.cdk.AtomContainerSet in project cdk by cdk.
the class CMLRoundTripTest method testMoleculeSet.
@Test
public void testMoleculeSet() throws Exception {
IAtomContainerSet list = new AtomContainerSet();
list.addAtomContainer(new AtomContainer());
list.addAtomContainer(new AtomContainer());
IChemModel model = new ChemModel();
model.setMoleculeSet(list);
IChemModel roundTripped = CMLRoundTripTool.roundTripChemModel(convertor, model);
IAtomContainerSet newList = roundTripped.getMoleculeSet();
Assert.assertNotNull(newList);
Assert.assertEquals(2, newList.getAtomContainerCount());
Assert.assertNotNull(newList.getAtomContainer(0));
Assert.assertNotNull(newList.getAtomContainer(1));
}
Aggregations