I'm not sure if this has been discussed or suggested before but it would be really nice to have a circular reference from IAtom back to it's parent IAtomContainer. Working with other libraries that do provide this reference (such as CML) makes it really intuitive when manipulating molecules. If you have a method which matches two atoms (but requires the container to work out certain properties) you can make the method a lot more readable and generally reduce the number of times you need to pass a container and an atom as arguments.
match(IAtom query, IAtom subject)
match(IAtomContainer query, IAtom queryAtom, IAtomContainer subject, IAtom subjectAtom)
In my opinion it would also open up possibilities of making methods a lot more usable (and OO). There's more then a few methods in IAtomContainer that take an atom index or object as input which could be inverted to be members of IAtom. Imagine be able to do this whilst iterating of atoms:
atom.getConnectedAtoms() // bonds also
atom.getConnectedAtomsCount() // bonds also
atom.getBondOrderSum() // would actually work (currently it is a settable field)!
It should be relatively easy to do by adding an intercept when atoms are added/removed to reference/un-reference a the parent container. I know from past experiences that languages like Perl 5 mean you need to do a bit of extra work (i.e. weaken(x) the references ) but in Java I'm not aware of any such problems, the GC can definitely handle it.
Anyways, I would like to hear thoughts on this. I can whip up a quick patch if needed to demonstrate.
| Predoctoral Student – Chemoinformatics and Metabolism
European Bioinformatics Institute, Wellcome Trust Genome Campus, Hinxton, Cambridge, CB10 1SD, UK
| +44–(0) 1223 49 2603