/** * {@inheritDoc} */ @Override public void setImplicitHydrogenCount(Integer hydrogenCount) { atom.setImplicitHydrogenCount(hydrogenCount); }
static IAtom atom(String symbol, int hCount) { IAtom atom = new Atom(symbol); atom.setImplicitHydrogenCount(hCount); return atom; } }
static IAtom atom(String symbol, int hCount) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(hCount); return a; } }
private void convertCMLToCDKHydrogenCounts() { for (IAtom atom : currentMolecule.atoms()) { if (atom.getImplicitHydrogenCount() != null) { int explicitHCount = AtomContainerManipulator.countExplicitHydrogens(currentMolecule, atom); if (explicitHCount != 0) { atom.setImplicitHydrogenCount(atom.getImplicitHydrogenCount() - explicitHCount); } } } }
private void convertCMLToCDKHydrogenCounts() { for (IAtom atom : currentMolecule.atoms()) { if (atom.getImplicitHydrogenCount() != null) { int explicitHCount = AtomContainerManipulator.countExplicitHydrogens(currentMolecule, atom); if (explicitHCount != 0) { atom.setImplicitHydrogenCount(atom.getImplicitHydrogenCount() - explicitHCount); } } } }
static IAtom atom(String symbol, int h, boolean arom) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(h); a.setFlag(CDKConstants.ISAROMATIC, arom); return a; }
static IAtom atom(String symbol, int hCount, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(hCount); a.setPoint2d(new Point2d(x, y)); return a; } }
static IAtom atom(String symbol, int hCount, double x, double y) { IAtom a = new Atom(symbol); a.setImplicitHydrogenCount(hCount); a.setPoint2d(new Point2d(x, y)); return a; }
@Test public void outputValencyWhenNeeded() throws IOException, CDKException { IAtomContainer mol = new AtomContainer(); mol.addAtom(new Atom("Na")); mol.addAtom(new Atom("Na")); mol.getAtom(0).setImplicitHydrogenCount(0); // Na metal mol.getAtom(1).setImplicitHydrogenCount(1); // Na hydride String res = writeToStr(mol); assertThat(res, CoreMatchers.containsString("M V30 1 Na 0 0 0 0 VAL=-1\n")); assertThat(res, CoreMatchers.containsString("M V30 2 Na 0 0 0 0\n")); }
@Test public void unknownSymbol_Pseudo() throws Exception { IAtom a = new PseudoAtom("R1"); a.setImplicitHydrogenCount(0); assertThat(new CDKToBeam().toBeamAtom(a).element(), is(Element.Unknown)); }
@Test public void chargedAtom() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); for (int chg = -10; chg < 10; chg++) { a.setFormalCharge(chg); assertThat(new CDKToBeam().toBeamAtom(a).charge(), is(chg)); } }
@Test public void unknownAtomTypeLeavesHydrogenCountAlone() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); CDKHydrogenAdder hydrogenAdder = CDKHydrogenAdder.getInstance(bldr); IAtomContainer container = bldr.newInstance(IAtomContainer.class); IAtom atom = bldr.newInstance(IAtom.class, "C"); atom.setImplicitHydrogenCount(3); atom.setAtomTypeName("X"); container.addAtom(atom); hydrogenAdder.addImplicitHydrogens(container); assertThat(atom.getImplicitHydrogenCount(), is(3)); }
@Test public void ethaneNonTerminal() { IAtom a1 = new Atom("C"); IAtom a2 = new Atom("C"); a1.setPoint2d(new Point2d(0, 0)); a2.setPoint2d(new Point2d(0.5, -0.5)); IBond bond1 = new Bond(a1, a2); a1.setImplicitHydrogenCount(3); a2.setImplicitHydrogenCount(3); assertTrue(SymbolVisibility.iupacRecommendationsWithoutTerminalCarbon() .visible(a1, Collections.singletonList(bond1), new RendererModel())); }
private static void configureAtoms(IAtomContainer mol) { try { for (IAtom atom : mol.atoms()) atom.setImplicitHydrogenCount(null); Isotopes.getInstance().configureAtoms(mol); } catch (Exception exc) { logger.error("Could not configure molecule!"); logger.debug(exc); } }
@Test public void iupacMethylAcceptable() { IAtom a1 = new Atom("C"); IAtom a2 = new Atom("C"); a1.setImplicitHydrogenCount(null); a2.setImplicitHydrogenCount(null); IBond bond = new Bond(a1, a2); a1.setPoint2d(new Point2d(0, 0)); a2.setPoint2d(new Point2d(0, 0)); assertFalse(SymbolVisibility.iupacRecommendationsWithoutTerminalCarbon().visible(a1, Arrays.asList(bond), new RendererModel())); }
@Test public void testGetMaxBondOrderImplH() { IAtomContainer container = (IAtomContainer) newChemObject(); IChemObjectBuilder builder = container.getBuilder(); IAtom a = builder.newAtom(); a.setImplicitHydrogenCount(1); container.addAtom(a); assertThat(container.getMaximumBondOrder(a), is(IBond.Order.SINGLE)); }
@Test public void methane_Atom() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(4); assertThat(new CDKToBeam().toBeamAtom(a).element(), is(Element.Carbon)); assertThat(new CDKToBeam().toBeamAtom(a).hydrogens(), is(4)); }
@Test public void aliphaticAtom() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); assertFalse(new CDKToBeam().toBeamAtom(a).aromatic()); }
/** * Because we are setting an options, we get a non-standard InChI. */ @Test(expected = IllegalArgumentException.class) public void testGetInChIGenerator_IAtomContainer_NullList() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("Cl"); a.setImplicitHydrogenCount(1); ac.addAtom(a); InChIGeneratorFactory.getInstance().getInChIGenerator(ac, (List<INCHI_OPTION>) null); }
@Test public void aromaticAtom() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); a.setFlag(CDKConstants.ISAROMATIC, true); assertTrue(new CDKToBeam().toBeamAtom(a).aromatic()); }