Navigation Menu

Skip to content

Commit

Permalink
Fix labelling of protons.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Jun 22, 2017
1 parent 801b108 commit cdc1ec1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Expand Up @@ -137,7 +137,6 @@ static long[] parseUSmilesNumbers(String aux, IAtomContainer container) {
if ((index = aux.indexOf("/F:")) >= 0) {
String[] fixedHNumbers = aux.substring(index + 3, aux.indexOf('/', index + 3)).split(";");
for (int i = 0; i < fixedHNumbers.length; i++) {

String component = fixedHNumbers[i];

// m, 2m, 3m ... need to lookup number in the base numbering
Expand All @@ -152,9 +151,8 @@ static long[] parseUSmilesNumbers(String aux, IAtomContainer container) {
}
} else {
String[] numbering = component.split(",");
first[i] = Integer.parseInt(numbering[0]) - 1;
for (String number : numbering)
numbers[Integer.parseInt(number) - 1] = label++;
numbers[Integer.parseInt(number)-1] = label++;
}
}
} else {
Expand Down
Expand Up @@ -171,6 +171,13 @@ public void bug1370() throws Exception {
assertThat(InChINumbersTools.getUSmilesNumbers(container), is(new long[]{3, 1, 2}));
}

@Test
public void protons() throws Exception {
IAtomContainer container = new SmilesParser(SilentChemObjectBuilder.getInstance())
.parseSmiles("[H+].[H+].F[Si-2](F)(F)(F)(F)F");
assertThat(InChINumbersTools.getUSmilesNumbers(container), is(new long[]{8, 9, 1, 7, 2, 3, 4, 5, 6}));
}

static IAtomContainer mock(int nAtoms) {
IAtomContainer container = Mockito.mock(IAtomContainer.class);
when(container.getAtomCount()).thenReturn(nAtoms);
Expand Down

0 comments on commit cdc1ec1

Please sign in to comment.