molecule flag for presence of coordinate bond?

User 870ab5b546

29-04-2013 15:29:40

This seems like an odd and somewhat particular request, but it would be very useful to us if there were a method such as Molecule.hasBondOfType(int).  The reason for the request is that we have to use special methods to handle molecules that contain coordinate bonds.  Currently, we have to look through every bond of a molecule and see if there is a coordinate bond in order to determine whether we need to send the molecule to the special methods.  It would be very convenient if the Molecule stored the information about the presence of a coordinate bond as a flag that we could then access.  


Note that the hasCoordinateBond() method would be no more efficient than what we are already doing if it simply looked through all the bonds of the molecule to see if any were coordinate bonds.  Instead, I would suggest adding a private field, numBondsOfType, Map<Integer, Integer>, which would store the number of bonds of each type.  You would then alter the values in the map as the molecule's bonds were manipulated.


If you really wanted to go all out, you could use Map<Integer, ArrayList<MolBond>>, where the value was the list of bonds of the type given by the key.  Then you could have a method, getBondsOfType(int) which would return the list of MolBonds (as an array).  

ChemAxon 044c6721bc

30-04-2013 08:45:02










bobgr wrote:

This seems like an odd and somewhat particular request, but it would be very useful to us if there were a method such as Molecule.hasBondOfType(int).  The reason for the request is that we have to use special methods to handle molecules that contain coordinate bonds.  Currently, we have to look through every bond of a molecule and see if there is a coordinate bond in order to determine whether we need to send the molecule to the special methods.  It would be very convenient if the Molecule stored the information about the presence of a coordinate bond as a flag that we could then access.  


Note that the hasCoordinateBond() method would be no more efficient than what we are already doing if it simply looked through all the bonds of the molecule to see if any were coordinate bonds.  Instead, I would suggest adding a private field, numBondsOfType, Map<Integer, Integer>, which would store the number of bonds of each type.  You would then alter the values in the map as the molecule's bonds were manipulated.


If you really wanted to go all out, you could use Map<Integer, ArrayList<MolBond>>, where the value was the list of bonds of the type given by the key.  Then you could have a method, getBondsOfType(int) which would return the list of MolBonds (as an array).  



Hi,


The problem with this solution is, then we have to update this map on every bond additon, bond removal, contracting and expanding sgroups, ... and I think in most cases it is a wast of time.


You can try to store that information in a molecule property, and update it when you change the molecule.


Janos