Skip to content

Commit

Permalink
Merge pull request #410 from cdk/patch/acceptLpInCxSmiles
Browse files Browse the repository at this point in the history
Looks good to me.
  • Loading branch information
egonw committed Jan 10, 2018
2 parents 29a0a9b + 2b9e401 commit a32c59f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Expand Up @@ -428,7 +428,7 @@ static int processCx(final String str, final CxSmilesState state) {
if (!processCoords(iter, state))
return -1;
break;
case 'c': // Skip cis/trans/unspec
case 'c': // cis/trans/unspec ignored
case 't':
// c/t:
if (iter.nextIf(':')) {
Expand All @@ -441,12 +441,18 @@ else if (iter.nextIf("tu:")) {
return -1;
}
break;
case 'r': // Skip relative stereochemistry
case 'r': // relative stereochemistry ignored
if (!iter.nextIf(':'))
return -1;
if (!skipIntList(iter, COMMA_SEPARATOR))
return -1;
break;
case 'l': // lone pairs ignored
if (!iter.nextIf("p:"))
return -1;
if (!skipIntMap(iter))
return -1;
break;
case 'f': // fragment grouping
if (!iter.nextIf(':'))
return -1;
Expand Down Expand Up @@ -477,7 +483,7 @@ else if (iter.nextIf("gD:")) {
return -1;
break;
case 'C':
case 'H': // skip coordination and hydrogen bonding
case 'H': // coordination and hydrogen bonding ignored
if (!iter.nextIf(':'))
return -1;
while (iter.hasNext() && isDigit(iter.curr())) {
Expand Down Expand Up @@ -514,6 +520,18 @@ private static boolean skipIntList(CharIter iter, char sep) {
return false;
}

private static boolean skipIntMap(CharIter iter) {
while (iter.hasNext()) {
char c = iter.curr();
if (isDigit(c) || c == ',' || c == ':')
iter.next();
else
return true;
}
// ran of end
return false;
}

private static int processUnsignedInt(CharIter iter) {
if (!iter.hasNext())
return -1;
Expand Down
Expand Up @@ -112,6 +112,12 @@ public void skipCisTransUnspec() {
assertThat(CxSmilesParser.processCx("|c:2,6,8,ctu:10,t:1,4,5|", state), is(not(-1)));
}

@Test
public void skipLonePairDefinitions() {
CxSmilesState state = new CxSmilesState();
assertThat(CxSmilesParser.processCx("|c:6,8,t:4,lp:2:2,4:1,11:1,m:1:8.9|", state), is(not(-1)));
}

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

0 comments on commit a32c59f

Please sign in to comment.