Thursday, 2 February 2012

Tweaking ChemDoodle

Patrik Rydberg posted some code to automatically scale a molecule in the ChemDoodle canvas. I was looking for something like this for quite some time. Now I could this improve for my settings having molFile from many different sources by first scaling the molecule with the scaleToAverageBondLength(Number length) function.

See an example here:
http://gmd.mpimp-golm.mpg.de/Analytes/0a2b3536-2245-4c0e-bdbc-495766eeec67.aspx

My code (taken from Patrik) is below:

structure = ChemDoodle.readMOL(molFile);
structure.scaleToAverageBondLength(10);
size = structure.getDimension();
scale = Math.min(canvas.width / size.x, canvas.height / size.y);
canvas.loadMolecule(structure);
canvas.specs.scale = scale * .9;
canvas.repaint();


cheers

No comments:

Post a Comment