Do you have a method for calculating a dihedral angle?
I am afraid not in the public API.
Please put it on your list of enhancement requests. It would not be hard for you to write such a method.
Thank you for the advice, we will certainly make such calculation available soon.
We actually have the method - we need it at various places (e.g. 3d clean, MarvinSpace) - but it is not part of the public API.
What do you think about a GeometryAnalyzer plugin or something like that? - similar to the recently released TopologyAnalyzer? This GeometryAnalyzer could provide services like you asked for: distance, angle, dihedral calculations, diameter, volume etc. Any ideas?
I think such a plug-in would be very useful.
The next step would be to allow the user to manipulate a structure by specifying dihedral angles, bond distances, etc. E.g., if I want eclipsed ethane, and I choose Select Conformer, I get only staggered ethane. I want to be able to specify an H-C-C-H dihedral angle of 0°.
Such functionality (i.e. change of dihedral) will be available in MarvinSpace soon.
Calculator plugins do not allow the manipulation of structures, but as far as I know plugins are being redesigned just now, so maybe it is the right moment to put structure manipulation via plugins on the list of requirements. I pass this on to the developers involved in plugin developments.
We are immediately in need of a method for calculating the dihedral angle. We have for now borrowed some code from another source, but it is copyrighted, and we don't know whether the authors will permit us to use the code commercially. Would you be willing to release your code for calculating the dihedral angle to us as part of our general license?
The code 'as is' would be useless for you and others out there as it relies on some internal classes (those were introduced for the sake of compact storage and fast calculation of large amount of 3d data).
What we can and will do is to reimplement all methods required by dihedral angle calculation, but these methods will be based on a much simpler (=canonic) 3d vector representation.
I will upload the source code to the contrib forum area soon and a link will be placed here.
Thanks for making Dihedral.java available. It generally works just fine. But often when the dihedral angle is exactly 180 degrees it results in NaN (not a number). I can work around the problem, but it would be better to fix it. To reproduce, build ethane, clean in 3D, and find the dihedral angle H-C-C-H picking two H atoms that are 180 degrees apart.
Thank you for reporting the bug! I'll the code again as soon as it is fixed.
Now that you have donated code for determining a dihedral angle, would you be able to donate code for rotating about a bond to make a new dihedral angle?
I might try to write it myself, but I'm afraid my trigonometry skills have rusted away since high school.
We will think about it. It is possible that we give away the matrix multiplication based solution, though there is a more sophisticated and more powerful method, based on quaternions, also known.
PS. Btw, I'm not sure we fixed the bug in the torsion calculator code. We'll check that.
OK, I wrote my own using JChem methods. I'll post it in the Contributions and Implementations forums.
It wasn't fixed in our copy, but I added one line to fix it.
|mvargyas wrote: |
|PS. Btw, I'm not sure we fixed the bug in the torsion calculator code. We'll check that. |
However, there's a more serious bug. Your algorithm returns values only between 0 and 180 degrees. Dihedral angles are measured between -180 and 180 degrees (or 0 to 360). The atom2-atom3 vector determines the perspective by which the atom3-atom4 vector is viewed to be clockwise or counterclockwise with respect to the atom2-atom1 vector.
I'll post a solution in the Contributions section.
Oh, I see you already posted a correction to your code in the Contributions section. Good enough.