This is my C++ code.

#include <INCHI-API/inchi.h>
#include <GraphMol/RDKitBase.h>
#include <RDGeneral/types.h>
#include <RDGeneral/RDLog.h>
#include <GraphMol/SmilesParse/SmilesParse.h>

using namespace RDKit;
using namespace std;

int main(int argc, const char * argv[])
{
    RWMol* pCurMol;
    MolGraph curTopology;
    vector<vector<int> > viiRingBonds;
    string sSmiles = "Oc1ncnnc1-c1ccccc1";
    list<boost::list_edge<unsigned long, boost::shared_ptr<Bond> >
>::const_iterator itEdge;

    pCurMol = SmilesToMol(sSmiles, 0, false);
    curTopology = pCurMol->getTopology();
    viiRingBonds = pCurMol->getRingInfo()->bondRings();
    for (itEdge = curTopology.m_edges.begin(); itEdge !=
curTopology.m_edges.end(); ++itEdge)
        if (queryIsBondInRing(itEdge->m_property.get()))
            cout<<"get one ring bond"<<endl;

    return 0;
}

It crashes in the following line

queryIsBondInRing(itEdge->m_property.get())

with the following information.

Pre-condition Violation
RingInfo not initialized
Violation occurred on line 67 in file
/Users/yingfeng/software/RDKit/rdkit-Release_2015_03_1/Code/GraphMol/RingInfo.cpp
Failed Expression: df_init
****

libc++abi.dylib: terminating with uncaught exception of type
Invar::Invariant: Pre-condition Violation


Actually, the corresponding python version works.

>>> from rdkit import Chem
>>> sSmiles = "Oc1ncnnc1-c1ccccc1"
>>> curMol =Chem.MolFromSmiles(sSmiles, False)
>>> iBondsNum = curMol.GetNumBonds()
>>> for i in range(iBondsNum):
...     current_bond = curMol.GetBondWithIdx(i)
...     if current_bond.IsInRing():
...             print i
...
1
2
3
4
5
7
8
9
10
11
12
13


Please note that the problem cannot be solved by using
SmilesToMol(sSmiles, 0, true);

because it may cause other problems, e.g.,
string sSmiles = "c.ccccc";
Therefore, I would like to stay with SmilesToMol(sSmiles, 0, false);

Could you please give me some hints for fixing the C++ version, and getting
the similar results of the python version.
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to