Skip to content

Commit

Permalink
Fix test regressions, I thought setSymbol also sets the atomic number…
Browse files Browse the repository at this point in the history
… - it does not.
  • Loading branch information
johnmay committed Apr 30, 2017
1 parent 28a46c6 commit 6e60cdd
Showing 1 changed file with 5 additions and 13 deletions.
Expand Up @@ -26,6 +26,7 @@

import com.google.common.collect.ImmutableSet;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.config.Elements;
import org.openscience.cdk.config.IsotopeFactory;
import org.openscience.cdk.config.Isotopes;
import org.openscience.cdk.exception.CDKException;
Expand Down Expand Up @@ -1280,9 +1281,11 @@ static int length(final String str) {
* @throws CDKException the symbol is not allowed
*/
private IAtom createAtom(String symbol, IChemObjectBuilder builder, int lineNum) throws CDKException {
if (isPeriodicElement(symbol)) {
final Elements elem = Elements.ofString(symbol);
if (elem != Elements.Unknown) {
IAtom atom = builder.newAtom();
atom.setSymbol(symbol);
atom.setSymbol(elem.symbol());
atom.setAtomicNumber(elem.number());
return atom;
}
if (symbol.equals("D") && interpretHydrogenIsotopes.isSet()) {
Expand Down Expand Up @@ -1315,17 +1318,6 @@ private IAtom createAtom(String symbol, IChemObjectBuilder builder, int lineNum)
return atom;
}

/**
* Is the symbol a periodic element.
*
* @param symbol a symbol from the input
* @return the symbol is a pseudo atom
*/
private static boolean isPeriodicElement(final String symbol) {
// XXX: PeriodicTable is slow - switch without file IO would be optimal
Integer elem = PeriodicTable.getAtomicNumber(symbol);
return elem != null && elem > 0;
}

/**
* Is the atom symbol a non-periodic element (i.e. pseudo). Valid pseudo
Expand Down

0 comments on commit 6e60cdd

Please sign in to comment.