Creative Commons License
http://blog.louic.nl by Louic S. Vermeer is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 3.0 Netherlands License.

Louic's blog – about science and stuff

How to cite scientific papers in openoffice, using Jabref as a reference manager

without comments

Get Jabref
http://jabref.sourceforge.net

Get the openoffice.org panel plugin for Jabref and install it
http://www.itk.ntnu.no/ansatte/Alver_Omholt_Morten/jabref/OOPlugin.html

Edit a style file to define the style of the links to the bibliography and the bibliography itself. An example file is given on the website of OOPlugin, and the layout options you can use in the style file are described on the Jabref export filter website:
http://jabref.sourceforge.net/help/CustomExports.php

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

September 1st, 2010 at 1:09 pm

Posted in linux, science

Mount a directory over ssh checklist

without comments

  • make sure ssh is installed and running
  • generate an ssh key for password-less login:
    • run ssh-keygen, do not add a pass phrase
    • copy .ssh/id_rsa.pub to remote host
    • cat the copied id_rsa.pub >> .ssh/authorized_keys
    • test
  • install sshfs
  • mount the remote directory: # sshfs remote:/directory /local_mountpoint
  • Share this:
    • Facebook
    • LinkedIn
    • email
    • RSS
    • Twitter

Written by louic

August 25th, 2010 at 1:59 pm

Posted in linux, sysadmin

Compiling Aria2, CNS, procheck and aqua for NMR structure calculation

without comments

A quick guide to compiling ARIA 2.2, CNS 1.21, AQUA 3.2 and PROCHECK, under Ubuntu Karmic 9.10 (32-bit)

If you use Gentoo linux, you can find aria under sci-chemistry (masked by ~x86). Procheck is in the science overlay (see the layman and overlays documentation). Aqua has to be installed manually at the time of writing this post.

In Ubuntu, the following packages are needed:

  • numpy
  • scipy
  • tcl 8.5
  • tk 8.5
  • tix
  • matplotlib
  • cns (to be compiled manually, see below)
  • the intel fortran compiler (to compile cns, gfortran does not seem to work)
  • tcsh
  • openjdk6 (needed for intel fortran compiler)
  • libstdc++5 (for cns)
  • flex (for cns)

Some files need to be copied from ARIA to CNS before it is compiled, this can be found in the ARIA instructions. Both CNS and ARIA can be compiled according to the instructions, but during the compilation of CNS with gfortran 4.3 I got a Segmentation fault. Using the Intel fortran compiler (ifort, free for academic use), there were no problems. For the installation of the Intel compiler, I needed to have openjdk6, which I installed using the Synaptic “default_jre” package.

CNS required libstdc++5 (download the old .deb) and flex (“lex” command not found) to compile correctly.

Procheck and aqua can be installed according to the instructions. I used ifort to compile procheck, and g++ for aqua.

And here are the lines to include in .tcshrc:

# for cns:
source /home/louic/software/cns_solve_1.21/cns_solve_env
 
# for aria:
setenv ARIA2 '/home/louic/software/aria2.2'
alias aria2 '/usr/bin/python -O $ARIA2/aria2.py'
 
# for procheck and aqua:
setenv prodir '/home/louic/software/procheck'
setenv aquaroot '/home/louic/software/aqua3.2'
source $aquaroot/aqsetup

There seemed to be some problems on a 64-bit system, which is why I switched back to using 32-bit for now. I did not fully investigate this issue and do not know what the exact problem was.

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

February 23rd, 2010 at 7:04 pm

Posted in NMR, linux, science, sysadmin, ubuntu

Turn off auto complete in openoffice.org calc

with 2 comments

Assuming you already found the Tools -> Autocorrect options (which is exactly where you’d expect it to be), that still leaves the (very annoying) autocomplete function enabled. To turn it off, you need to disable:

Tools -> Cell Contents -> AutoInput

This will turn it off until you turn it back on.

(I found it thanks to this weblog)

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

February 18th, 2010 at 6:48 pm

Posted in Uncategorized

Using procheck_nmr on a large number of structures

without comments

After a structure calculation with the aria 2.2 software I used aqua and procheck_nmr to assess the result. Although procheck_nmr worked fine on my 20 refined structures (in aria’s refine directory), it ran into trouble with the 100 structures after iteration 8 (directory it8):

 * Restraints read in from file:
 * allpdb.nrv                                                                  
* Warning. Error reading restraint on line          34
* Warning. Error reading restraint on line          35
* Warning. Error reading restraint on line          36
* Warning. Error reading restraint on line          37
* Warning. Error reading restraint on line          38
* Warning. Error reading restraint on line          39
* Warning. Error reading restraint on line          40
* Warning. Error reading restraint on line          41
* Warning. Error reading restraint on line          42
(... and so on...)

A look at the allpdb.nrv file indicated that nothing was wrong with it, and as I mentioned the analysis worked fine when a lower number of structures was analysed.

A quick look at the procheck_nmr script indicated that these error messages were produced by vplot, which has it’s source code in the vplot.f file. The source-code defines a string called IREC, that will hold the record with all the relevant distances in all the structures, but IREC is defined as:

       CHARACTER*512 IREC

…which is not long enough to hold all the distances that are read from the .nrv file. A similar problem occurs somewhere else in the code, where a format string is used on the record that is read from the .nrv file.

By increasing the size of the relevant variables and recompiling vplot.f, the analysis runs smoothly. Here is the diff-file that may be used as a patch:

louic@picadilly:~/software/procheck$ diff -u ../old/procheck/vplot.f vplot.f
--- ../old/procheck/vplot.f	2010-01-19 13:37:32.000000000 +0000
+++ vplot.f	2010-01-21 18:46:38.000000000 +0000
@@ -2141,7 +2141,7 @@
       CHARACTER*4   ATTYP(2)
       CHARACTER*9   RESDET(2)
       CHARACTER*80  FNAME
-      CHARACTER*512 IREC
+      CHARACTER*1024 IREC
       INTEGER       IATNO(2), IATTYP, ICONST, ICTYPE, IERR, IFILE,
      -              IMODEL, IRES, IRESNO(2), ITYPE, JERR, LCOUNT, LINE,
      -              NFILE, MAXCON, UCOUNT
@@ -2292,7 +2292,7 @@
 C----                     Read in the restraint violations for all the models
                           READ(IREC,460,IOSTAT=IERR)
      -                        (ACDIST(IFILE,ICONST), IFILE = 1, NFILE)
- 460                      FORMAT(57X,60F7.2)
+ 460                      FORMAT(57X,100F7.2)
 
 C----                     Extract the data for just those models that
 C                         have been selected by the user

To apply this patch, go to the directory where vplot.f is located, save the above patch as vplot.f.patch, and run the following commands:

patch < vplot.f.patch
make

Note that although this modification makes the analysis run on 100 structures, the length of IREC and the float in the format string are still limited. They may need to be increased if you want to analyse more structures at the same time.

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

January 22nd, 2010 at 1:32 pm

Posted in NMR, science

Interpolating data on a grid with python/numpy

with 2 comments

Sometimes, measured data points have different values on the x-axis, but data-processing requires the data points to be the same in all the spectra. This “shift” in data-points may be due to calibration of the data, or simply because the x-variable is not exactly reproduced between measurements. The following code interpolates all input-spectra so that the values on the x-axis are aligned on a grid, where the grid is calculated from the average values of the data points in the original spectra. The code can easily be adapted to use a pre-defined grid, if that is what you want.

In the example below, the limited number of data points used for the interpolation causes peaks to shift and/or decrease in intensity (a common problem of linear interpolation). If your spectra consist of many data points (like mine), this is not a problem though. Increasing the number of data points on the grid will obviously improve the fit as well.

Without any further introduction (code says more that a 1000 words!), here is the python code:

#!/usr/bin/python
"""
    Test program for linear interpolation of data.
 
    Filled circles are original data, shifted with respect to each other
 
    Crosses are interpolated data points on a grid, with the same x-axis values
    for each spectrum. The grid is calculated by taking the average values of the
    x-datapoints of all the spectra.
"""
import numpy as np
from scipy import interpolate
 
def interpolate_to_average_grid(xdata, ydata):
 
    # define grid as average x-values over all spectra,
    xgrid = np.mean(xdata, axis = 0)
 
    # delete data outside the smallest maximum and largest minimum, because
    # we do not want to extrapolate, the interp1d-function does not support that
    minx = np.min(xdata[0])
    maxx = np.max(xdata[0])
    for x in xdata:
        if maxx > np.max(x):
            maxx = np.max(x)
        if minx < np.min(x):
            minx = np.min(x)
    deleteindex = np.where((xgrid > maxx) | (xgrid < minx))
    xgrid = np.delete(xgrid, deleteindex[0])
 
    # create an empty array to hold the interpolated data
    new_ydata = np.zeros(shape = (len(ydata), len(xgrid)))
 
    # interpolate all spectra the grid
    for i in range(len(xdata)):
        f = interpolate.interp1d(xdata[i], ydata[i])
        new_ydata[i] = f(xgrid)
    return xgrid, new_ydata
 
if __name__ == "__main__":
 
    ### generate some data (three "spectra", slightly shifted) 
    # TODO: if the xdata is reversed (np.arange(14.9, -5.1, -1)), it does not work (why?)
    xdata = np.array([np.arange(-5.1, 14.9, 1), np.arange(-5.5, 14.5, 1), np.arange(-7, 13, 1)])
    ydata = np.array([np.sin(xdata[0]), np.abs(np.sin(xdata[1])) - 0.5, 0.7 * np.sin(xdata[2])])
 
    newxdata, newydata = interpolate_to_average_grid(xdata, ydata)
 
    # visualize what was done
    import matplotlib.pyplot as p
    colours = ['bo', 'go', 'yo']
    lines = ['b-', 'g-', 'y-']
    coloursnew = ['bx', 'gx', 'yx']
    for i in range(len(xdata)):
        p.plot(xdata[i], ydata[i], colours[i])
        p.plot(xdata[i], ydata[i], lines[i])
    for i in range(len(newydata)):
        p.plot(newxdata, newydata[i], coloursnew[i])
    p.show()
Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

December 1st, 2009 at 1:49 pm

Posted in numpy, python, science

Compiling and installing MolMol under Linux

with 9 comments

The molmol software that is available from the website of ETH Zurich does not compile on Ubuntu Linux without some changes. It seems that it is no longer supported by ETH Zurich, but can be downloaded from several other websites (just google it). I describe below what I needed to do to get it to compile and run on Ubuntu Linux.

A summary of the installation procedure as described in the readme file follows for reference, but it does not seem to work without the changes mentioned below:

tar xvzf molmol-2k.2.0-doc.tar.gz
tar xfzf molmol-2k.2.0-src.tar.gz
 
cd tiff-v3.4
./configure
make
sudo make install
cd ..
 
cp makedef.lnx makedef
./INSTALL
make
sed -i 's/ksh/sh/g' molmol 
cd src/main
strip molmol
cp molmol ../../molmol.lnx
cd ../..
 
./molmol

First, some additional packages are needed in Ubuntu:

sudo apt-get install libmotif-dev
sudo apt-get install x11proto-print-dev
sudo apt-get install libxpm-dev

(depending on your current ubuntu installation, you may need some other packages as well. Some error messages during the installation may give you an indication of what else is needed.)

However, when I tried to compile molmol, the following error occured:

/usr/bin/gcc -I../../tools/include -Dsqrtf=sqrt -Dexpf=exp -Dlogf=log -Dpowf=pow -Dsinf=sin -Dcosf=cos -Dtanf=tan -Dasinf=asin -Dacosf=acos -Datanf=atan -Datan2f=atan2 -Dfabsf=fabs -Dceilf=ceil -O2 -I../../tools/include -Dsqrtf=sqrt -Dexpf=exp -Dlogf=log -Dpowf=pow -Dsinf=sin -Dcosf=cos -Dtanf=tan -Dasinf=asin -Dacosf=acos -Datanf=atan -Datan2f=atan2 -Dfabsf=fabs -Dceilf=ceil  -c -o RandNum.o RandNum.c
In file included from /usr/include/math.h:94,
                 from RandNum.c:29:
/usr/include/bits/mathcalls.h:55: error: conflicting types for ‘acos’
/usr/include/bits/mathcalls.h:57: error: conflicting types for ‘asin’
/usr/include/bits/mathcalls.h:59: error: conflicting types for ‘atan’
/usr/include/bits/mathcalls.h:61: error: conflicting types for ‘atan2’
/usr/include/bits/mathcalls.h:64: error: conflicting types for ‘cos’
/usr/include/bits/mathcalls.h:66: error: conflicting types for ‘sin’
/usr/include/bits/mathcalls.h:68: error: conflicting types for ‘tan’
/usr/include/bits/mathcalls.h:101: error: conflicting types for ‘exp’
/usr/include/bits/mathcalls.h:110: error: conflicting types for ‘log’
/usr/include/bits/mathcalls.h:154: error: conflicting types for ‘pow’
/usr/include/bits/mathcalls.h:157: error: conflicting types for ‘sqrt’
/usr/include/bits/mathcalls.h:179: error: conflicting types for ‘ceil’
/usr/include/bits/mathcalls.h:182: error: conflicting types for ‘fabs’
make[4]: *** [RandNum.o] Error 1

This was easily solved by editing the makedef file as follows:

change

MISSFUNC = -Dsqrtf=sqrt -Dexpf=exp -Dlogf=log -Dpowf=pow \
           -Dsinf=sin -Dcosf=cos -Dtanf=tan \
           -Dasinf=asin -Dacosf=acos -Datanf=atan -Datan2f=atan2 \
           -Dfabsf=fabs -Dceilf=ceil

to

# MISSFUNC = -Dsqrtf=sqrt -Dexpf=exp -Dlogf=log -Dpowf=pow \
#         -Dsinf=sin -Dcosf=cos -Dtanf=tan \
#         -Dasinf=asin -Dacosf=acos -Datanf=atan -Datan2f=atan2 \
#         -Dfabsf=fabs -Dceilf=ceil

At this point, I got a second error

/usr/bin/sleep 2
make[6]: /usr/bin/sleep: Command not found

This one is even easier to solve, by again editing makedef:

change

WAIT   = /usr/bin/sleep 2

to

WAIT   = /bin/sleep 2

Another error occurs that requires us to make some changes in the source code. The error message is:

/usr/bin/gcc -o molmol -I../../tools/include -I../../sg/include -I../../include  -O2 MolMol.o MolInit.o ../../lib/libcip.a ../../lib/libcmd.a ../../lib/libui.a ../../lib/libgraph.a ../../lib/libio.a ../../lib/libpu.a ../../lib/libcalc.a ../../lib/libprim.a ../../lib/libdata.a ../../lib/libattr.a ../../lib/libfileio.a ../../lib/libos.a ../../sg/lib/libsg.a ../../tools/lib/libtools.a  -L/usr/X11R6/lib -lXm -lXt -lX11 -lm -lc -lieee
../../lib/libos.a(GFile.o): In function `raiseError':
GFile.c:(.text+0x37): warning: `sys_errlist' is deprecated; use `strerror' or `strerror_r' instead
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in ../../lib/libos.a(GFile.o)
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[4]: *** [molmol] Error 1

The following changes to the source-code solved the problem.

Add the following line to the file ./src/os/GFile.c

#include <errno.h>

add it for example under the line that says

#include <linlist.h>

Also change the following line (line 85 after the previous edit):

msg = sys_errlist[errno];

to

msg = strerror(errno);

Molmol shoud compile now, but unfortunately the problems are not finished yet. After having stripped and copied molmol from ./src/main to molmol.lnx as in the original instructions, when we try to run it, it says:

MOLMOL 2K.2 
 
Version 2.1-2.6: Copyright (c) 1994-98 by
    Institut fuer Molekularbiologie und Biophysik, ETH Zurich
    Spectrospin AG, Faellanden, Switzerland
 
Version 2K.2: Custom version by Reto Koradi, 1999-2003
 
using Motif/OpenGL
unknown IO device

This can be solved by editing the startup script (the file called molmol):

Comment out the following lines (line 192-209):

#if [ -n "$nograph" ]; then
#  MOLMOLDEV=TTY/NO
#elif [ -n "$MOLMOLDEV" ]; then
#  true  # already set
#elif [ -n "$localdev" -a \( $display = ":0" -o $display = ":0.0" \) ]; then
#  MOLMOLDEV=$localdev
#elif [ -x $xdpy ]; then
#  xdpyout=`$xdpy -d $display 2>&1 | egrep 'GLX|unable'`
#  case $xdpyout in
#    *unable*) MOLMOLDEV=TTY/NO
#              nograph=y
#              continue;;
#    *GLX*)    if [ -n "$glxdev" ]; then
#                MOLMOLDEV=$glxdev
#              fi
#              continue;;
#  esac
#fi

I hope this helps!

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

August 7th, 2009 at 4:42 pm

Vertically align a table (or something) in vim

without comments

Just a short note to myself how to align a table in vim. I found the answer here. We start with the following example, a part of a LateX table (that was generated with an openoffice plugin). But the columns (“&” characters) are not aligned vertically, which is ugly.

      C1 & c3 & 0.30593 & C1 \\
      C1X & c3 & 0.13418 & C1X \\
      C2 & c3 & 0.08862 & C2 \\
      C2X & c3 & -0.08100 & C2X \\

Of course, aligning the & characters can easily be done automagically (and I did not even have to write the script myself!)

  • download the vim Align plugin
  • install it. details on how to install are on the plugin’s page
  • use it: select a block and type (in this case, we want to align the & character):
    :Align &
  • watch the magic
      C1   & c3 & 0.30593  & C1 \\
      C1X  & c3 & 0.13418  & C1X \\
      C2   & c3 & 0.08862  & C2 \\
      C2X  & c3 & -0.08100 & C2X \\

Actually, this was just an example. The Align package has a special command to align LaTeX tables, which also aligns the \\ thingies. Just type \tt instead of :Align &.

(And in case you want to know: the table shows AMBER ff03 atom types and partial charges of an octylglucoside molecule, as calculated by AM1-BCC. But you are probably not interested :) )

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

February 6th, 2009 at 1:15 pm

Posted in LaTeX, vim

Drawing structures of organic molecules in (Gentoo) Linux

with one comment

In gentoo portage, there are several programs to draw structures of organic molecules. The best one is gchempaint. Not in portage, but also very interesting is bkchem. A Gentoo ebuild is available, but needs to be installed from a portage overlay. To install it, just use the commands below (where I assume you have a portage overlay correctly set up in /usr/local/portage).

# mkdir -p /usr/local/portage/sci-chemistry/bkchem
# cd /usr/local/portage/sci-chemistry/bkchem
# wget http://bkchem.zirael.org/download/bkchem-0.12.5.ebuild
# ebuild bkchem-0.12.5.ebuild digest
# emerge -va bkchem

If you want to make some final adjustments to the structure of the molecule, I suggest saving the molecule as an svg image, and making the adjustments with inkscape.

BKChem website
GChemPaint website

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

February 5th, 2009 at 2:21 pm

Posted in gentoo, linux, science, thesis

Some xmgrace tips

with 15 comments

Xmgrace is a very nice piece of software to create publication quality figures. Even better is that it stores your data and graph layout options as plain text (which is especially nice in combination with subversion or perl scripts).

But some things are not very intuitive, which is why I keep a list of some useful possibilities below:

  • Subscript, superscript
    x-squared: x\S2\N
    subscript: 3\s10\N
  • Greek letters, example: theta
    \f{Symbol}q\f{}
  • Special symbols, example: Angstrom symbol
    \cE\C
    For other characters, look at this list: ascii table with low and high characters. Just use the character from the left column between \c and \C to produce the one from the right column. I highlighted the most interesting characters (for a scientist). The \c and \C option are listed as deprecated in the xmgrace manual., but what is the new way?. The new method to insert special characters in xmgrace is:

    • Press ctrl-e while positioned in a text-edit field to bring up the font dialog box.
    • Select the desired font from the drop-down list. You probably want to use Symbol because it contains many of the commonly used special characters.
    • Click on the character you want to insert
  • Saving the default settings for new graphs:
    open xmgrace, make the desired settings, save them as:
    ~/.grace/templates/Default.agr
    Unfortunately, this does not save the “print” settings, but see below.
  • Setting the default printer to print to .png files with 300dpi:
    create the file ~/.grace/gracerc.user and enter the following text:
    HARDCOPY DEVICE "PNG"
    DEVICE "PNG" DPI 300
  • Changing the definition of the default colors:
    Just edit the lines that say
    @map color 7 to (220, 220, 220), "grey"
    in the saved file. Edit the default file (see above) if you wish to use the new colors everywhere from now on.

See also the Grace users guide and the grace forums.

If you have more helpful hints, please post them in the comments, so that this blog post will become an interesting collection of tips that can be turned into a useful “cheat sheet”.

Share this:
  • Facebook
  • LinkedIn
  • email
  • RSS
  • Twitter

Written by louic

January 30th, 2009 at 3:32 pm