/** * Create a new CDK {@link IAtom} from the Beam Atom. * * @param beamAtom an Atom from the Beam ChemicalGraph * @param hCount hydrogen count for the atom * @return the CDK atom to have it's properties set */ IAtom toCDKAtom(Atom beamAtom, int hCount) { IAtom cdkAtom = newCDKAtom(beamAtom); cdkAtom.setImplicitHydrogenCount(hCount); cdkAtom.setFormalCharge(beamAtom.charge()); if (beamAtom.isotope() >= 0) cdkAtom.setMassNumber(beamAtom.isotope()); if (beamAtom.aromatic()) cdkAtom.setIsAromatic(true); if (beamAtom.atomClass() > 0) cdkAtom.setProperty(ATOM_ATOM_MAPPING, beamAtom.atomClass()); return cdkAtom; }
@Test public void unspecifiedIsotope() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); assertThat(new CDKToBeam().toBeamAtom(a).isotope(), is(-1)); }
@Test public void noDefaultIsotope() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); a.setMassNumber(12); assertThat(new CDKToBeam().toBeamAtom(a).isotope(), is(12)); }
@Test public void specifiedIsotope() throws Exception { IAtom a = new Atom("C"); a.setImplicitHydrogenCount(0); a.setMassNumber(13); assertThat(new CDKToBeam().toBeamAtom(a).isotope(), is(13)); }
@Test public void C13_nonIsomeric() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("C"); a.setMassNumber(13); ac.addAtom(a); Graph g = convert(ac, false, 0); // non-isomeric assertThat(g.atom(0).isotope(), is(-1)); assertThat(g.toSmiles(), is("C")); }
@Test public void C13_isomeric() throws Exception { IAtomContainer ac = new AtomContainer(); IAtom a = new Atom("C"); a.setMassNumber(13); ac.addAtom(a); Graph g = convert(ac, SmiFlavor.AtomicMass); assertThat(g.atom(0).isotope(), is(13)); assertThat(g.toSmiles(), is("[13CH4]")); }
static Atom toSubset(Atom a, Graph g, int u) { // atom is already a subset atom if (a.subset()) return a; // element is not organic and thus cannot be part of the subset if (!a.element().organic()) return a; // if any of these values are set the atom cannot be a subset atom if (a.charge() != 0 || a.atomClass() != 0 || a.isotope() >= 0) return a; Atom subset = a.aromatic() ? AtomImpl.AromaticSubset.ofElement(a.element()) : AtomImpl.AliphaticSubset.ofElement(a.element()); // does the implied availableElectrons from the bond order sum match that // which was stored - if aromatic we only check the lowest valence state int impliedHCount = subset.hydrogens(g, u); // mismatch in number of hydrogens we must write this as a bracket atom return impliedHCount != a.hydrogens() ? a : subset; } }