[chimera-dev] Linking Chimera with our molecular simulation tool-kit
Eric Pettersen
pett at cgl.ucsf.edu
Wed Oct 21 13:54:47 PDT 2015
Hi Lianheng,
One of our design goals for Chimera was to enable the development of extension for third parties, so obviously we’d be happy if you made an extension for running CP2K via Chimera. I believe all the capabilities you outline are available in Chimera.
The first thing I’d do if I were you is to look at the Chimera Programmer’s Guide, particularly the Examples. They don’t have enough detail to get you completely going, but they do cover the basic concepts of how things work under the hood in Chimera. Links:
http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/index.html <http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/index.html>
http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html <http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html>
The next thing would be to look at a couple of extensions that do things along the lines of what you want to do. The ones that come to my mind are the tools in the “Amber” tools category (Add Ions, Solvate, Write Prmtop) that present some kind of interface to the user and, based on the interface settings, deliver commands to various Amber executables on the back end, forward the text output of the commands to the reply log, and open the output files (for Solvate and Add Ions) and present their structures in the graphics window.
The code for these extensions are in <your Chimera app>/share/tool-name, so tool-name is either Solvate, WritePrmtop, or Addions. As detailed the Programmer’s Guide, each of these directories have a ChimeraExtension.py file, which contains code to tell Chimera where to put the tool in the Tools menu, and optionally what command to add for the tool, what file types it’s a reader for, and what button to add to the Model Panel for it. These tools put their non-GUI code into __init__.py and their GUI code in gui.py. This segregation makes it easier to offer a command version of the tool. To see how the tool drives the backend executable look at __init__.py for Solvate for example, in particular the initiateSolvate function. In general terms, that routine writes the input files that will be read by Amber’s sleap executable, forms the sleap command it wants to send, use’s Python’s subprocess.Popen to run the command, send the input command, and collect the output. As the command executes, it’s output is forwarded line by line to both the status line and the reply log. The routine then checks for the existence of the expected output file and raises an error if it’s missing. Otherwise it goes ahead and processes the file. The processing is pretty complicated as it tries to find the correspondences between the input, which has solvent added, and the original structure and I recommend you ignore that part of the code!
It’s not 100% clear from your mail if your desired expected interaction between Chimera and CP2K fits into this scheme of one-shot (or series of one-shot) executions of CP2K, or if you were thinking of some kind of “stateful” execution where Chimera stays in continuous communication with one instance of CP2K. The latter is also possible but in the interests of not turning this mail into a George R.R. Martin novel, I'll cover that if you ask about it. :-)
One of the points in your mail was getting info about what’s selected. It’s reasonably simple:
from chimera.selection import currentAtoms
selAtoms = currentAtoms()
There are various attributes of Atom you may be interested in, such as name, element, residue, coord() and/or xformCoord(), and attributes of Residue such as type, id.position, id.chainId, id.insertionCode. You may want to use help() on these classes (chimera.Atom, chimera.Residue) in the Python shell (Tools->General Controls->IDLE) to get more extensive info.
Lastly, asking on this mailing list is probably the quickest way to get turnaround on problems you run into. We’re happy to help!
—Eric
Eric Pettersen
UCSF Computer Graphics Lab
> On Oct 21, 2015, at 5:36 AM, Lianheng Tong <lianheng.tong at kcl.ac.uk> wrote:
>
> Dear Chimera developers,
>
> I am a postdoc research associate working with Prof. Lev Kantorovich of King’s College London. I am currently a full time developer for the ab initio atomic simulation code CP2K, and as a part of our project funding, we are looking to develop a tool kit that would improve user friendliness that would allow the users to construct various bulk or molecular structures in an intuitive and graphically way.
>
> We currently have a quite extensive tool-kit (tetr) developed by Prof. Kantorovich for generating, modifying structures—especially tailored for periodic systems, as well as post processing utilities on volume data (such as generating STM images etc). It is written in FORTRAN, and currently is command based only, with the user input being either interactive or by a batch file. The goal, is to be able to link to a visualisation package like Chimera, so that:
>
> a) one is able to automatically update the visualisation when the user uses the tool interactively
> b) allow the user to select atoms and fragments and use these selections as an input to the tool-kit.
>
> Ideally, the took-kit can run as an independent code, with the extension providing an interface between Chimera and the tool-kit. The user would then control the tool-kit from within the Chimera command interface.
>
> I have used Chimera a lot during my PhD, however, I have not yet written any extension for it. I do, however, have quite a number of years experiences with code development, especially in Fortran and in Python. I am wondering:
>
> 1) If you would mind if we develop an extension to link our took-kit with Chimera
> 2) If the functionalities I mentioned above would be possible to achieve
>
> Any suggestions from you would be great. Thank you very much for your time, and I look forward to hearing from you soon.
>
> Best regards,
>
> Lianheng
>
> ====================================
> Lianheng Tong
> Room S4.02, Strand Building
> Department of Physics
> Kings College London
> Strand, London WC2R 2LS, U.K.
> Tel: +44 20 7848 2064
> Fax: +44 20 7848 2420
> lianheng.tong at kcl.ac.uk <mailto:lianheng.tong at kcl.ac.uk>
> ====================================
>
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20151021/3debc39b/attachment.html>
More information about the Chimera-dev
mailing list