My software notes

May 12, 2007

shell script + gnuplot

Filed under: softwares and scripts — kpwu @ 3:36 pm

I have to analyze about 70 PFG-NMR data (maybe more..), it’s not fun when deal with each data point routinely. Here is the goal I have and the solution I did.

Goal: using shell script (awk, UNIX tools and sed) to do simple calculation; then use gnuplot to generate a lots of plots.


  1. use shell script to format correct files that gnuplot can take as inputs
  2. run gnuplot by calling run.gnu (a gnuplot script)
  3. look at the PNG file generated by gnuplot

Result: see the figure here:
dioxane diffusion plot
content of shell script:

rm -f fit.log
for INP in *k.dat
newname=`basename $INP .dat`
paste gzlvl6.dat $INP > _temp1
cat _temp1 |awk ‘{printf \
“%4.3f%10.3f%10.3f%12.3f\n”,($1*0.00235)^2,log($5/100),$1,$5 }’ >_temp2
## make a proper script to generate gnuplot with good title
cp run.gnu _temp.gnu
echo “plot f(x) with lines ls 1 title ‘fitting line’, ‘”_temp2″‘ using 1:2 title ‘dioxane $newname’ with points 6” >> _temp.gnu
/usr/bin/gnuplot _temp.gnu
## post-filename-modification
mv fit.log $newname-fit.log
mv test.png $newname.png
cat _temp2 |sort -n > $newname-all-info.txt
rm _temp*

Content of run.gnu:
set terminal png
set output “test.png”
fit f(x) “_temp2” using 1:2 via a,b
set xlabel “G^2”
set ylabel “ln(I/I0)”
set yrange [-4:0]
set style line 1 lt 1 lw 3


PyMOL starts to support .MOE file by 1.00beta23

Filed under: pymol/ molmol — kpwu @ 3:18 pm

News from PyMOL mailing list:

This message is for PyMOL users who also use the Molecular Operating
Environment (MOE), a commmercial molecular modeling package published by the
Chemical Computing Group (CCG).

Incentive builds of PyMOL 1.00beta23 include the latest version of what will
hopefully prove to be a broadly useful capacity for reading .MOE files in

The basic idea is that you can do all sorts of fancy molecular calculations
in MOE (an expert package) and then easily share those results with your
non-computational colleagues via PyMOL session files, shows, or rendered
movies simply by reading your .MOE file into PyMOL.

The way it works is that each .MOE file becomes a group object in PyMOL
containing multiple objects with each of the individual chains and graphics
you have defined in MOE. PyMOL then attempts to mimic MOE appearance as
much as practical. Note that multiple .MOE files can be loaded into a
single PyMOL session, enabling you to combine and display results from an
assortment of related calculations.

Current PyMOL sponsors are welcome to download and try this build (1.00b23)
from using the access credentials provided on
their latest invoice receipt.

Please let us know how well it works with your own .MOE files — we
absolutely need more feedback on this feature! If you do experience
problems, please send us your (non-proprietary!) .MOE files for
troubleshooting and test-case development.


PS. Although the PyMOL .MOE reader itself is not open-source, PyMOL session
files and shows containing converted MOE content can be opened by
open-source PyMOL builds.

PPS. If you’re not familiar with MOE,
— though it is proprietary, it has a very open architecture, well-suited
for methods development.

PPPS. Maestro users, stay tuned… dot-MAE is next as soon as .MOE reading
proves stable and complete.

DeLano Scientific LLC
Subscriber Support Services

May 1, 2007

gnuplot, installed on OS X

Filed under: mac,softwares and scripts — kpwu @ 1:33 pm

Today, tried to combine shell script and xmgr or gnuplot to generate a lot of figures. I am lazy to process by excel, pro-fit or other graphical programs, and I don’t care about the quality at first round. The shorter time I spend on the data processing, the better solution I want.

Thus, I decide to use gnuplot. The scriptable program is nice and easy to learn. It’s tricky to install gnuplot on OS X, especially when you already install NMRPipe. NMRPipe provide older gnuplot 3.5 which can’t do fitting and miss many new functions. I use “sudo mv $NMRPIPE_HOME/nmrbin.mac/gnuplot” to rename it. Besides that, after installing GnuPlot 4.0 for mac and AquaTerm, there is an extra step required. The AquaTerm I download is 1.0.1 version, but it’s not working for gnuplot, just need to make a softlink by this way (see reference):

Open the Terminal (Applications > Utilities > Terminal) and ...
            ...$ cd /usr/local/lib/
            ...$ sudo ln -s libaquaterm.1.0.1.dylib libaquaterm.1.0.0.dylib

Then call gnuplot (/usr/local/bin/gnuplot) if you don’t refresh your shell, the default gnuplot will be 3.5 because NMRPipe installed it.

The tricky link I learned is from

Also, here is a very good tutorial site for gnuplot newbie:

Blog at