/** * {@inheritDoc} */ @Override public void setFormalCharge(Integer charge) { atom.setFormalCharge(charge); }
@Test public void multipleCharges() throws Exception { IAtomContainer mock = mock(6); read("M CHG 2 2 1 5 -2", mock); verify(mock.getAtom(1)).setFormalCharge(+1); verify(mock.getAtom(4)).setFormalCharge(-2); }
@Test public void cation() throws Exception { IAtomContainer mock = mock(3); read("M CHG 1 1 1", mock); verify(mock.getAtom(0)).setFormalCharge(+1); }
@Test public void multipleChargesTruncated() throws Exception { IAtomContainer mock = mock(6); read("M CHG 2 2 -3", mock); verify(mock.getAtom(1)).setFormalCharge(-3); }
@Test public void testHydride() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("H"); atom.setFormalCharge(-1); mol.addAtom(atom); String[] expectedTypes = new String[]{"H.minus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test @Override public void showCarbon_FormalChargeTest() { IAtomContainer atomContainer = super.makeCCC(); IAtom carbon = atomContainer.getAtom(1); carbon.setFormalCharge(1); Assert.assertTrue(generator.showCarbon(carbon, atomContainer, model)); }
@Test public void test_S_2minus() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "S"); a1.setFormalCharge(-2); mol.addAtom(a1); String[] expectedTypes = {"S.2minus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Pb_2plus() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Pb"); a1.setFormalCharge(2); mol.addAtom(a1); String[] expectedTypes = {"Pb.2plus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Tl_neutral() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Tl"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Tl"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Cr_neutral() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Cr"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Cr.neutral"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Cr_3plus() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Cr"); a1.setFormalCharge(3); mol.addAtom(a1); String[] expectedTypes = {"Cr.3plus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Cr_6plus() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Cr"); a1.setFormalCharge(6); mol.addAtom(a1); String[] expectedTypes = {"Cr.6plus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Th() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Th"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Th"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Na_neutral() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Na"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Na.neutral"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Mn_metallic() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Mn"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Mn.metallic"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Ra() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Ra"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Ra.neutral"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void test_Rb_neutral() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Rb"); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Rb.neutral"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testIAtomType_FormalCharge() throws Exception { IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom atom = builder.newInstance(IAtom.class, "C"); atom.setID("a1"); atom.setFormalCharge(+1); mol.addAtom(atom); IAtomContainer copy = CMLRoundTripTool.roundTripMolecule(convertor, mol); String difference = AtomDiff.diff(atom, copy.getAtom(0)); Assert.assertEquals("Found non-zero diff: " + difference, 0, difference.length()); }
@Test public void test_Se_2() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newInstance(IAtomContainer.class); IAtom a1 = builder.newInstance(IAtom.class, "Se"); a1.setImplicitHydrogenCount(0); a1.setFormalCharge(0); mol.addAtom(a1); String[] expectedTypes = {"Se.2"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }
@Test public void testMethyleneBromKation() throws Exception { IAtomContainer mol = new AtomContainer(); IAtom atom = new Atom("C"); IAtom atom2 = new Atom("Br"); mol.addAtom(atom); mol.addAtom(atom2); atom2.setFormalCharge(+1); mol.addBond(0, 1, Order.DOUBLE); String[] expectedTypes = {"C.sp2", "Br.plus.sp2"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); }