private void setSymbolInternal(String symbol) { if (symbol == null) this.atomicNumber = null; else this.atomicNumber = Elements.ofString(symbol).number(); }
private void setSymbolInternal(String symbol) { if (symbol == null) this.atomicNumber = null; else this.atomicNumber = Elements.ofString(symbol).number(); }
/** * Get the atomic number of the element. * * @param symbol the symbol of the element * @return the atomic number */ public static Integer getAtomicNumber(String symbol) { return Elements.ofString(symbol).number(); }
/** * Get the atomic number of the element. * * @param symbol the symbol of the element * @return the atomic number */ public static Integer getAtomicNumber(String symbol) { return Elements.ofString(symbol).number(); }
private void setSymbolInternal(String symbol) { if (symbol == null) this.atomicNumber = null; else this.atomicNumber = Elements.ofString(symbol).number(); }
private void setSymbolInternal(String symbol) { if (symbol == null) this.atomicNumber = null; else this.atomicNumber = Elements.ofString(symbol).number(); }
/** * Gets an array of all isotopes known to the IsotopeFactory for the given * element symbol. * *@param symbol An element symbol to search for *@return An array of isotopes that matches the given element symbol */ public IIsotope[] getIsotopes(String symbol) { final int elem = Elements.ofString(symbol).number(); if (isotopes[elem] == null) return EMPTY_ISOTOPE_ARRAY; List<IIsotope> list = new ArrayList<IIsotope>(); for (IIsotope isotope : isotopes[elem]) { list.add(clone(isotope)); } return list.toArray(new IIsotope[list.size()]); }
private static List<IAtom> getRgrps(IAtomContainer container, Elements reversed) { List<IAtom> res = new ArrayList<>(); for (IAtom atom : container.atoms()) { if (atom.getAtomicNumber() == 0) { res.add(atom); } else if (atom.getAtomicNumber() == reversed.number()) { return Collections.emptyList(); } } return res; }
/** * Gets an array of all isotopes known to the IsotopeFactory for the given * element symbol. * *@param symbol An element symbol to search for *@return An array of isotopes that matches the given element symbol */ public IIsotope[] getIsotopes(String symbol) { final int elem = Elements.ofString(symbol).number(); if (isotopes[elem] == null) return EMPTY_ISOTOPE_ARRAY; List<IIsotope> list = new ArrayList<IIsotope>(); for (IIsotope isotope : isotopes[elem]) { list.add(clone(isotope)); } return list.toArray(new IIsotope[list.size()]); }
/** * Returns the most abundant (major) isotope whose symbol equals element. * *@param symbol the symbol of the element in question *@return The Major Isotope value */ public IIsotope getMajorIsotope(String symbol) { return getMajorIsotope(Elements.ofString(symbol).number()); }
/** * Returns the most abundant (major) isotope whose symbol equals element. * *@param symbol the symbol of the element in question *@return The Major Isotope value */ public IIsotope getMajorIsotope(String symbol) { return getMajorIsotope(Elements.ofString(symbol).number()); }
/** * Get an isotope based on the element symbol and exact mass. * * @param symbol the element symbol * @param exactMass the mass number * @param tolerance allowed difference from provided exact mass * @return the corresponding isotope */ public IIsotope getIsotope(String symbol, double exactMass, double tolerance) { IIsotope ret = null; double minDiff = Double.MAX_VALUE; int elem = Elements.ofString(symbol).number(); List<IIsotope> isotopes = this.isotopes[elem]; if (isotopes == null) return null; for (IIsotope isotope : isotopes) { double diff = Math.abs(isotope.getExactMass() - exactMass); if (isotope.getSymbol().equals(symbol) && diff <= tolerance && diff < minDiff) { ret = clone(isotope); minDiff = diff; } } return ret; }
/** * Get an isotope based on the element symbol and exact mass. * * @param symbol the element symbol * @param exactMass the mass number * @param tolerance allowed difference from provided exact mass * @return the corresponding isotope */ public IIsotope getIsotope(String symbol, double exactMass, double tolerance) { IIsotope ret = null; double minDiff = Double.MAX_VALUE; int elem = Elements.ofString(symbol).number(); List<IIsotope> isotopes = this.isotopes[elem]; if (isotopes == null) return null; for (IIsotope isotope : isotopes) { double diff = Math.abs(isotope.getExactMass() - exactMass); if (isotope.getSymbol().equals(symbol) && diff <= tolerance && diff < minDiff) { ret = clone(isotope); minDiff = diff; } } return ret; }
/** * Get isotope based on element symbol and mass number. * * @param symbol the element symbol * @param massNumber the mass number * @return the corresponding isotope */ public IIsotope getIsotope(String symbol, int massNumber) { int elem = Elements.ofString(symbol).number(); List<IIsotope> isotopes = this.isotopes[elem]; if (isotopes == null) return null; for (IIsotope isotope : isotopes) { if (isotope.getSymbol().equals(symbol) && isotope.getMassNumber() == massNumber) { return clone(isotope); } } return null; }
/** * Get isotope based on element symbol and mass number. * * @param symbol the element symbol * @param massNumber the mass number * @return the corresponding isotope */ public IIsotope getIsotope(String symbol, int massNumber) { int elem = Elements.ofString(symbol).number(); List<IIsotope> isotopes = this.isotopes[elem]; if (isotopes == null) return null; for (IIsotope isotope : isotopes) { if (isotope.getSymbol().equals(symbol) && isotope.getMassNumber() == massNumber) { return clone(isotope); } } return null; }
@Test public void atomicNumHighWeightElements() { assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Darmstadtium.number())), is("[#110]")); assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Tennessine.number())), is("[#117]")); assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Nihonium.number())), is("[#113]")); assertThat(Smarts.generateAtom(expr(ALIPHATIC_ELEMENT, Elements.Darmstadtium.number())), is("[#110]")); assertThat(Smarts.generateAtom(expr(ALIPHATIC_ELEMENT, Elements.Tennessine.number())), is("[#117]")); assertThat(Smarts.generateAtom(expr(ALIPHATIC_ELEMENT, Elements.Nihonium.number())), is("[#113]")); }
/** *{@inheritDoc} */ @Override public int compare(IAtomContainer containerA, IAtomContainer containerB) { // first order by size int sizeCmp = Ints.compare(sizePreference(containerA.getAtomCount()), sizePreference(containerB.getAtomCount())); if (sizeCmp != 0) return sizeCmp; // now order by number of double bonds int piBondCmp = Ints.compare(nDoubleBonds(containerA), nDoubleBonds(containerB)); if (piBondCmp != 0) return -piBondCmp; // order by element frequencies, all carbon rings are preferred int[] freqA = countLightElements(containerA); int[] freqB = countLightElements(containerB); for (Elements element : Arrays.asList(Elements.Carbon, Elements.Nitrogen, Elements.Oxygen, Elements.Sulfur, Elements.Phosphorus)) { int elemCmp = Ints.compare(freqA[element.number()], freqB[element.number()]); if (elemCmp != 0) return -elemCmp; } return 0; }
@Test public void chromium() { Expr actual = getAtomExpr("[Cr]"); Expr expected = expr(ELEMENT, Elements.Chromium.number()); assertThat(actual, is(expected)); }
@Test public void testAliphaticSymbols() { for (Elements e : Elements.values()) { int len = e.symbol().length(); if (len == 1 || len == 2) { String smarts = "[" + e.symbol() + "]"; QueryAtomContainer mol = new QueryAtomContainer(null); assertTrue(smarts, Smarts.parse(mol, smarts)); Expr expr = getAtomExpr(mol.getAtom(0)); assertThat(expr, anyOf(is(new Expr(ELEMENT, e.number())), is(new Expr(ALIPHATIC_ELEMENT, e.number())))); } } }
@Test public void atomicNum() { assertThat(Smarts.generateAtom(expr(ELEMENT, 0)), is("[#0]")); assertThat(Smarts.generateAtom(expr(ALIPHATIC_ELEMENT, 0)), is("[#0]")); assertThat(Smarts.generateAtom(expr(AROMATIC_ELEMENT, 0)), is("[#0]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 1)), is("[#1]")); assertThat(Smarts.generateAtom(expr(ALIPHATIC_ELEMENT, 1)), is("[#1]")); assertThat(Smarts.generateAtom(expr(AROMATIC_ELEMENT, 1)), is("[#1]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 2)), is("[He]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 3)), is("[Li]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 6)), is("[#6]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 7)), is("[#7]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 8)), is("[#8]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 9)), is("F")); assertThat(Smarts.generateAtom(expr(ELEMENT, 10)), is("[Ne]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 11)), is("[Na]")); assertThat(Smarts.generateAtom(expr(ELEMENT, 12)), is("[Mg]")); // Ds, Ts and Nh etc write as #<num> assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Darmstadtium.number())), is("[#110]")); assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Tennessine.number())), is("[#117]")); assertThat(Smarts.generateAtom(expr(ELEMENT, Elements.Nihonium.number())), is("[#113]")); }