#209 MFAnalyser.removeHydrogens() can "disconnect" molecules

closed
5
2012-10-08
2004-05-12
No

G'day,

I'm not a chemist but I know someone who is (my boss),
so excuse me if I've made a chemical blunder here...

We are using

ac = new MFAnalyser(ac).removeHydrogens();
HydrogenAdder().addImplicitHydrogensToSatisfyValency(ac);

to render all hydrogens implicitly in a Renderer2D. In
general, this works well. However, for some exotic
molecules that have hydrogens bound to multiple atoms
(e.g. boranes) then removeHydrogens() disconnects the
molecule and gets the hydrogenCount wrong (e.g. B2H6
becomes two separate BH3).

Attached is a patch for this problem that

1) adds a new private method
MFAnalyser.removeHydrogens(List preserve) that allows
you to remove hydrogens except those passed in the
perserve List. It also gets the hydrogenCount correct.

2) MFAnalyser.removeHydrogens() simply calls
MFAnalyser.removeHydrogens(new ArrayList()).

3) adds a new public method
MFAnalyser().removeHydrogensPreserveMultiplyBonded()
that calls MFAnalyser.removeHydrogens(mulitple_h),
where multiple_h are the hydrogen atoms bound to
multiple atoms.

To apply the patch

%> cd cdk-source-20040324
%> patch -p1 < MFAnalyser.removeHydrogens_patch.diff

This fixes the problem and all jUnit tests pass.

Regards,
Chris.

Discussion

  • Egon Willighagen

    Logged In: YES
    user_id=25678

    Chris, thanx for all these patches. Could you also make a
    new JUnit test, that tests these new methods? This serves
    two purposes: it's a good example on how to use to code
    and in which occassions, and it makes sure that these
    methods do not get broken later...

     
  • Chris Pudney

    Chris Pudney - 2004-05-14

    Logged In: YES
    user_id=624072

    G'day,

    Two new jUnit tests:

    1. MFAnalyserTest.testRemoveHydrogensBorane() tests
      MFAnalyser.removeHydrogens() for the case of B2H6, which
      includes two multiply bonded H (should get two disconnect BH4s)

    2.
    MFAnalyserTest.testRemoveHydrogensPreserveMulitplyBondedBorane()
    tests MFAnalyser.removeHydrogensPreserveMultiplyBonded() for
    the case of B2H6, which includes two multiply bonded H
    (should remove all four singly bonded Hs and set
    hydrogenCount of the Bs to two - multiply bonded Hs should
    not be removed).

    To apply the patch

    %> cd cdk-source-20040324
    %> patch -p1 < MFAnalyserTest_patch.diff

    Regards,
    Chris.

     
  • Egon Willighagen

    Logged In: YES
    user_id=25678

    Ok, thanx once more. I've applied the patches to CVS just after the
    May release. I've put your name on cdk.sf.net/intro.html; is that ok?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks