Skip to content

Commit

Permalink
Ignore prefix underscore on R labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Dec 3, 2018
1 parent 9e7cb8f commit 23baae9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ private static boolean processAtomLabels(final CharIter iter, final Map<Integer,
return true;
} else {
iter.pos--; // push back
final int beg = iter.pos;
int beg = iter.pos;
int rollback = beg;
while (iter.hasNext()) {

if (iter.pos == beg && iter.curr() == '_' &&
iter.peek() == 'R') {
++beg;
}

// correct step over of escaped label
if (iter.curr() == '&') {
rollback = iter.pos;
Expand Down Expand Up @@ -677,6 +683,10 @@ char next() {
return str.charAt(pos++);
}

public char peek() {
return pos < str.length() ? str.charAt(pos+1) : '\0';
}


/**
* Access a substring from the iterator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ public void atomLabelsTruncated3() {
assertThat(CxSmilesParser.processCx("|$;;;Het;$", state), is(-1));
}

@Test
public void removeUnderscore() {
CxSmilesState state = new CxSmilesState();
CxSmilesParser.processCx("|$;;;_R1;$|", state);
assertThat(state.atomLabels.get(3), is("R1"));
}

@Test
public void skipCis() {
CxSmilesState state = new CxSmilesState();
Expand Down

0 comments on commit 23baae9

Please sign in to comment.