Hello Andrew,

To read compressed files in java, check out the java.util.zip package, which has Readers and InputStreams that transparantly decompress a file. E.G
"gzipReader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(fileName))));"

The JAVA example for the rest looks okay, there's only some style comments
@MDLiter For-loop: The line:
"for (IteratingMDLReader mdliter = new IteratingMDLReader(sdfile, DefaultChemObjectBuilder.getInstance()); mdliter.hasNext(); ) {"
Would more cleanly be split into a init-line + while-loop, though I agree with Rajarshi that its odd that they're separate.
"IteratingMDLReader mdliter = new IteratingMDLReader(sdfile, DefaultChemObjectBuilder.getInstance());
while ( mdliter.hasNext() ) {
doLoopstuf
();
}"
@atom For-loop:
the CDK-style guidelines prefer longer variable names (though this is really more me being obsessive), so the "IAtom a" would look better as, for example, "IAtom atom" or even "IAtom currentAtom"

Otherwise, no comment, excellent code.

Cheers,
Jules

On 1 June 2011 13:43, Andrew Dalke <dalke@dalkescientific.com> wrote:
Hi all,

 I'm working on my poster for ICCS next week. It's about the Chemistry Toolkit Rosetta. The main part of my poster shows the examples from

 http://ctr.wikia.com/wiki/Heavy_atom_counts_from_an_SD_file

with commentary.

The CDK/Java example there was something I wrote about 1.5 years ago, and I don't know the CDK API that well.

Would one of you all kindly review the code and see if it's appropriate and idiomatically correct? I know from the CDK/Cinfony example that I could use

 cdk.tools.manipulator.AtomCountainterManipulater().getHeavyAtoms

but I don't know if that's what people usually use.

I would also appreciate commentary about why CDK chose its approach. For example, in my code I have

 for ( ... mdliter = new ... ; mdliter.hasNext() )

while for the atom iterator I have

 for (IAtom a : mol.atoms() )

Are there two different forms because I don't know Java well enough?

Also, how would people handle a compressed input file? Is there a way to handle that automatically? And is there a way pass any structure filename and be able to read molecules from it?

Cheers,
                               Andrew
                               dalke@dalkescientific.com



------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user