Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#564 Cloning of stereo elements (bug:1264)

Accepted
closed
None
cdk-1.4.x
1
2012-11-06
2012-11-01
John May
No

Patch for: https://sourceforge.net/p/cdk/bugs/1264/

This patch adds shallow and deep cloning of stereo-elements on atom containers and its subclasses. There was a couple of things I spotted as I was going along and so I patched these also.

All code is on stereo-element-cloning and some have sizeable commit messages but i'll step through the commits here also.

  • removed redundant code from addBond() bug/1271 commit

  • removed print to standard out from builders commit

  • spotted a potential bug in double bond stereo element - bug/1273commit

  • added removal of stereo-elements in AtomContainer.removeAllElements() bug/1270commit

  • removed redundant code from ChemObject.clone - a chunk could be replaced with standard collections API commit

  • unit tests for how we expect the cloning to hand tetrahedral, atom parity and double bond elements commit commit2

  • added a new method on AtomContainer - setStereoElements() this was required because when the original container is cloned the list is only a shallow copy and we need make sure the old elements are changed when we modified the clone. A unit test were also added. commit

  • [large] reworked the atom container clone method to be more readable - it also now used
    maps to convert between the original and cloned atoms without using a linear search for the index of the atom in the original. commit

  • [large] added and implemented a new method on stereo elements - the method allows us to map between one stereo element instance and another by providing a mapping of atoms and bonds. Unit tests were added for corner cases including how null should be handled commit

  • added shallow copy of stereo elements commit

  • added deep copy of stereo elements - this utilises the new map method on stereo elements commit

  • [large] rounding it all off with some non-destructive API changes - using return covariance we can return the correct type from a clone and thus eliminate the client side case :-) - commit

Most of the changes are quite straight forward but a couple are fairly large which I've indicated in the list above. I've tried to organise stuff to be easy to follow in the history but there might be some stuff out of order.

Thanks,
J

https://github.com/johnmay/cdk/commit/88a2bb249de6ee787c9b174e8c7a9f35868e8dc0

Discussion

  • I'm on it...

     
    • assigned_to: Egon Willighagen
    • branch: master --> cdk-1.4.x
     
  • John May
    John May
    2012-11-04

    patches have been applied egonw/cdk-1.4.x

     
    Last edit: John May 2012-11-04
  • John May
    John May
    2012-11-04

    If there is no more issues - can be closed.

     
    • status: open --> closed
    • milestone: Needs_Review --> Accepted