Skip to content

Commit

Permalink
Fixed hydrogen bug and disabled evaluation test;
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasSchaub committed Feb 1, 2024
1 parent 6214bac commit 9f4f57c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@ private void markAtoms(IAtomContainer aMolecule) {
// if H...
// convert to implicit H
IAtom tmpConnectedAtom;
try {
if (this.adjListCache[idx].length > 0) {
tmpConnectedAtom = aMolecule.getAtom(this.adjListCache[idx][0]);
} catch(ArrayIndexOutOfBoundsException anException) {
//TODO: this happens too often to ignore, investigate!
ErtlFunctionalGroupsFinder.LOGGING_TOOL.warn("Explicit H was included in atom count but not correctly in adjacency list");
break;
} else {
//unconnected, explicit hydrogen atoms (like e.g. in CHEBI:365445) have an array of bond partners of size 0
// nothing to do about them, but they also do not concern us
continue;
}
if (Objects.isNull(tmpConnectedAtom.getImplicitHydrogenCount())) {
tmpConnectedAtom.setImplicitHydrogenCount(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKConstants;
Expand Down Expand Up @@ -93,6 +94,7 @@
* @author Jonas Schaub
* @version 1.3
*/
@Disabled("Legacy code and lengthy analyses")
public class ErtlFunctionalGroupsFinderEvaluationTest {

//<editor-fold defaultstate="collapsed" desc="Private static final constants">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,23 @@ public void testRAtoms1() throws Exception {
this.testFind(tmpMoleculeSmiles, tmpExpectedFGs);
}
//
/**
* Tests that a former bug concerning unconnected, explicit hydrogen atoms does not occur anymore.
*
* @throws Exception if anything goes wrong
* @author Jonas Schaub
*/
@Test
public void testHydrogenBug() throws Exception {
String tmpMoleculeSmiles = "[H+].[H+].[O-]C(=O)\\C=C/C([O-])=O.[H][C@@]12Cc3c[nH]c4cccc(C1=C[C@@H](COC(=O)C1CCCCC1)CN2C)c34"; //CHEBI:365445
String[] tmpExpectedFGs = new String[]{"O=C([O-])[C]=[C]C(=O)[O-]", "[C]=[C]", "*OC(*)=O", "[R]N([R])[R]", "NarR3"};
this.testFind(tmpMoleculeSmiles, tmpExpectedFGs);

tmpMoleculeSmiles = "[HH].O=C1N([C@H](C)C(C1=C(O)[C@]2([C@]3([C@H](C=C([C@H]2[C@@H](C(=O)O)CC)C)C[C@H](C)CC3)C)C)=O)C"; //CHEBI:223373
tmpExpectedFGs = new String[]{"*C(=O)C(=[C]O[H])C(=O)N(*)*", "[C]=[C]", "*C(=O)O[H]"};
this.testFind(tmpMoleculeSmiles, tmpExpectedFGs);
}
//
/**
* Applies EFGF to detect functional groups in the given molecule and compares the identified FG to the given
* expected FG, using i.a. an identity search. Note that the order of the given FG must match the order of the detected
Expand Down

0 comments on commit 9f4f57c

Please sign in to comment.