Hi all,

I got stung for not fully reading some doc today and thought I would share to 
get some opinions on whether the method behaviour should/could change. I'll 
explain more in a bit but here's what I was doing.

The following snippet (https://gist.github.com/3139004) checks if the the 
container has coordinates for it's atoms and will invoke the renderer if it 
does. If we don't have coordinates we handle appropriately. 

if (GeometryTools.has2DCoordinates(container)) {
    renderer.paint(container, new AWTDrawVisitor(g2), bounds, true);
} else {
    // can log or invoke g2.drawString() to display "no coordinates"
}

This will work for the majority of cases however if can cause the paint method 
to throw an exception. In my mind the 'has2DCoordinates' tells me whether we 
have coordinates for all atoms in our container/molecule. However what it will 
actually tell you is whether any of your atoms have 2D coordinates. As I said 
this was my fault for not fully reading the doc and assuming 'Determines if 
this AtomContainer contains 2D coordinates' means all atoms. There is the 
method 'has2DCoordinatesNew' which we can use to get an integer and determine 
full (2) or partial coordinates (1). In my mind a method like  
'has2DCoordinates' would be mainly used to check an input is valid (as above) 
and not fail.

It should be noted that equivalent 'has3DCoordinates' will return true only if 
all atoms have 3D coordinates as I had presumed with the 2D method.

It would be good to unify the 'has2DCoordinates' and 'has3DCoordinates' to 
behave the same way. Personally I would opt to change 'has2DCoordinates' as I 
can see the use cases for such a method being used more for preventing errors 
then checking molecules with partial atoms.

Please let me know your opinions.

Many thanks,
John


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to