@Override public IChemObject newTestObject() { return new AtomContainer(); } });
/** * When atomic mass is defined as a delta some atoms don't have a reasonable * default. Most tools will output an 'M ISO' property, so can be specified * @throws Exception expected format error */ @Test(expected = CDKException.class) public void seaborgiumMassDelta() throws Exception { try (InputStream in = getClass().getResourceAsStream("seaborgium.mol"); MDLV2000Reader mdlr = new MDLV2000Reader(in, Mode.STRICT)) { IAtomContainer mol = mdlr.read(new AtomContainer()); } }
public void ignoreCalculate_IAtomContainer() throws Exception { String filename = "data/mdl/clorobenzene.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IAtomContainer container = reader.read(new AtomContainer()); DescriptorValue count = descriptor.calculate(container); System.out.println(count.getValue()); Assert.fail("Not validated yet"); }
/** * @cdk.bug 2784209 */ @Test public void testNoAtomsIsConnected() { IAtomContainer container = new AtomContainer(); Assert.assertTrue("Molecule appears not to be connected", ConnectivityChecker.isConnected(container)); }
@Test public void testChargedCompounds() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom aluminum = new Atom("Al"); aluminum.setFormalCharge(+3); mol.addAtom(aluminum); StringWriter strWriter = new StringWriter(); Mopac7Writer writer = new Mopac7Writer(strWriter); writer.write(mol); writer.close(); Assert.assertTrue(strWriter.toString().contains("CHARGE=3")); }
@Test public void carbon_cation() { IAtomContainer container = new AtomContainer(); IAtom atom = new Atom("C"); atom.setFormalCharge(-1); container.addAtom(atom); MDLValence.apply(container); assertThat(atom.getValency(), is(3)); assertThat(atom.getImplicitHydrogenCount(), is(3)); }
@Test public void testChlorRadical() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("Cl"); mol.addAtom(atom); mol.addSingleElectron(0); String[] expectedTypes = {"Cl.radical"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
/** * @cdk.bug 780545 */ @Test(timeout = 5000) public void testBug780545() throws Exception { IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("C")); IAtomContainer ac = layout(mol); assertTrue(GeometryUtil.has2DCoordinates(ac)); }
@Test public void testZinc() throws Exception { IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("Zn")); mol.getAtom(0).setFormalCharge(+2); String[] expectedTypes = {"Zn.2plus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testMethylAmine() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("N"); IAtom atom2 = new Atom("C"); mol.addAtom(atom); mol.addAtom(atom2); mol.addBond(0, 1, Order.SINGLE); String[] expectedTypes = {"N.3", "C.3"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testMethanol() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("O"); IAtom atom2 = new Atom("C"); mol.addAtom(atom); mol.addAtom(atom2); mol.addBond(0, 1, Order.SINGLE); String[] expectedTypes = {"O.3", "C.3"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testEthyneRadical() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("C"); IAtom atom2 = new Atom("C"); mol.addAtom(atom); mol.addAtom(atom2); mol.addSingleElectron(1); mol.addBond(0, 1, Order.TRIPLE); String[] expectedTypes = {"C.sp", "C.radical.sp1"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testMethanolRadical() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("C"); IAtom atom2 = new Atom("O"); mol.addAtom(atom); mol.addAtom(atom2); mol.addSingleElectron(1); mol.addBond(0, 1, IBond.Order.SINGLE); String[] expectedTypes = {"C.sp3", "O.sp3.radical"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testGetWarningMessage() throws Exception { IAtomContainer ac = new AtomContainer(); ac.addAtom(new Atom("Cl")); ac.addAtom(new Atom("H")); ac.addBond(0, 1, Order.TRIPLE); InChIGenerator gen = getFactory().getInChIGenerator(ac); Assert.assertNotNull(gen.getMessage()); Assert.assertTrue(gen.getMessage().contains("Accepted unusual valence")); }
private IAtomContainer singleBondMolecule() { IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("C", new Point3d(0.0, 0.0, 0.0))); mol.addAtom(new Atom("O", new Point3d(1.0, 1.0, 1.0))); mol.addBond(0, 1, IBond.Order.SINGLE); return mol; }
@Test public void testMolecule_int_int_int_int() { IAtomContainer m = new AtomContainer(5, 5, 1, 1); Assert.assertNotNull(m); Assert.assertEquals(0, m.getAtomCount()); Assert.assertEquals(0, m.getBondCount()); Assert.assertEquals(0, m.getLonePairCount()); Assert.assertEquals(0, m.getSingleElectronCount()); }
@Test public void testAtom() throws Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("N"); mol.addAtom(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol); Assert.assertEquals(1, roundTrippedMol.getAtomCount()); IAtom roundTrippedAtom = roundTrippedMol.getAtom(0); Assert.assertEquals(atom.getSymbol(), roundTrippedAtom.getSymbol()); }
@Ignore("Have to figure out how to store partial charges in CML2") public void testAtomPartialCharge() throws Exception { IAtomContainer mol = new AtomContainer(); Atom atom = new Atom("N"); double partialCharge = 0.5; atom.setCharge(partialCharge); mol.addAtom(atom); IAtomContainer roundTrippedMol = CMLRoundTripTool.roundTripMolecule(convertor, mol); Assert.assertEquals(1, roundTrippedMol.getAtomCount()); IAtom roundTrippedAtom = roundTrippedMol.getAtom(0); Assert.assertEquals(atom.getCharge(), roundTrippedAtom.getCharge(), 0.0001); }
@Test public void testGetClosestAtom_Double_Double_IAtomContainer_IAtom() { IAtom atom1 = new Atom("C"); atom1.setPoint2d(new Point2d(1, 0)); IAtom atom2 = new Atom("C"); atom2.setPoint2d(new Point2d(5, 0)); IAtomContainer acont = new AtomContainer(); acont.addAtom(atom1); acont.addAtom(atom2); Assert.assertEquals(atom2, GeometryUtil.getClosestAtom(1.0, 0.0, acont, atom1)); Assert.assertEquals(atom1, GeometryUtil.getClosestAtom(1.0, 0.0, acont, null)); }
@Test public void testAtomContainer_int_int_int_int() { // create an empty container with predefined // array lengths IAtomContainer ac = new AtomContainer(5, 6, 1, 2); Assert.assertEquals(0, ac.getAtomCount()); Assert.assertEquals(0, ac.getElectronContainerCount()); // test whether the ElectronContainer is correctly initialized ac.addBond(ac.getBuilder().newInstance(IBond.class, ac.getBuilder().newInstance(IAtom.class, "C"), ac.getBuilder().newInstance(IAtom.class, "C"), IBond.Order.DOUBLE)); ac.addLonePair(ac.getBuilder().newInstance(ILonePair.class, ac.getBuilder().newInstance(IAtom.class, "N"))); }