Not sure if it will help, but the python version of IsInRing checks to see
if the sssr is initialized.  Here is the C++ code that is used, you may be
able to adapt it to your needs:

bool BondIsInRing(const Bond *bond) {
  if (!bond->getOwningMol().getRingInfo()->isInitialized()) {
    MolOps::findSSSR(bond->getOwningMol());
  }
  return bond->getOwningMol().getRingInfo()->numBondRings(bond->getIdx())
!= 0;
}


On Wed, Apr 13, 2016 at 11:59 AM, Yingfeng Wang <ywang...@gmail.com> wrote:

> Paolo,
>
> Thanks. As I mentioned in the end of my question, setting this flag true
> may cause other problems. In the python version, the sanitize flag is also
> false, but it works. Is it possible to figure out a workaround for checking
> whether each bond is in a ring in the C++ version?
>
> Best,
> Yingfeng
>
> On Wed, Apr 13, 2016 at 11:53 AM, Paolo Tosco <paolo.to...@unito.it>
> wrote:
>
>> Dear Yingfeng,
>>
>> the reason why RingInfo is not initialized is that you are invoking
>> SmilesToMol() with the sanitize flag set to false; setting that parameter
>> to true in the SmilesToMol() call should fix your problem.
>>
>> Kind regards,
>> Paolo
>>
>>
>> On 4/13/2016 16:48, Yingfeng Wang wrote:
>>
>> 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 
>> listRdkit-discuss@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>>
>
>
> ------------------------------------------------------------------------------
> 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
>
>
------------------------------------------------------------------------------
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