mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
Allow Java to see RGroup labels in the std::map wrapper. (#2681)
This commit is contained in:
committed by
Greg Landrum
parent
bb3bdb01ea
commit
47264fe727
@@ -11,13 +11,37 @@
|
||||
*/
|
||||
%{
|
||||
#include <GraphMol/RGroupDecomposition/RGroupDecomp.h>
|
||||
typedef std::vector<std::string> STR_VECT;
|
||||
%}
|
||||
|
||||
%template(SparseIntVect64) RDKit::SparseIntVect<boost::int64_t>;
|
||||
|
||||
|
||||
%template(StringMolMap) std::map<std::string, boost::shared_ptr<RDKit::ROMol>>;
|
||||
%template(ROMol_Vect) std::vector<boost::shared_ptr<RDKit::ROMol>>;
|
||||
%template(StringMolMap_Vect) std::vector<std::map<std::string, boost::shared_ptr<RDKit::ROMol>>>;
|
||||
%template(StringROMol_VectMap) std::map<std::string,std::vector<boost::shared_ptr<RDKit::ROMol>>>;
|
||||
|
||||
|
||||
%extend std::map<std::string, boost::shared_ptr<RDKit::ROMol>> {
|
||||
std::vector<std::string> keys() {
|
||||
std::vector<std::string> _keys;
|
||||
for(auto it : *self) {
|
||||
std::cerr << "* '" << it.first << "'" << std::endl;
|
||||
_keys.push_back(it.first);
|
||||
}
|
||||
return _keys;
|
||||
}
|
||||
}
|
||||
|
||||
%extend std::map<std::string,std::vector<boost::shared_ptr<RDKit::ROMol>>> {
|
||||
std::vector<std::string> keys() {
|
||||
std::vector<std::string> _keys;
|
||||
for(auto it : *self) {
|
||||
_keys.push_back(it.first);
|
||||
}
|
||||
return _keys;
|
||||
}
|
||||
}
|
||||
|
||||
%include <GraphMol/RGroupDecomposition/RGroupDecomp.h>
|
||||
|
||||
@@ -30,7 +30,16 @@ public class RGroupDecompositionTests extends GraphMolTest {
|
||||
m = RWMol.MolFromSmiles("c1c(Cl)cccc1");
|
||||
assertEquals(1,decomp.add(m));
|
||||
assertTrue(decomp.process());
|
||||
Str_Vect keys = decomp.getRGroupsAsColumns().keys();
|
||||
assertTrue(keys.size() == 2);
|
||||
assertTrue(keys.get(0).equals("Core"));
|
||||
assertTrue(keys.get(1).equals("R1"));
|
||||
|
||||
Str_Vect keys2 = decomp.getRGroupLabels();
|
||||
assertTrue(keys2.size() == 2);
|
||||
assertTrue(keys2.get(0).equals("Core"));
|
||||
assertTrue(keys2.get(1).equals("R1"));
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
Reference in New Issue
Block a user