TopologyAnalyser stereoDoubleBondCount

User 73531e86ff

12-03-2009 12:48:29

Hi,





I'm writing a function which calulates the number of chiral atoms and number of stereo double bonds. I was able to use the TopologyAnalyser for the chiral atoms successfully. However, I had some issue with the stereoDoubleBondCount function - i'm not sure if it is a bug or as designed.





Basically, if the input smiles does not define the cis/trans state of the double bond it is not included in the count.





e.g. CC=CC gives 0 whereas C/C=C/C gives 1








My workaround was to firstly calculate the 2D coordinates and then search for "squiggly" bonds. Please let me know if there is a better way to do this - I expect calculating the 2D coordinates is not the most efficient. My existing code is below:








Code:
 


  public int stereoDoubleBondCount(Molecule molecule) {


    int count = 0;


    molecule.clean( 2, "" );


    for( final MolBond bond : molecule.getBondArray() ) {


      count += isDoubleBondStereo(bond) ? 1 : 0;


    }


    return count;


  }





  private boolean isDoubleBondStereo( MolBond bond ) {





    if( bond.getType() == 2 ) {


      final int bondStereo = bond.getFlags() & MolBond.CTUMASK;


      if( (bondStereo & ( MolBond.CIS | MolBond.TRANS ) ) != 0 ) {


        return true;


      } else {


        for( final MolAtom atom : Arrays.asList( bond.getAtom1(), bond.getAtom2() ) ) {


          for( int i=0; i


            final int outerBondStereo = atom.getBond(i).getFlags() & MolBond.STEREO1_MASK;


            if( ( outerBondStereo & ( MolBond.UP | MolBond.DOWN )) != 0) {


              return true;


            }


          }


        }


      }


    }


    return false;





  }








Cheers,


Shane

ChemAxon e08c317633

13-03-2009 23:12:27

Hi,





TopologyAnalyser.stereoDoubleBondCount() returns the sum of cis and trans double bonds in the molecule.





As I understand, you want to count all double bonds that can be stereo double bonds (C=C shoud give 0, while CC=CC shoud give 1). The following methods could help:





http://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/struc/MoleculeGraph.html#canBeCT(int, int)





http://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/struc/MolBond.html#calcStereo2()





Regards,


Zsolt

ChemAxon 25dcd765a3

16-03-2009 09:20:26

Hi,





As Zsolt suggested you can simply run through the double bonds and check whether the double bond can be Cis/Trans stereo using MoleculeGraph.canBeCT(int i2, int i3) or MoleculeGraph.canBeCT(int i2, int i3, boolean grcheck).





The first method equals the second method with parameter grcheck true. The grcheck parameter specifies if the method should return true for double bonds which have same ligands on one end of the double bond. Eg for molecule CC=C(C)C canBeCT with grcheck false (not checking atom equivalences for ligands) returns true, while canBeCT with grcheck true (checking atom equivalences for ligands) returns false (as the two Carbon atoms are equivalent on the second atom of the double bond).








Andras

User 73531e86ff

16-03-2009 12:55:39

Hi,





Thanks for alerting me to this function.  My tests now pass without having to generate the 2D coordinates.  My new code is below, however, notice I needed the call to isRingBond as this function was returning true for double bonds in rings that didn't need to be marked as cis/trans (maybe it's worth adding this to your javadoc).  I'll also need to run my function on a larger test set as I'm sure that some larger rings can have cis/trans double bond properties.





Code:



  public int count() {


    int count = 0;


    for (final MolBond bond : mol.getBondArray()) {


      count += isDoubleBondStereo(bond) ? 1 : 0;


    }


    return count;


  }





  private boolean isDoubleBondStereo(MolBond bond) {





    final int a1 = mol.indexOf( bond.getAtom1() );


    final int a2 = mol.indexOf( bond.getAtom2() );


    final int b = mol.indexOf( bond );





    if (bond.getType() == 2 && !mol.isRingBond(b) && mol.canBeCT(a1, a2, true) ) {


      return true;


    }


    return false;





  }








Cheers,


Shane

ChemAxon 25dcd765a3

16-03-2009 14:43:58

Hi,





You are right. The canBeCT method does not differentiate ring bonds and non-ring bonds.








I would suggest to check the ring sizes before checking Cis/Trans information.








Code:
public int count() {





  // determine which ring bond can be CT specific


  boolean[] ringNonCT = new boolean[m.getBondCount()];


  int[][] sssr = m.getSSSR();


  for (int i = 0; i < sssr.length; i++) {


    int[] sr = sssr;


    int size = sr.length;


    if (size < MoleculeGraph.MIN_RING_SIZE_FOR_TRANS_DB) {


      int h, n;


      for (int ib = 0; ib < siz; ib++) {


        h = sr[ib];


        n = sr[(ib+1)%size] ;


        int idx = btab[h][n];


        // this bond cannot be CT


        ringNonCT[idx] = true;


      }


    }


  }





  // check bonds (using your code)


  int count = 0;


  for (int i = 0; i < m.getBondCount(); i++){


    final MolBond bond = mol.getBond(i);


    count += (!ringNonCT[idx] && isDoubleBondStereo(bond)) ? 1 : 0;





  }





  return count;





}








// later private boolean isDoubleBondStereo(MolBond bond) method should not


// check if the bond is ring as we have checked it already





















I hope this helps








Andras

User 73531e86ff

17-03-2009 13:09:02

Hi, 





Thanks for the example - I have implemented it and will let you know if we have any problems when we get down to more extensive testing.





Cheers,





Shane

ChemAxon 25dcd765a3

17-03-2009 17:01:21

OK, please let me know if you have any problem, or if it is successfully pass the tests.





Andras