Hello Guillaume,
you have a vector of unsigned int "SparseIntVect<boost::uint32_t>” which is a
vector of unsigned int.
Looking at the C++ public member function you can find “getVal(int index)”
which give to you the correspondent bit as integer value.
So, you can iterate and convert to a string using stringstream.
Second things… is better to use getHashedFingerprint to have a limited size of
fingerprint (2048 bit).
Here the fully woking example.
/******* START C++ CODE ******/
#include <GraphMol/FileParsers/MolSupplier.h>
#include <RDGeneral/RDLog.h>
#include <GraphMol/RDKitBase.h>
#include <DataStructs/SparseIntVect.h>
#include <GraphMol/Fingerprints/MorganFingerprints.h>
#include <sstream>
int main(int argc, char *argv[])
{
RDKit::SmilesMolSupplier supplier(argv[1], " \t", 0, 1, false, true);
RDKit::ROMol* mol;
while (!supplier.atEnd()){
mol = new RDKit::ROMol;
mol = supplier.next();
if (mol){
RDKit::SparseIntVect<boost::uint32_t> *finger =
RDKit::MorganFingerprints::getHashedFingerprint((*mol), 2);
std::stringstream out;
for(uint i = 0; i < finger->size(); i++){
out << finger->getVal(i);
}
std::cout << out.str() << std::endl;
delete finger;
}
delete mol;
mol = NULL;
}
}
/******* END C++ CODE ******/
/******** START CMakeListst.txt ********/
project(examplerdkit)
cmake_minimum_required(VERSION 3.0)
include_directories(${RDKIT_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
add_executable(test1 main.cpp)
target_link_libraries(test1 ${RDKIT_LIBRARIES})
/******** END CMakeListst.txt ********/
To compile:
mkdir build
cd build
export RDLIB="/usr/local/lib/“;
cmake .. -DRDKIT_INCLUDE_DIR=/usr/local/include/rdkit
-DBoost_INCLUDE_DIR=/usr/local/include/boost/
-DRDKIT_LIBRARIES="${RDLIB}/libRDGeometryLib.dylib;${RDLIB}/libDepictor.dylib;${RDLIB}/libSmilesParse.dylib;$RDLIB/libGraphMol.dylib;${RDLIB}/libRDGeneral.dylib;${RDLIB}/libFileParsers.dylib;${RDLIB}/libFingerprints.dylib”
make
to use
echo "N1C=NC2=C1C(=O)N(C(=O)N2C)C caffeina” >> caffeina.smi
./test1 caffena.smi
output:
./test1 caffeina.smi
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000100000000000000000000000000010000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000001000000000000000000000000000000000001000000000000000000000000000000002100000000000000000000000000000000000000000000000000000001000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Best regards,
Marco
> On 11 May 2015, at 16:11, Guillaume GODIN <[email protected]>
> wrote:
>
> Dear Greg,
>
> Sorry, I forget that link point.
>
> So emscripten now see the fingerprint,
>
> how to convert it on a readable format like base64 or a string... ?
>
> Best regards,
>
> Guillaume
>
>
>
>
>
> Hi,
>
> Are you sure that you have included the Fingerprints library in the link
> statement?
>
>
> In the future please direct RDKit questions like this to the rdkit-discuss
> mailing list. You can find subscription info here:
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
> <https://lists.sourceforge.net/lists/listinfo/rdkit-discuss>
>
> -greg
>
>
> Dear Gregory Landrum,
>
> I started to build rdkit 2004_09 wrap to javascript using emscripten.
>
> I was able to expose all your descriptors in a string and see it in a browser.
>
> But, I have trouble to expose the fingerprint, it's look like there is a
> missing piece in the c++ implementation.
>
> When I try to compile this part of my code I have the following issue:
>
> SparseIntVect<boost::uint32_t> *finger;
>
> finger = MorganFingerprints::getFingerprint(*mol, 2);
>
> the compiler don't find the linking to your c++ code: warning: unresolved
> symbol:
> _ZN5RDKit18MorganFingerprints14getFingerprintERKNS_5ROMolEjPNSt3__16vectorIjNS4_9allocatorIjEEEEPKS8_bbbbPNS4_3mapIjNS5_INS4_4pairIjjEENS6_ISE_EEEENS4_4lessIjEENS6_INSD_IKjSG_EEEEEE
>
> Did you have any advise to determine where I can find this ?
>
> best regards,
>
> Dr. Guillaume GODIN
>
> Project Manager
>
> Innovation
>
> CORPORATE R&D DIVISION
>
> DIRECTLINE +41 (0)22 780 3645
>
> MOBILE +41 (0)79 536 1039
>
> Firmenich SA
>
> RUE DES JEUNES 1 | CASE POSTALE 239 | CH-1211 GENEVE 8
>
>
>
> **********************************************************************
> DISCLAIMER
> This email and any files transmitted with it, including replies and forwarded
> copies (which may contain alterations) subsequently transmitted from
> Firmenich, are confidential and solely for the use of the intended recipient.
> The contents do not represent the opinion of Firmenich except to the extent
> that it relates to their official business.
> **********************************************************************
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
>
> <http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________>
> Rdkit-discuss mailing list
> [email protected]
> <mailto:[email protected]>
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
> <https://lists.sourceforge.net/lists/listinfo/rdkit-discuss>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss