MolComparator question

User 870ab5b546

26-04-2013 19:04:33

I thought I would write a MolComparator that enforced the direction of coordinate bonds.  I wrote the following code:


    public boolean compareBonds(int queryBondNum, int targetBondNum) {
boolean match = true;
final MolBond queryBond = query.getBond(getOrigQueryBond(queryBondNum));
final MolBond targetBond =
target.getBond(getOrigTargetBond(targetBondNum));
if (queryBond.getType() == MolBond.COORDINATE
&& targetBond.getType() == MolBond.COORDINATE) {
final String SELF = "CoordBondDirnMatcher.compareBonds: ";
final MolAtom queryAtom1 = queryBond.getAtom1();
final MolAtom targetAtom1 = targetBond.getAtom1();
final int qAtom1Num = query.indexOf(queryAtom1);
final int tAtom1Num = target.indexOf(targetAtom1);
match = queryAtom1.getAtno() == targetAtom1.getAtno()
&& queryAtom1.getCharge() == targetAtom1.getCharge()
&& queryAtom1.getRadical() == targetAtom1.getRadical()
&& queryAtom1.getMassno() == targetAtom1.getMassno()
&& queryAtom1.getBondCount() == targetAtom1.getBondCount();
} // if either bond is not coordinate
return match;
} // compareBonds(int, int)

As you can see, I am using atomic number, charge, etc. as a proxy for the atoms matching, but really, I would like to see if queryAtom1 and targetAtom1 match according to the overall match in the structure.  Is there a way to do it?

ChemAxon d9cc14700b

29-04-2013 10:28:35

Hi Bob,


This solution works fine for bonds between different atoms. If you would like to generalize it then you will have to override MolComparator#compareHit(int[], int). Let me know if you need further assistance.


Best Regards,
Gabor

User 870ab5b546

29-04-2013 12:56:52

Thanks.  Instead of trying to figure out how to write the MolComparator, I just decided to convert all coordinate bonds A->B into regular single bonds with formal charges, +A-B.  That solves the problem.