Skip to content

Commit 223f7cd

Browse files
johnmayegonw
authored andcommitted
Bug enhanced stereo should not be emitted for exclusively "Isomeric" SMILES flavour.
1 parent 428e399 commit 223f7cd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

storage/smiles/src/main/java/org/openscience/cdk/smiles/CxSmilesGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public int compare(List<Integer> a, List<Integer> b) {
192192
sb.append('$');
193193
}
194194

195-
if (SmiFlavor.isSet(opts, SmiFlavor.CxEnhancedStereo)) {
195+
if (SmiFlavor.isFullySet(opts, SmiFlavor.CxEnhancedStereo)) {
196196
if (state.racemic) {
197197
if (sb.length() > 2)
198198
sb.append(',');

storage/smiles/src/main/java/org/openscience/cdk/smiles/SmiFlavor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,13 @@ private SmiFlavor() {
241241
*/
242242
public static final int UniversalSmiles = InChILabelling | Isomeric;
243243

244+
// test if a single bit flag is set
244245
static boolean isSet(int opts, int opt) {
245246
return (opts & opt) != 0;
246247
}
248+
249+
// test if the flag is fully set with all bits
250+
static boolean isFullySet(int opts, int opt) {
251+
return (opts & opt) == opt;
252+
}
247253
}

storage/smiles/src/test/java/org/openscience/cdk/smiles/CxSmilesGeneratorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,11 @@ public void radicalCanon() throws Exception {
189189
SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.CxEnhancedStereo);
190190
assertThat(smigen.create(mol), is("C[C@H](O)[C@H](O)C1CCCCC1 |a:1,&1:3|"));
191191
}
192+
193+
@Test public void noEnhancedStereoInIsomeric() throws Exception {
194+
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
195+
IAtomContainer mol = smipar.parseSmiles("C[C@H](O)[C@H](O)C1CCCCC1 |r|");
196+
SmilesGenerator smigen = new SmilesGenerator(SmiFlavor.Isomeric);
197+
assertThat(smigen.create(mol), is("C[C@H](O)[C@H](O)C1CCCCC1"));
198+
}
192199
}

0 commit comments

Comments
 (0)