mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-05 22:04:27 +08:00
Add tautomer query to the substructlibrary (#3808)
* Fixes #3797 * [WIP] Add tautomer queries to the substruct library * Add TautomerQuery to CMake * Add missing TautomerQuery functions, python wrapper and tests * Add python wrappers for Substruct Library Tautomer Queries * Explictly label non-const pattern function now that we have both * Use boost::shared_ptr not std::shared_ptr * Fix java builds * One more try to fix java builds * Fix Java Tests * Run clang format * Reenable tests * Fix annoyingly stupid bug and annoying commit of debug code * Fix documentation * reenable ifdef threadsafe check * Throw warning and perform tautomer search instead of bailing with incorrect fingerprints * Simplfy api with templates * Fix SubstructLibrary java issues * minor API cleanup * simplify the SWIG wrappers Co-authored-by: Brian Kelley <bkelley@relaytx.com> Co-authored-by: greg landrum <greg.landrum@gmail.com>
This commit is contained in:
@@ -57,6 +57,7 @@ public class SubstructLibraryTests extends GraphMolTest {
|
||||
|
||||
// fpholder - can we create it...
|
||||
PatternHolder ph = new PatternHolder();
|
||||
TautomerPatternHolder tph = new TautomerPatternHolder();
|
||||
|
||||
// Now lets make some molecules
|
||||
mol = RWMol.MolFromSmiles("c1ccccc1");
|
||||
@@ -139,7 +140,10 @@ public class SubstructLibraryTests extends GraphMolTest {
|
||||
|
||||
matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertTrue(lib.hasMatch(mol));
|
||||
|
||||
|
||||
if(lib.canSerialize()) {
|
||||
byte pickle[] = lib.Serialize();
|
||||
assertTrue(pickle != null);
|
||||
@@ -148,6 +152,8 @@ public class SubstructLibraryTests extends GraphMolTest {
|
||||
assertEquals(lib.size(), 1);
|
||||
matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertTrue(lib.hasMatch(mol));
|
||||
}
|
||||
|
||||
// cached smiles mol holder
|
||||
@@ -237,6 +243,75 @@ public class SubstructLibraryTests extends GraphMolTest {
|
||||
assertEquals(1, matches.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4Basics() {
|
||||
MolHolder mh = new MolHolder();
|
||||
TautomerPatternHolder pat = new TautomerPatternHolder();
|
||||
assertEquals(0, mh.size());
|
||||
CachedMolHolder cmh = new CachedMolHolder();
|
||||
assertEquals(0, cmh.size());
|
||||
CachedSmilesMolHolder csmh = new CachedSmilesMolHolder();
|
||||
assertEquals(0, csmh.size());
|
||||
CachedTrustedSmilesMolHolder ctsmh = new CachedTrustedSmilesMolHolder();
|
||||
assertEquals(0, ctsmh.size());
|
||||
mol = RWMol.MolFromSmiles("c1ccccc1");
|
||||
TautomerQuery tautomerQuery = TautomerQuery.fromMol(mol);
|
||||
|
||||
// mol holder
|
||||
SubstructLibrary lib = new SubstructLibrary(mh, pat);
|
||||
lib.addMol(mol);
|
||||
|
||||
UInt_Vect matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
|
||||
matches = lib.getMatches(tautomerQuery);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertEquals(1, lib.countMatches(tautomerQuery));
|
||||
|
||||
// cached mol holder
|
||||
try {
|
||||
lib = new SubstructLibrary(cmh, pat);
|
||||
lib.addMol(mol);
|
||||
assertTrue(false); // shouldn't get here can't share patternholder and addmol
|
||||
} catch(Exception e) {
|
||||
// ok to get here
|
||||
}
|
||||
cmh = new CachedMolHolder();
|
||||
pat = new TautomerPatternHolder();
|
||||
lib = new SubstructLibrary(cmh, pat);
|
||||
lib.addMol(mol);
|
||||
matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
matches = lib.getMatches(tautomerQuery);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertEquals(1, lib.countMatches(tautomerQuery));
|
||||
|
||||
// cached smiles mol holder
|
||||
pat = new TautomerPatternHolder();
|
||||
lib = new SubstructLibrary(csmh, pat);
|
||||
lib.addMol(mol);
|
||||
|
||||
matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
matches = lib.getMatches(tautomerQuery);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertEquals(1, lib.countMatches(tautomerQuery));
|
||||
|
||||
// cached trusted smiles mol holder
|
||||
pat = new TautomerPatternHolder();
|
||||
lib = new SubstructLibrary(ctsmh, pat);
|
||||
lib.addMol(mol);
|
||||
|
||||
matches = lib.getMatches(mol);
|
||||
assertEquals(1, matches.size());
|
||||
matches = lib.getMatches(tautomerQuery);
|
||||
assertEquals(1, matches.size());
|
||||
assertEquals(1, lib.countMatches(mol));
|
||||
assertEquals(1, lib.countMatches(tautomerQuery));
|
||||
}
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
Reference in New Issue
Block a user