Navigation Menu

Skip to content

Commit

Permalink
Deprecate defunct SMILES flag now the core library invariants are bet…
Browse files Browse the repository at this point in the history
…ter.
  • Loading branch information
johnmay committed Jun 7, 2017
1 parent b197fbf commit f8e1a80
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
Expand Up @@ -225,9 +225,7 @@ static Atom toBeamAtom(final IAtom a, final int flavour) {
if (SmiFlavor.isSet(flavour, SmiFlavor.AtomicMass | SmiFlavor.AtomicMassStrict)) {
Integer massNumber = a.getMassNumber();
if (massNumber != null) {
if (SmiFlavor.isSet(flavour, SmiFlavor.AtomicMassStrict) ||
!massNumber.equals(getMajorMassNumber(element)))
ab.isotope(massNumber);
ab.isotope(massNumber);
}
}

Expand Down
Expand Up @@ -96,7 +96,10 @@ private SmiFlavor() {
/**
* Generate SMILES with the major isotopes, only omit mass numbers when it
* is unset.
* @deprecated no longer needed, default CDK behaviour is now to pass
* through mass numbers if non-null
*/
@Deprecated
public static final int AtomicMassStrict = 0x800;


Expand Down
Expand Up @@ -154,11 +154,11 @@ public void specifiedIsotope() throws Exception {
}

@Test
public void defaultIsotope() throws Exception {
public void noDefaultIsotope() throws Exception {
IAtom a = new Atom("C");
a.setImplicitHydrogenCount(0);
a.setMassNumber(12);
assertThat(new CDKToBeam().toBeamAtom(a).isotope(), is(-1));
assertThat(new CDKToBeam().toBeamAtom(a).isotope(), is(12));
}

// special check that a CDK pseudo atom will default to 0 hydrogens if
Expand Down
Expand Up @@ -1243,7 +1243,13 @@ public void strictIsotopes() throws CDKException {
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = smipar.parseSmiles("[12CH3]C");
assertThat(new SmilesGenerator(SmiFlavor.AtomicMassStrict).create(mol), is("[12CH3]C"));
assertThat(new SmilesGenerator(SmiFlavor.AtomicMass).create(mol), is("CC"));
}

@Test
public void isotopes() throws CDKException {
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = smipar.parseSmiles("[12CH3]C");
assertThat(new SmilesGenerator(SmiFlavor.AtomicMass).create(mol), is("[12CH3]C"));
}

static ITetrahedralChirality anticlockwise(IAtomContainer container, int central, int a1, int a2, int a3, int a4) {
Expand Down
Expand Up @@ -26,13 +26,16 @@

import org.junit.Ignore;
import org.junit.Test;
import org.openscience.cdk.exception.InvalidSmilesException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.isomorphism.Pattern;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;

import java.io.IOException;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
Expand Down

0 comments on commit f8e1a80

Please sign in to comment.