Hi All,
As I've been transliterating the GettingStartedInPython to
GettingStartedInC++, I've noticed that you get different default behaviour
from Kekulize in the two languages:
m = Chem.MolFromSmiles('c1ccccc1')
print( 'Order : {}'.format( m.GetBondWithIdx(0).GetBondType() ) )
print( 'Aromatic : {}'.format( m.GetBondWithIdx(0).GetIsAromatic() ) )
Chem.Kekulize(m)
print( 'After default Kekulize : Aromatic : {}'.format(
m.GetBondWithIdx(0).GetIsAromatic() ) )
m1 = Chem.MolFromSmiles('c1ccccc1')
Chem.Kekulize(m1 , clearAromaticFlags=False )
print( 'After Kekulize, clearAromaticFlags False : Aromatic : {}'.format(
m1.GetBondWithIdx(0).GetIsAromatic() ) )
m2 = Chem.MolFromSmiles('c1ccccc1')
Chem.Kekulize(m2 , clearAromaticFlags=True )
print( 'After Kekulize, clearAromaticFlags True : Aromatic : {}'.format(
m2.GetBondWithIdx(0).GetIsAromatic() ) )
gives
Order : AROMATIC
Aromatic : True
After default Kekulize : Aromatic : True
After Kekulize, clearAromaticFlags False : Aromatic : True
After Kekulize, clearAromaticFlags True : Aromatic : False
Whereas the corresponding C++
RDKit::RWMOL_SPTR mol( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1" )
) );
std::cout << "Order : " << mol->getBondWithIdx( 0 )->getBondType() <<
std::endl;
std::cout << "Aromatic : " << mol->getBondWithIdx( 0 )->getIsAromatic()
<< std::endl;
RDKit::MolOps::Kekulize( *mol );
std::cout << "After default Kekulize : Aromatic : " <<
mol->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
RDKit::RWMOL_SPTR mol1( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1"
) ) );
RDKit::MolOps::Kekulize( *mol1 , false );
std::cout << "After Kekulize, markAtomsBonds false : Aromatic : " <<
mol1->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
RDKit::RWMOL_SPTR mol2( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1"
) ) );
RDKit::MolOps::Kekulize( *mol2 , true );
std::cout << "After Kekulize, markAtomsBonds true : Aromatic : " <<
mol2->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
gives
Order : 12
Aromatic : 1
After default Kekulize : Aromatic : 0
After Kekulize, markAtomsBonds false : Aromatic : 1
After Kekulize, markAtomsBonds true : Aromatic : 0
I.e. by default the Python version clears the Aromatic flags on the bonds,
the C++ doesn't. That seemed sufficiently anomalous to point out and
consider whether they should be unified. Although there's a strong
possibility that that would be a breaking change for people's code.
I attach the full program files for the two versions if you want to
reproduce it. This is on a recent pull of the github code
(e9af48ffd77c5a219a1671a63704aa815c08b348)
//
// Modifying molecules example9.cpp
#include <iostream>
#include <GraphMol/GraphMol.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/MolOps.h>
int main( int argc , char **argv ) {
RDKit::RWMOL_SPTR mol( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1" ) ) );
std::cout << "Order : " << mol->getBondWithIdx( 0 )->getBondType() << std::endl;
std::cout << "Aromatic : " << mol->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
RDKit::MolOps::Kekulize( *mol );
std::cout << "After default Kekulize : Aromatic : " << mol->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
RDKit::RWMOL_SPTR mol1( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1" ) ) );
RDKit::MolOps::Kekulize( *mol1 , false );
std::cout << "After Kekulize, markAtomsBonds false : Aromatic : " << mol1->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
RDKit::RWMOL_SPTR mol2( new RDKit::RWMol( *RDKit::SmilesToMol( "c1ccccc1" ) ) );
RDKit::MolOps::Kekulize( *mol2 , true );
std::cout << "After Kekulize, markAtomsBonds true : Aromatic : " << mol2->getBondWithIdx( 0 )->getIsAromatic() << std::endl;
}
#!/usr/bin/env python
from rdkit import Chem
m = Chem.MolFromSmiles('c1ccccc1')
print( 'Order : {}'.format( m.GetBondWithIdx(0).GetBondType() ) )
print( 'Aromatic : {}'.format( m.GetBondWithIdx(0).GetIsAromatic() ) )
Chem.Kekulize(m)
print( 'After default Kekulize : Aromatic : {}'.format( m.GetBondWithIdx(0).GetIsAromatic() ) )
m1 = Chem.MolFromSmiles('c1ccccc1')
Chem.Kekulize(m1 , clearAromaticFlags=False )
print( 'After Kekulize, clearAromaticFlags False : Aromatic : {}'.format( m1.GetBondWithIdx(0).GetIsAromatic() ) )
m2 = Chem.MolFromSmiles('c1ccccc1')
Chem.Kekulize(m2 , clearAromaticFlags=True )
print( 'After Kekulize, clearAromaticFlags True : Aromatic : {}'.format( m2.GetBondWithIdx(0).GetIsAromatic() ) )
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss