jjhelmus / nmrglue

A module for working with NMR data in Python
BSD 3-Clause "New" or "Revised" License
209 stars 86 forks source link

xcpy: Interfacing with external scripts from Topspin #103

Closed kaustubhmote closed 5 years ago

kaustubhmote commented 5 years ago

Bruker-Topspin now being freely available under an academic licence, this is a feature request that comes up often for me, and has popped up on the nmrglue-discuss group as well. The file xcpy.py, which is included in the nmrglue/util folder, will allow the use of nmrglue (and any other cpython script) from within Topspin. It is a lightly polished version of what has been sitting in one of my repositories for sometime now, and takes some suggestions from the nmrglue-discuss thread. This should go nicely with the ability of nmrglue to read and write (#85, #88) bruker datasets, and also with the philosophy of nmrglue of being the 'glue'. I am including a simple "Hello World" script as well (xcpy_test.py), but some real world examples can be found here.

The documentation on how to use this file are given in the file docstring itself. The TLDR version is: Copy or symlink xcpy.py to the <topspin>/exp/stan/nmr/py/user directory, where is the directory where your topspin is located. If you now type xcpy or xcpy -h from within Topspin, the documentation should pop up and is hopefully self-explanatory regarding the various options and initial set up.

A simple GIF on how this should look like:

xcpy

This approach is, of course, not restricted to nmrglue; other programs like nmrpipe, matnmr, etc can all be accessed from within Topspin in a similar fashion (xcpy uses the subprocess module of the internal Jython to call an external script). I am inclined to start with just this, and see whether any bugs pop up before including other things in there. Currently, this is tested with Linux and Windows, and Topspin 3.6 and 4.0.

jjhelmus commented 5 years ago

@kaustubhmote This is really neat. I don't know they best location for this file in nmrglue but for the time being nmrglue/util seems fine.

kaustubhmote commented 5 years ago

Thanks! I actually thought I will have time for a couple of additions to improve the usability a bit before this is merged. I'll open a separate PR for that then.