rdkit_chem 2019.03.3.1 → 2025.09.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +713 -0
  3. data/Code/CMakeLists.txt +44 -0
  4. data/Code/RubyWrappers/Abbreviations.i +19 -0
  5. data/Code/RubyWrappers/AddHs.i +34 -0
  6. data/Code/RubyWrappers/Atom.i +165 -0
  7. data/Code/RubyWrappers/AtomIterators.i +77 -0
  8. data/Code/RubyWrappers/AtomPairs.i +95 -0
  9. data/Code/RubyWrappers/AvalonLib.i +41 -0
  10. data/Code/RubyWrappers/BitOps.i +72 -0
  11. data/Code/RubyWrappers/Bond.i +87 -0
  12. data/Code/RubyWrappers/BondIterators.i +61 -0
  13. data/Code/RubyWrappers/CMakeLists.txt +67 -0
  14. data/Code/RubyWrappers/Canon.i +40 -0
  15. data/Code/RubyWrappers/ChemDraw.i +81 -0
  16. data/Code/RubyWrappers/ChemReactions.i +166 -0
  17. data/Code/RubyWrappers/ChemTransforms.i +126 -0
  18. data/Code/RubyWrappers/Conformer.i +69 -0
  19. data/Code/RubyWrappers/Descriptors.i +64 -0
  20. data/Code/RubyWrappers/Dict.i +45 -0
  21. data/Code/RubyWrappers/DistGeom.i +217 -0
  22. data/Code/RubyWrappers/DiversityPick.h +49 -0
  23. data/Code/RubyWrappers/DiversityPick.i +10 -0
  24. data/Code/RubyWrappers/ErrorGenerator.i +73 -0
  25. data/Code/RubyWrappers/ExplicitBitVect.i +76 -0
  26. data/Code/RubyWrappers/FMCS.i +63 -0
  27. data/Code/RubyWrappers/FilterCatalog.i +154 -0
  28. data/Code/RubyWrappers/Fingerprints.i +56 -0
  29. data/Code/RubyWrappers/ForceField.i +161 -0
  30. data/Code/RubyWrappers/GeneralizedSubstruct.i +38 -0
  31. data/Code/RubyWrappers/GenericRDKitException.h +27 -0
  32. data/Code/RubyWrappers/Inchi.i +38 -0
  33. data/Code/RubyWrappers/MolBundle.i +16 -0
  34. data/Code/RubyWrappers/MolDraw2D.i +117 -0
  35. data/Code/RubyWrappers/MolEnumerator.i +45 -0
  36. data/Code/RubyWrappers/MolHash.i +25 -0
  37. data/Code/RubyWrappers/MolOps.i +72 -0
  38. data/Code/RubyWrappers/MolStandardize.i +37 -0
  39. data/Code/RubyWrappers/MolSupplier.i +83 -0
  40. data/Code/RubyWrappers/MolTransforms.i +39 -0
  41. data/Code/RubyWrappers/MolWriters.i +41 -0
  42. data/Code/RubyWrappers/MonomerInfo.i +42 -0
  43. data/Code/RubyWrappers/MorganFingerprints.h +21 -0
  44. data/Code/RubyWrappers/MorganFingerprints.i +66 -0
  45. data/Code/RubyWrappers/PeriodicTable.i +44 -0
  46. data/Code/RubyWrappers/Queries.i +289 -0
  47. data/Code/RubyWrappers/QueryAtom.i +47 -0
  48. data/Code/RubyWrappers/QueryBond.i +47 -0
  49. data/Code/RubyWrappers/QueryOps.i +44 -0
  50. data/Code/RubyWrappers/RDKitExceptions.i +75 -0
  51. data/Code/RubyWrappers/RDLogger.i +74 -0
  52. data/Code/RubyWrappers/RDProps.i +44 -0
  53. data/Code/RubyWrappers/RGroupDecomposition.i +52 -0
  54. data/Code/RubyWrappers/ROMol.i +695 -0
  55. data/Code/RubyWrappers/RWMol.i +241 -0
  56. data/Code/RubyWrappers/RascalMCES.i +71 -0
  57. data/Code/RubyWrappers/ReactionFingerprints.i +37 -0
  58. data/Code/RubyWrappers/RingInfo.i +40 -0
  59. data/Code/RubyWrappers/Rings.i +40 -0
  60. data/Code/RubyWrappers/SanitException.i +100 -0
  61. data/Code/RubyWrappers/ScaffoldNetwork.i +28 -0
  62. data/Code/RubyWrappers/SmartsWrite.i +38 -0
  63. data/Code/RubyWrappers/SmilesParse.i +40 -0
  64. data/Code/RubyWrappers/SmilesWrite.i +42 -0
  65. data/Code/RubyWrappers/StereoGroup.i +16 -0
  66. data/Code/RubyWrappers/Streams.i +67 -0
  67. data/Code/RubyWrappers/Subgraphs.i +53 -0
  68. data/Code/RubyWrappers/Subset.i +75 -0
  69. data/Code/RubyWrappers/SubstanceGroup.i +91 -0
  70. data/Code/RubyWrappers/SubstructLibrary.i +80 -0
  71. data/Code/RubyWrappers/TautomerQuery.i +19 -0
  72. data/Code/RubyWrappers/Trajectory.i +34 -0
  73. data/Code/RubyWrappers/boost_tuple.i +64 -0
  74. data/Code/RubyWrappers/extend_std_vector.i +10 -0
  75. data/Code/RubyWrappers/gmwrapper/CMakeLists.txt +69 -0
  76. data/Code/RubyWrappers/gmwrapper/GraphMolRuby.i +431 -0
  77. data/Code/RubyWrappers/gmwrapper/std_list.i +65 -0
  78. data/Code/RubyWrappers/point.i +56 -0
  79. data/Code/RubyWrappers/transforms.i +60 -0
  80. data/Code/RubyWrappers/types.i +40 -0
  81. data/README.md +24 -0
  82. data/Rakefile +125 -4
  83. data/ext/rdkit_chem/CMakeLists.txt +69 -0
  84. data/ext/rdkit_chem/Makefile +5 -0
  85. data/ext/rdkit_chem/extconf.rb +47 -17
  86. data/lib/rdkit_chem/version.rb +1 -1
  87. data/lib/rdkit_chem.rb +31 -1
  88. data/test/test_rdkit_chem.rb +38 -10
  89. metadata +119 -13
@@ -0,0 +1,83 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %include "std_string.i"
35
+ %include "std_vector.i"
36
+ %include "std_map.i"
37
+ %include "std_pair.i"
38
+
39
+ %{
40
+ #include <GraphMol/FileParsers/MolSupplier.h>
41
+ #include <GraphMol/FileParsers/MolSupplier.v1API.h>
42
+ #include <GraphMol/Resonance.h>
43
+ #include <GraphMol/Substruct/SubstructMatch.h>
44
+ %}
45
+
46
+ %include "Streams.i"
47
+ %ignore RDKit::v2;
48
+ %newobject RDKit::ForwardSDMolSupplier::next;
49
+ %newobject RDKit::ResonanceMolSupplier::next;
50
+ %newobject RDKit::SDMolSupplier::next;
51
+ %newobject RDKit::SmilesMolSupplier::next;
52
+ %newobject RDKit::TDTMolSupplier::next;
53
+ %newobject RDKit::PDBMolSupplier::next;
54
+
55
+
56
+ %include <GraphMol/FileParsers/MolSupplier.h>
57
+ %include <GraphMol/FileParsers/MolSupplier.v1API.h>
58
+
59
+ #ifdef RDK_USE_BOOST_IOSTREAMS
60
+ %extend RDKit::v1::ForwardSDMolSupplier {
61
+ ForwardSDMolSupplier(RDKit::gzstream *strm, bool sanitize=true, bool removeHs = true,
62
+ bool strictParsing = true) {
63
+ const bool takeOwnership = false;
64
+ RDKit::ForwardSDMolSupplier*foo = new RDKit::ForwardSDMolSupplier(
65
+ (std::istream*)strm,
66
+ takeOwnership,
67
+ sanitize, removeHs, strictParsing);
68
+ PRECONDITION(!foo->atEnd(), "LDJKLJF");
69
+ return foo;
70
+ }
71
+ };
72
+ #endif
73
+
74
+ %include <GraphMol/Resonance.h>
75
+
76
+ %extend RDKit::ResonanceMolSupplier {
77
+ std::vector< std::vector<std::pair<int, int> > > getSubstructMatches(RDKit::ROMol &query,bool uniquify=false, bool useChirality=false, int numThreads=1){
78
+ std::vector<RDKit::MatchVectType> mv;
79
+ SubstructMatch(*($self),query,mv,uniquify,true,useChirality,false,1000,numThreads);
80
+ return mv;
81
+ }
82
+ }
83
+
@@ -0,0 +1,39 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %{
35
+ #include <GraphMol/MolTransforms/MolTransforms.h>
36
+ %}
37
+
38
+ %rename(Transform3D) RDGeom::Transform3D;
39
+ %include <GraphMol/MolTransforms/MolTransforms.h>
@@ -0,0 +1,41 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %{
35
+ #include <GraphMol/FileParsers/FileWriters.h>
36
+ #include <GraphMol/FileParsers/MolWriters.h>
37
+ %}
38
+
39
+ %include <GraphMol/FileParsers/FileWriters.h>
40
+ %include <GraphMol/FileParsers/MolWriters.h>
41
+
@@ -0,0 +1,42 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2013, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %include "std_string.i"
35
+
36
+ %{
37
+ #include <GraphMol/MonomerInfo.h>
38
+ %}
39
+
40
+ %include <GraphMol/MonomerInfo.h>
41
+
42
+
@@ -0,0 +1,21 @@
1
+
2
+ #include <RDGeneral/export.h>
3
+ #include <GraphMol/Atom.h>
4
+ #include <GraphMol/GraphMol.h>
5
+ #include <GraphMol/Fingerprints/MorganFingerprints.h>
6
+ #include <DataStructs/BitVects.h>
7
+ #include <vector>
8
+
9
+ RDKit::SparseIntVect<std::uint32_t> *getFeatureFingerprint(
10
+ const RDKit::ROMol &mol, unsigned int radius, bool useChirality = false,
11
+ bool useBondTypes = true, bool useCounts = true) {
12
+ std::vector<std::uint32_t> *invars =
13
+ new std::vector<std::uint32_t>(mol.getNumAtoms());
14
+ RDKit::MorganFingerprints::getFeatureInvariants(mol, *invars);
15
+ RDKit::SparseIntVect<std::uint32_t> *res =
16
+ RDKit::MorganFingerprints::getFingerprint(
17
+ mol, static_cast<unsigned int>(radius), invars, 0, useChirality,
18
+ useBondTypes, useCounts, false, 0);
19
+ delete invars;
20
+ return res;
21
+ }
@@ -0,0 +1,66 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+
35
+ %{
36
+ #include <boost/cstdint.hpp>
37
+ #include <DataStructs/SparseIntVect.h>
38
+ #include <GraphMol/Fingerprints/MorganFingerprints.h>
39
+ #include <MorganFingerprints.h>
40
+ %}
41
+
42
+ //%include <DataStructs/SparseIntVect.h>
43
+
44
+
45
+ %newobject RDKit::MorganFingerprints::getFingerprint;
46
+ %rename(MorganFingerprintMol) RDKit::MorganFingerprints::getFingerprint;
47
+ %newobject RDKit::MorganFingerprints::getFingerprintAsBitVect;
48
+ %rename(getMorganFingerprintAsBitVect) RDKit::MorganFingerprints::getFingerprintAsBitVect;
49
+ %include <GraphMol/Fingerprints/MorganFingerprints.h>
50
+
51
+ %include <DataStructs/BitOps.h>
52
+ %template(TanimotoSimilarityEBV) TanimotoSimilarity<ExplicitBitVect,ExplicitBitVect>;
53
+ %template(DiceSimilarity) DiceSimilarity<ExplicitBitVect,ExplicitBitVect>;
54
+ // Use base types (int/unsigned int) to avoid duplicate swig::traits definitions
55
+ %template(DiceSimilarity) RDKit::DiceSimilarity<unsigned int>;
56
+ %template(DiceSimilarity) RDKit::DiceSimilarity<int>;
57
+ // DiceSimilarity<long long> removed - Ruby SWIG lacks swig::traits for long long int
58
+ %template(TanimotoSimilaritySIVu32) RDKit::TanimotoSimilarity<unsigned int>;
59
+ %template(TanimotoSimilaritySIVi32) RDKit::TanimotoSimilarity<int>;
60
+ // TanimotoSimilaritySIVi64 removed - Ruby SWIG lacks swig::traits for long long int
61
+ %template(TverskySimilarity) RDKit::TverskySimilarity<unsigned int>;
62
+ %template(TverskySimilarity) RDKit::TverskySimilarity<int>;
63
+ // TverskySimilarity<long long> removed - Ruby SWIG lacks swig::traits for long long int
64
+
65
+
66
+ %include "MorganFingerprints.h"
@@ -0,0 +1,44 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %{
35
+ #include <map>
36
+ #include <vector>
37
+ #include <RDGeneral/types.h>
38
+ #include <GraphMol/atomic_data.h>
39
+ #include <GraphMol/PeriodicTable.h>
40
+ %}
41
+
42
+ %include <RDGeneral/types.h>
43
+ %include <GraphMol/atomic_data.h>
44
+ %include <GraphMol/PeriodicTable.h>
@@ -0,0 +1,289 @@
1
+ /*
2
+ *
3
+ * Copyright (C) 2024 Gareth Jones, Glysade LLC
4
+ *
5
+ * @@ All Rights Reserved @@
6
+ * This file is part of the RDKit.
7
+ * The contents are covered by the terms of the BSD license
8
+ * which is included in the file license.txt, found at the root
9
+ * of the RDKit source tree.
10
+ *
11
+ */
12
+
13
+ %include <boost_shared_ptr.i>
14
+ %shared_ptr(RDKit::QueryAtom)
15
+ %shared_ptr(RDKit::QueryBond)
16
+
17
+ // Adapted from the Python Wrappers
18
+
19
+ %{
20
+ #include <GraphMol/RDKitBase.h>
21
+ #include <GraphMol/RDKitQueries.h>
22
+ #include <RDGeneral/types.h>
23
+ %}
24
+
25
+ %include <GraphMol/RDKitBase.h>;
26
+ %include <GraphMol/RDKitQueries.h>;
27
+ %include <RDGeneral/types.h>;
28
+
29
+ /*
30
+ NOTE: it looks like there is a typo in the below code
31
+ ATOM_GREATER_QUERY is intentionally being used for the LessQueryAtom
32
+ and ATOM_LESS_QUERY for GreaterQueryAtom in the python API.
33
+ The C++ API is internally consistent and logical, but having
34
+ AtomNumLessQueryAtom(6) return atoms where 6 is less than their atomic
35
+ number feels backwards in Python.
36
+
37
+ */
38
+ %define QAFUNC1(funcname, func, type)
39
+ %inline %{
40
+
41
+ boost::shared_ptr<RDKit::QueryAtom> funcname ## EqualsQueryAtom(type val, bool negate=false) {
42
+ boost::shared_ptr<RDKit::QueryAtom> res(new RDKit::QueryAtom());
43
+ res->setQuery(RDKit:: ## func(val));
44
+ if (negate) {
45
+ res->getQuery()->setNegation(true);
46
+ }
47
+ return res;
48
+ }
49
+
50
+ boost::shared_ptr<RDKit::QueryAtom> funcname ## LessQueryAtom(type val, bool negate=false) {
51
+ boost::shared_ptr<RDKit::QueryAtom> res(new RDKit::QueryAtom());
52
+ res->setQuery(
53
+ RDKit:: ## func <RDKit::ATOM_GREATER_QUERY>(val, std::string( # funcname "Less")));
54
+ if (negate) {
55
+ res->getQuery()->setNegation(true);
56
+ }
57
+ return res;
58
+ }
59
+
60
+ boost::shared_ptr<RDKit::QueryAtom> funcname ## GreaterQueryAtom(type val, bool negate=false) {
61
+ boost::shared_ptr<RDKit::QueryAtom> res(new RDKit::QueryAtom());
62
+ res->setQuery(
63
+ RDKit:: ## func <RDKit::ATOM_LESS_QUERY>(val, std::string(# funcname "Greater")));
64
+ if (negate) {
65
+ res->getQuery()->setNegation(true);
66
+ }
67
+ return res;
68
+ }
69
+ %}
70
+ %enddef
71
+
72
+ %define QAFUNC2(funcname, func, type)
73
+ %inline %{
74
+ boost::shared_ptr<RDKit::QueryAtom> funcname(bool negate=false) {
75
+ boost::shared_ptr<RDKit::QueryAtom> res(new RDKit::QueryAtom());
76
+ res->setQuery(RDKit:: ## func());
77
+ if (negate) {
78
+ res->getQuery()->setNegation(true);
79
+ }
80
+ return res;
81
+ }
82
+ %}
83
+ %enddef
84
+
85
+ QAFUNC1(AtomNum, makeAtomNumQuery, int);
86
+ QAFUNC1(ExplicitValence, makeAtomExplicitValenceQuery, int);
87
+ QAFUNC1(TotalValence, makeAtomTotalValenceQuery, int);
88
+ QAFUNC1(ExplicitDegree, makeAtomExplicitDegreeQuery, int);
89
+ QAFUNC1(TotalDegree, makeAtomTotalDegreeQuery, int);
90
+ QAFUNC1(NonHydrogenDegree, makeAtomNonHydrogenDegreeQuery, int);
91
+ QAFUNC1(HCount, makeAtomHCountQuery, int);
92
+ QAFUNC1(Mass, makeAtomMassQuery, int);
93
+ QAFUNC1(Isotope, makeAtomIsotopeQuery, int);
94
+ QAFUNC1(FormalCharge, makeAtomFormalChargeQuery, int);
95
+ QAFUNC1(Hybridization, makeAtomHybridizationQuery, int);
96
+ QAFUNC1(InNRings, makeAtomInNRingsQuery, int);
97
+ QAFUNC1(MinRingSize, makeAtomMinRingSizeQuery, int);
98
+ QAFUNC1(RingBondCount, makeAtomRingBondCountQuery, int);
99
+ QAFUNC1(NumRadicalElectrons, makeAtomNumRadicalElectronsQuery, int);
100
+ QAFUNC1(NumHeteroatomNeighbors, makeAtomNumHeteroatomNbrsQuery, int);
101
+ QAFUNC1(NumAliphaticHeteroatomNeighbors,
102
+ makeAtomNumAliphaticHeteroatomNbrsQuery, int);
103
+
104
+ QAFUNC2(IsUnsaturatedQueryAtom, makeAtomUnsaturatedQuery, int);
105
+ QAFUNC2(IsAromaticQueryAtom, makeAtomAromaticQuery, int);
106
+ QAFUNC2(IsAliphaticQueryAtom, makeAtomAliphaticQuery, int);
107
+ QAFUNC2(IsInRingQueryAtom, makeAtomInRingQuery, int);
108
+ QAFUNC2(HasChiralTagQueryAtom, makeAtomHasChiralTagQuery, int);
109
+ QAFUNC2(MissingChiralTagQueryAtom, makeAtomMissingChiralTagQuery, int);
110
+ QAFUNC2(IsBridgeheadQueryAtom, makeAtomIsBridgeheadQuery, int);
111
+ QAFUNC2(AAtomQueryAtom, makeAAtomQuery, int);
112
+ QAFUNC2(AHAtomQueryAtom, makeAHAtomQuery, int);
113
+ QAFUNC2(QAtomQueryAtom, makeQAtomQuery, int);
114
+ QAFUNC2(QHAtomQueryAtom, makeQHAtomQuery, int);
115
+ QAFUNC2(XAtomQueryAtom, makeXAtomQuery, int);
116
+ QAFUNC2(XHAtomQueryAtom, makeXHAtomQuery, int);
117
+ QAFUNC2(MAtomQueryAtom, makeMAtomQuery, int);
118
+ QAFUNC2(MHAtomQueryAtom, makeMHAtomQuery, int);
119
+
120
+ %{
121
+
122
+ template <class Ob, class Ret, class T>
123
+ boost::shared_ptr<Ret> PropQuery(const std::string &propname, const T &v, bool negate) {
124
+ boost::shared_ptr<Ret> res(new Ret());
125
+ res->setQuery(RDKit::makePropQuery<Ob, T>(propname, v));
126
+ if (negate) {
127
+ res->getQuery()->setNegation(true);
128
+ }
129
+ return res;
130
+ }
131
+
132
+ template <class Ob, class Ret, class T>
133
+ boost::shared_ptr<Ret> PropQueryWithTol(const std::string &propname, const T &v, bool negate,
134
+ const T &tol = T()) {
135
+ boost::shared_ptr<Ret> res(new Ret());
136
+ res->setQuery(RDKit::makePropQuery<Ob, T>(propname, v, tol));
137
+ if (negate) {
138
+ res->getQuery()->setNegation(true);
139
+ }
140
+ return res;
141
+ }
142
+
143
+ template <class Ob, class Ret>
144
+ boost::shared_ptr<Ret> PropQueryWithTol(const std::string &propname, const ExplicitBitVect &v,
145
+ bool negate=false, float tol = 0.0) {
146
+ boost::shared_ptr<Ret> res(new Ret());
147
+ res->setQuery(RDKit::makePropQuery<Ob>(propname, v, tol));
148
+ if (negate) {
149
+ res->getQuery()->setNegation(true);
150
+ }
151
+ return res;
152
+ }
153
+
154
+ boost::shared_ptr<RDKit::QueryAtom> HasPropQueryAtom(const std::string &propname, bool negate=false) {
155
+ boost::shared_ptr<RDKit::QueryAtom> res(new RDKit::QueryAtom());
156
+ res->setQuery(RDKit::makeHasPropQuery<RDKit::Atom>(propname));
157
+ if (negate) {
158
+ res->getQuery()->setNegation(true);
159
+ }
160
+ return res;
161
+ }
162
+
163
+ boost::shared_ptr<RDKit::QueryAtom> HasIntPropWithValueQueryAtom(const std::string &propname, int val, bool negate=false) {
164
+ return PropQuery<RDKit::Atom, RDKit::QueryAtom, int>(propname, val, negate);
165
+ }
166
+
167
+ boost::shared_ptr<RDKit::QueryAtom> HasBoolPropWithValueQueryAtom(const std::string &propname, bool val, bool negate=false) {
168
+ return PropQuery<RDKit::Atom, RDKit::QueryAtom, bool>(propname, val, negate);
169
+ }
170
+
171
+ boost::shared_ptr<RDKit::QueryAtom> HasStringPropWithValueQueryAtom(const std::string &propname, const std::string &val, bool negate=false) {
172
+ return PropQuery<RDKit::Atom, RDKit::QueryAtom, std::string>(propname, val, negate);
173
+ }
174
+
175
+ boost::shared_ptr<RDKit::QueryAtom> HasDoublePropWithValueQueryAtom(const std::string &propname, double val, bool negate=false, double tol=0) {
176
+ return PropQueryWithTol<RDKit::Atom, RDKit::QueryAtom, double>(propname, val, negate, tol);
177
+ }
178
+
179
+ boost::shared_ptr<RDKit::QueryAtom> HasBitVectPropWithValueQueryAtom(const std::string &propname, const ExplicitBitVect &val, bool negate=false, float tol=0) {
180
+ return PropQueryWithTol<RDKit::Atom, RDKit::QueryAtom>(propname, val, negate, tol);
181
+ }
182
+
183
+ boost::shared_ptr<RDKit::QueryBond> HasPropQueryBond(const std::string &propname, bool negate=false) {
184
+ boost::shared_ptr<RDKit::QueryBond> res(new RDKit::QueryBond());
185
+ res->setQuery(RDKit::makeHasPropQuery<RDKit::Bond>(propname));
186
+ if (negate) {
187
+ res->getQuery()->setNegation(true);
188
+ }
189
+ return res;
190
+ }
191
+
192
+ boost::shared_ptr<RDKit::QueryBond> HasIntPropWithValueQueryBond(const std::string &propname, int val, bool negate=false) {
193
+ return PropQuery<RDKit::Bond, RDKit::QueryBond, int>(propname, val, negate);
194
+ }
195
+
196
+ boost::shared_ptr<RDKit::QueryBond> HasBoolPropWithValueQueryBond(const std::string &propname, bool val, bool negate=false) {
197
+ return PropQuery<RDKit::Bond, RDKit::QueryBond, bool>(propname, val, negate);
198
+ }
199
+
200
+ boost::shared_ptr<RDKit::QueryBond> HasStringPropWithValueQueryBond(const std::string &propname, const std::string &val, bool negate=false) {
201
+ return PropQuery<RDKit::Bond, RDKit::QueryBond, std::string>(propname, val, negate);
202
+ }
203
+
204
+ boost::shared_ptr<RDKit::QueryBond> HasDoublePropWithValueQueryBond(const std::string &propname, double val, bool negate=false, double tol=0) {
205
+ return PropQueryWithTol<RDKit::Bond, RDKit::QueryBond, double>(propname, val, negate, tol);
206
+ }
207
+
208
+ %}
209
+
210
+ boost::shared_ptr<RDKit::QueryAtom> HasPropQueryAtom(const std::string &propname, bool negate=false);
211
+ boost::shared_ptr<RDKit::QueryBond> HasPropQueryBond(const std::string &propname, bool negate=false);
212
+ boost::shared_ptr<RDKit::QueryAtom> HasIntPropWithValueQueryAtom(const std::string &propname, int val, bool negate=false);
213
+ boost::shared_ptr<RDKit::QueryAtom> HasBoolPropWithValueQueryAtom(const std::string &propname, bool val, bool negate=false);
214
+ boost::shared_ptr<RDKit::QueryAtom> HasStringPropWithValueQueryAtom(const std::string &propname, const std::string &val, bool negate=false);
215
+ boost::shared_ptr<RDKit::QueryAtom> HasDoublePropWithValueQueryAtom(const std::string &propname, double val, bool negate=false, double tol=0);
216
+ boost::shared_ptr<RDKit::QueryAtom> HasBitVectPropWithValueQueryAtom(const std::string &propname, const ExplicitBitVect &val, bool negate=false, float tol=0);
217
+ boost::shared_ptr<RDKit::QueryBond> HasPropQueryBond(const std::string &propname, bool negate=false);
218
+ boost::shared_ptr<RDKit::QueryBond> HasIntPropWithValueQueryBond(const std::string &propname, int val, bool negate=false);
219
+ boost::shared_ptr<RDKit::QueryBond> HasBoolPropWithValueQueryBond(const std::string &propname, bool val, bool negate=false);
220
+ boost::shared_ptr<RDKit::QueryBond> HasStringPropWithValueQueryBond(const std::string &propname, const std::string &val, bool negate=false);
221
+ boost::shared_ptr<RDKit::QueryBond> HasDoublePropWithValueQueryBond(const std::string &propname, double val, bool negate=false, double tol=0);
222
+
223
+ %extend RDKit::QueryAtom {
224
+ void ExpandQuery(const RDKit::QueryAtom *other, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true) {
225
+ PRECONDITION(other, "bad atoms");
226
+ if (other->hasQuery()) {
227
+ const RDKit::QueryAtom::QUERYATOM_QUERY *qry = other->getQuery();
228
+ ($self)->expandQuery(qry->copy(), how, maintainOrder);
229
+ }
230
+ }
231
+
232
+ void setQuery(const RDKit::QueryAtom *other) {
233
+ PRECONDITION(other, "bad atoms");
234
+ if (other->hasQuery()) {
235
+ ($self)->setQuery(other->getQuery()->copy());
236
+ }
237
+ }
238
+ }
239
+
240
+ %extend RDKit::Atom {
241
+ void ExpandQuery(const RDKit::QueryAtom *other, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true) {
242
+ PRECONDITION(other, "bad atoms");
243
+ if (other->hasQuery()) {
244
+ const RDKit::QueryAtom::QUERYATOM_QUERY *qry = other->getQuery();
245
+ ($self)->expandQuery(qry->copy(), how, maintainOrder);
246
+ }
247
+ }
248
+
249
+ void setQuery(const RDKit::QueryAtom *other) {
250
+ PRECONDITION(other, "bad atoms");
251
+ if (other->hasQuery()) {
252
+ ($self)->setQuery(other->getQuery()->copy());
253
+ }
254
+ }
255
+ }
256
+
257
+ %extend RDKit::QueryBond {
258
+ void ExpandQuery(const RDKit::QueryBond *other, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true) {
259
+ PRECONDITION(other, "bad bonds");
260
+ if (other->hasQuery()) {
261
+ const RDKit::QueryBond::QUERYBOND_QUERY *qry = other->getQuery();
262
+ ($self)->expandQuery(qry->copy(), how, maintainOrder);
263
+ }
264
+ }
265
+
266
+ void SetQuery(const RDKit::QueryBond *other) {
267
+ PRECONDITION(other, "bad bonds");
268
+ if (other->hasQuery()) {
269
+ ($self)->setQuery(other->getQuery()->copy());
270
+ }
271
+ }
272
+ }
273
+
274
+ %extend RDKit::Bond {
275
+ void ExpandQuery(const RDKit::QueryBond *other, Queries::CompositeQueryType how=Queries::COMPOSITE_AND, bool maintainOrder=true) {
276
+ PRECONDITION(other, "bad bonds");
277
+ if (other->hasQuery()) {
278
+ const RDKit::QueryBond::QUERYBOND_QUERY *qry = other->getQuery();
279
+ ($self)->expandQuery(qry->copy(), how, maintainOrder);
280
+ }
281
+ }
282
+
283
+ void SetQuery(const RDKit::QueryBond *other) {
284
+ PRECONDITION(other, "bad bonds");
285
+ if (other->hasQuery()) {
286
+ ($self)->setQuery(other->getQuery()->copy());
287
+ }
288
+ }
289
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ * $Id$
3
+ *
4
+ * Copyright (c) 2010, Novartis Institutes for BioMedical Research Inc.
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are
9
+ * met:
10
+ *
11
+ * * Redistributions of source code must retain the above copyright
12
+ * notice, this list of conditions and the following disclaimer.
13
+ * * Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials provided
16
+ * with the distribution.
17
+ * * Neither the name of Novartis Institutes for BioMedical Research Inc.
18
+ * nor the names of its contributors may be used to endorse or promote
19
+ * products derived from this software without specific prior written permission.
20
+ *
21
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+ %{
35
+ #include <GraphMol/QueryAtom.h>
36
+ %}
37
+
38
+ %ignore RDKit::QueryAtom::expandQuery;
39
+ %ignore RDKit::QueryAtom::setQuery;
40
+
41
+ %include <GraphMol/QueryAtom.h>
42
+
43
+ %extend RDKit::QueryAtom {
44
+ bool MatchAtom(RDKit::Atom const *what) {
45
+ return ($self)->Match(what);
46
+ }
47
+ }