mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
additional functionality required by the knime nodes
This commit is contained in:
@@ -43,7 +43,8 @@
|
||||
|
||||
%include <GraphMol/ChemReactions/Reaction.h>
|
||||
%include <GraphMol/ChemReactions/ReactionParser.h>
|
||||
%ignore RDKit::ChemicalReaction::validate;
|
||||
%ignore RDKit::ChemicalReaction::validate(unsigned int &,unsigned int &,bool);
|
||||
%ignore RDKit::ChemicalReaction::validate(unsigned int &,unsigned int &);
|
||||
|
||||
%extend RDKit::ChemicalReaction {
|
||||
static RDKit::ChemicalReaction *ReactionFromSmarts(std::string sma){
|
||||
@@ -100,7 +101,7 @@ static RDKit::ChemicalReaction *RxnFromBinary(std::vector<int> pkl){
|
||||
};
|
||||
|
||||
/* A Java-accessible validation function */
|
||||
std::pair<int,int> *Validate(bool silent=false) {
|
||||
std::pair<int,int> *validateReaction(bool silent=false) {
|
||||
std::pair<int,int> *res = new std::pair<int,int>();
|
||||
// Use some local unsigned ints so that we don't create a new and useless type at the Java
|
||||
// level.
|
||||
@@ -110,6 +111,12 @@ static RDKit::ChemicalReaction *RxnFromBinary(std::vector<int> pkl){
|
||||
res->first = (int) first;
|
||||
res->second = (int) second;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
bool validate() {
|
||||
unsigned int nErr=0,nWarn=0;
|
||||
bool res=$self->validate(nErr,nWarn);
|
||||
return res;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -48,6 +48,8 @@ SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(UInt_Pair_Vect, std::vector< std::pair<unsign
|
||||
|
||||
%newobject RDKit::MorganFingerprints::getFingerprint;
|
||||
%rename(MorganFingerprintMol) RDKit::MorganFingerprints::getFingerprint;
|
||||
%newobject RDKit::MorganFingerprints::getFingerprintAsBitVect;
|
||||
%rename(getMorganFingerprintAsBitVect) RDKit::MorganFingerprints::getFingerprintAsBitVect;
|
||||
%include <GraphMol/Fingerprints/MorganFingerprints.h>
|
||||
|
||||
%include <DataStructs/BitOps.h>
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include <GraphMol/DistGeomHelpers/Embedder.h>
|
||||
#include <GraphMol/DistGeomHelpers/BoundsMatrixBuilder.h>
|
||||
#include <GraphMol/MolAlign/AlignMolecules.h>
|
||||
#include "Depict.h"
|
||||
%}
|
||||
|
||||
%template(ROMol_Vect) std::vector< boost::shared_ptr<RDKit::ROMol> >;
|
||||
@@ -212,6 +213,25 @@
|
||||
permuteDeg4Nodes);
|
||||
}
|
||||
|
||||
unsigned int compute2DCoords(RDKit::ROMol &templ){
|
||||
RDKit::MatchVectType matchVect;
|
||||
if(templ.getNumConformers() && SubstructMatch(*($self),templ,matchVect)){
|
||||
RDGeom::INT_POINT2D_MAP coordMap;
|
||||
RDKit::Conformer conf=templ.getConformer();
|
||||
for(RDKit::MatchVectType::const_iterator iter=matchVect.begin();
|
||||
iter!=matchVect.end();++iter){
|
||||
RDGeom::Point2D pt;
|
||||
pt.x = conf.getAtomPos(iter->first).x;
|
||||
pt.y = conf.getAtomPos(iter->first).y;
|
||||
coordMap[iter->second]=pt;
|
||||
}
|
||||
return RDDepict::compute2DCoords(*($self),&coordMap);
|
||||
} else {
|
||||
return RDDepict::compute2DCoords(*($self),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned int compute2DCoordsMimicDistMat(const RDDepict::DOUBLE_SMART_PTR *dmat=0,
|
||||
bool canonOrient=true,
|
||||
bool clearConfs=true,
|
||||
@@ -336,3 +356,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
%extend RDKit::ROMol {
|
||||
std::string ToSVG(int lineWidthMult=2,int fontSize=50){
|
||||
if(lineWidthMult<0) lineWidthMult *=2;
|
||||
if(fontSize<0) fontSize*=2;
|
||||
std::vector<int> drawing=MolToDrawing(*($self),0);
|
||||
std::string svg=DrawingToSVG(drawing,lineWidthMult,fontSize);
|
||||
return svg;
|
||||
}
|
||||
std::string ToSVG(const std::vector<int> &highlightAtoms,
|
||||
int lineWidthMult=2,int fontSize=50){
|
||||
if(lineWidthMult<0) lineWidthMult *=2;
|
||||
if(fontSize<0) fontSize*=2;
|
||||
std::vector<int> drawing=MolToDrawing(*($self),&highlightAtoms);
|
||||
std::string svg=DrawingToSVG(drawing,lineWidthMult,fontSize);
|
||||
return svg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ INCLUDE_DIRECTORIES(${JNI_INCLUDE_DIRS})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(GraphMolJava.i PROPERTIES CPLUSPLUS ON )
|
||||
|
||||
|
||||
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../*.java COPY_SOURCE)
|
||||
FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/org/RDKit COPY_DEST)
|
||||
|
||||
# Setup a few variables for environment-specific things
|
||||
if(WIN32)
|
||||
ADD_DEFINITIONS("/W3 /wd4716")
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
/* Include the base types before anything that will utilize them */
|
||||
%include "stdint.i"
|
||||
%include "std_string.i"
|
||||
%include "std_list.i"
|
||||
%include "std_vector.i"
|
||||
%include "std_map.i"
|
||||
%include "std_pair.i"
|
||||
@@ -173,6 +174,8 @@ typedef unsigned long long int uintmax_t;
|
||||
%include "../transforms.i"
|
||||
%include "../DistGeom.i"
|
||||
%include "../ForceField.i"
|
||||
%include "../ChemTransforms.i"
|
||||
%include "../Subgraphs.i"
|
||||
|
||||
// Create a class to throw various sorts of errors for testing. Required for unit tests in ErrorHandlingTests.java
|
||||
#ifdef INCLUDE_ERROR_GENERATOR
|
||||
@@ -207,6 +210,7 @@ typedef unsigned long long int uintmax_t;
|
||||
%template(Int_Int_Map) std::map<int,int>;
|
||||
%template(Int_Point2D_Map) std::map<int, RDGeom::Point2D>;
|
||||
%template(Int_Point3D_Map) std::map<int, RDGeom::Point3D>;
|
||||
%template(Int_Int_Vect_List_Map) std::map<int,std::list<std::vector<int> > >;
|
||||
|
||||
/* vector pair */
|
||||
%template(UInt_Pair_Vect) std::vector<std::pair<boost::uint32_t,int> >;
|
||||
@@ -216,6 +220,10 @@ typedef unsigned long long int uintmax_t;
|
||||
/* vector vector */
|
||||
%template(Int_Vect_Vect) std::vector<std::vector<int> >;
|
||||
|
||||
/* list */
|
||||
%template(Int_Vect_List) std::list<std::vector<int> >;
|
||||
|
||||
|
||||
/* other */
|
||||
%template(Match_Vect_Vect) std::vector<std::vector<std::pair<int,int> > >;
|
||||
%template(Flagged_Atomic_Params_Vect) std::pair<std::vector<const ForceFields::UFF::AtomicParams *>,bool>;
|
||||
|
||||
@@ -291,13 +291,13 @@ public class ChemReactionTests extends GraphMolTest {
|
||||
public void test5Validation() {
|
||||
ChemicalReaction rxn = ChemicalReaction.ReactionFromSmarts("[C:1](=[O:2])O.[N:3]>>[C:1](=[O:2])[N:3]");
|
||||
assertNotNull(rxn);
|
||||
Int_Pair validationResults = rxn.Validate();
|
||||
Int_Pair validationResults = rxn.validateReaction();
|
||||
assertEquals(0, validationResults.getFirst());
|
||||
assertEquals(0, validationResults.getSecond());
|
||||
|
||||
rxn = ChemicalReaction.ReactionFromSmarts("[C:1](=[O:1])O.[N:3]>>[C:1](=[O:2])[N:3]");
|
||||
assertNotNull(rxn);
|
||||
validationResults = rxn.Validate();
|
||||
validationResults = rxn.validateReaction();
|
||||
assertEquals(0, validationResults.getFirst());
|
||||
assertEquals(2, validationResults.getSecond());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user