Skip to content

Commit

Permalink
Atom values were omitted from output.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Aug 16, 2016
1 parent 2dffeff commit c494b38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,27 @@ public int compare(List<Integer> a, List<Integer> b) {
sb.append('$');
}

// Atom Values
if (SmiFlavour.isSet(opts, SmiFlavour.CxAtomValue) &&
state.atomValues != null && !state.atomValues.isEmpty()) {

if (sb.length() > 2)
sb.append(',');
sb.append("$_AV:");
int nonempty_cnt = 0;
for (int idx : invorder) {
String label = state.atomValues.get(idx);
if (label == null || label.isEmpty()) label = "";
else nonempty_cnt++;
sb.append(encode_alias(label));
// don't need to write anymore more ';'
if (nonempty_cnt == state.atomValues.size())
break;
sb.append(";");
}
sb.append('$');
}

// 2D/3D Coordinates
if (SmiFlavour.isSet(opts, SmiFlavour.CxCoordinates) &&
state.atomCoords != null && !state.atomCoords.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,12 @@ public void atomValues() throws InvalidSmilesException {
is(smigen.create(rxn2)));
}

@Test public void canonAtomLabels() throws CDKException {
IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance();
SmilesParser smipar = new SmilesParser(bldr);
IAtomContainer mol = smipar.parseSmiles("c1ccccc1O |$_AV:0;1;2;3;4;5;6$|");
SmilesGenerator smigen = new SmilesGenerator(SmiFlavour.Canonical | SmiFlavour.CxAtomValue);
assertThat(smigen.create(mol), is("OC=1C=CC=CC1 |$_AV:6;5;0;1;2;3;4$|"));
}

}

0 comments on commit c494b38

Please sign in to comment.