forked from rdkit/rdkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fingerprints to GeneralizedSubstruct search and extended SWIG w…
…rappers (rdkit#6991) * Added fingerprints to GeneralizedSubstruct search * Small change to fire tests * Edits from code review * Updated swig - newobject not required for GeneralizedSubstruct fingerprint methods * GeneralizedSubstruct only supports unique_ptr in SWIG4.1
- Loading branch information
1 parent
b6361ae
commit 31de6b0
Showing
8 changed files
with
196 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
Code/JavaWrappers/csharp_wrapper/RDKitCSharpTest/GeneralizedSubstructTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using GraphMolWrap; | ||
using Xunit; | ||
|
||
namespace RdkitTests | ||
{ | ||
public class GeneralizedSubstructTest | ||
{ | ||
private bool FingerprintsMatch(ExtendedQueryMol queryMol, RWMol target) | ||
{ | ||
var queryFingerprint = queryMol.patternFingerprintQuery(); | ||
var targetFingerprint = RDKFuncs.patternFingerprintTargetMol(target); | ||
Assert.True(queryFingerprint.getNumOnBits() > 0); | ||
Assert.True(targetFingerprint.getNumOnBits() > 0); | ||
var match = RDKFuncs.AllProbeBitsMatch(queryFingerprint, targetFingerprint); | ||
return match; | ||
} | ||
|
||
[Fact] | ||
public void TestControlSteps() | ||
{ | ||
var queryMol = RWMol.MolFromSmiles("COCC1OC(N)=N1 |LN:1:1.3|"); | ||
var xqm1 = RDKFuncs.createExtendedQueryMol(queryMol); | ||
var xqm2 = RDKFuncs.createExtendedQueryMol(queryMol, false); | ||
var xqm3 = RDKFuncs.createExtendedQueryMol(queryMol, true, false); | ||
var xqm4 = RDKFuncs.createExtendedQueryMol(queryMol, false, false); | ||
|
||
var mol1 = RWMol.MolFromSmiles("COCC1OC(N)=N1"); | ||
Assert.Equal(1, xqm1.getSubstructMatches(mol1).Count); | ||
Assert.Equal(1, xqm2.getSubstructMatches(mol1).Count); | ||
Assert.Equal(1, xqm3.getSubstructMatches(mol1).Count); | ||
Assert.Equal(1, xqm4.getSubstructMatches(mol1).Count); | ||
Assert.True(FingerprintsMatch(xqm1, mol1)); | ||
Assert.True(FingerprintsMatch(xqm2, mol1)); | ||
Assert.True(FingerprintsMatch(xqm3, mol1)); | ||
Assert.True(FingerprintsMatch(xqm4, mol1)); | ||
|
||
var mol2 = RWMol.MolFromSmiles("COCC1OC(=N)N1"); | ||
Assert.Equal(1, xqm1.getSubstructMatches(mol2).Count); | ||
Assert.Equal(1, xqm2.getSubstructMatches(mol2).Count); | ||
Assert.Equal(0, xqm3.getSubstructMatches(mol2).Count); | ||
Assert.Equal(0, xqm4.getSubstructMatches(mol2).Count); | ||
Assert.True(FingerprintsMatch(xqm1, mol2)); | ||
Assert.True(FingerprintsMatch(xqm2, mol2)); | ||
Assert.False(FingerprintsMatch(xqm3, mol2)); | ||
Assert.False(FingerprintsMatch(xqm4, mol2)); | ||
|
||
var mol3 = RWMol.MolFromSmiles("COOCC1OC(N)=N1"); | ||
Assert.Equal(1, xqm1.getSubstructMatches(mol3).Count); | ||
Assert.Equal(0, xqm2.getSubstructMatches(mol3).Count); | ||
Assert.Equal(1, xqm3.getSubstructMatches(mol3).Count); | ||
Assert.Equal(0, xqm4.getSubstructMatches(mol3).Count); | ||
Assert.True(FingerprintsMatch(xqm1, mol3)); | ||
Assert.True(FingerprintsMatch(xqm3, mol3)); | ||
} | ||
} | ||
} |