Hi all,
Yesterday I was in Cologne (as well as Tuesday) and worked with Christian in
setting up a ForceField plugin, i.e. a CDK plugin [1] for Jmol that will
subject the active molecule to a force field (FF) energy minimization...
We soon discovered that getChemModel and getChemFile were not implemented yet,
but solved that yesterday (making e.g. the COTViewer plugin working now
too :), several other plugins have been working for much longer...)
Anyway, the FF code in CDK is not fully working yet (ETA a few weeks...), but
the basic plugin is...
Additionally, I added a new method to the CDKEditBus interface and implemented
it for Jmol today: runScript(String, String). The implementation looks like:
public void runScript(String mimeType, String script) {
if ("chemical/x-rasmol".equals(mimeType)) {
viewer.evalString(script);
} else {
// ignore
System.out.println("Ignoring script with unknown MIME type: " +
mimeType);
}
}
In other words, CDK Plugins for Jmol can now use Jmol scripting... Strictly
speaking, this only allows Rasmol scripts, so maybe we should propose a new
MIME type: application/x-jmol-script ??
But there are still some issues left...
1. I think there used to be a method in the Viewer.java called getBondAtomId1
() and -2() or so, that would given me the indices of the two involved
atoms... allowing me to get these atoms then with getAtomName(i)... but these
are no longer present. In order to get the connectivity now, I had to use a
workaround, by matching Point3f coordinates of the bond against those of the
atoms:
// copy the bonds
for (int i=0; i<viewer.getBondCount(); i++) {
// Ok, at the time or writing the JmolViewer no longer has
// something like getBondAtomNumber1() :(
int atomNumber1 = -1;
int atomNumber2 = -1;
Point3f atomCoord = viewer.getBondPoint3f1(i);
for (int j=0; j<atomPoints.length; j++) {
if (atomCoord.distance(atomPoints[j]) < 0.01) {
atomNumber1 = j;
j=atomPoints.length;
}
}
atomCoord = viewer.getBondPoint3f2(i);
for (int j=0; j<atomPoints.length; j++) {
if (atomCoord.distance(atomPoints[j]) < 0.01) {
atomNumber2 = j;
j=atomPoints.length;
}
}
// just assume this is working ...
molecule.addBond(atomNumber1, atomNumber2,
viewer.getBondOrder(i));
}
This *is* working, but a bit ugly...
2. While implemented, the methods showChemFile(ChemFile) and
showChemModel(ChemModel) of the CDKEditBus implementation in Jmol
(JmolEditBus.java) does not work, and gave this error:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException:
org.openscience.cdk.ChemFile
at
org.jmol.adapter.smarter.SmarterJmolAdapter.getAtomSetCollectionName(SmarterJmolAdapter.java:85)
at org.jmol.viewer.ModelManager.setClientFile(ModelManager.java:65)
at org.jmol.viewer.Viewer.openClientFile(Viewer.java:1026)
at
org.openscience.jmol.app.JmolEditBus.showChemFile(JmolEditBus.java:101)
at
org.openscience.jmol.app.JmolEditBus.showChemModel(JmolEditBus.java:109)
at
org.openscience.cdkplugin.forcefield.ForceFieldPlugin$AddChannelEvent.actionPerformed(ForceFieldPlugin.java:137)
The problem here is that it uses the SmarterJmolAdapter by default, and needs
the CdkJmolAdapter now. By using java -Dmodel=cdk -jar Jmol.jar it only
worked after I added missing CDK classes to the jmol2cdk.jar...After fixing
that it seemed to work :)
But the problem remains that it would be nice if the actual adapter could be
overwritten, e.g. using
viewer.openClientFile("", "", file, JmolAdapter useThisOne);
Or maybe the Viewer should detect wether the 'clientFile' is instanceof
ChemObject and then use the CdkJmolAdapter... Or something like that...
Miguel,
what do you think on these two issues?
Egon
1. http://www.woc.science.ru.nl/cdk/
-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/info/Sentarus/hamr30
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers