PBM – Poor Bioinformatician’s Module

It’s hard to say whether to actually call this a tool, because this was my ten minute solution to the problem of setting up the $PATH and other environment variables with the right links to various bioinformatics software packages.  I since discovered that this had already been solved back in 1991 with the module software package, but even those files look a little cumbersome, whereas this is dead simple.

To set this up for yourself, do the following:

  1.  Create a directory somewhere convenient but out of the way. I use “~/.pbm”.
  2. Add the following line to your .bashrc file:
    alias pbm="source ~/bin/pbm.sh"
  3. Add the following text as the script for pbm:
    if [ $# -ne 1 ]; then
        echo "Usage: pbm execname"
    else
        FILE=~/.pbm/$1
        if [ ! -e $FILE ]; then
            echo "Error: pbm config file for $1 not found."
        else
            source $FILE
        fi
    fi

Then, just create configuration files in ~/.pbm for each of the bioinformatics packages you want to use.  Most of them can just be a simple “export PATH” command, like my bwa file:

export PATH=~/soft/bwa-0.7.8:$PATH

Note: Be sure to use the form “export VAR=…:$VAR” for these “list of directories” environment variables. This ensures that the package is at the beginning of the list (and so will be the one used), but retains all of the existing directories (so you can still find the rest of your commands).

You can also set any environment variables you need for the package, like in my setup of the MACS software, which needs a directory in the PYTHONPATH:

export PYTHONPATH=~/soft/MACS/lib/python2.6/site-packages:$PYTHONPATH
export PATH=~/soft/MACS/bin:$PATH

pbm peaksplitter

As you can also see, you can load other packages in your config file.  In this case, MACS uses the PeakSplitter package, and so I setup a separate config file for it, then just include it in the MACS config file. Also, you can construct your own commands, particularly for those java-based packages that don’t provide easy command lines for using their components, like I did for cramtools:

alias cramtools="java -jar ~/soft/Cramtools-2.1/cramtools-2.1.jar"

Once you have setup the configuration files, running “pbm name” will load the config file with that name and setup your environment for using that package (and you won’t have to remember where the heck it is).

Also, if you care about versioning, create additional files with specific versions (bwa7.8, …) to ensure that you get the exact version you are looking for.

Leave a Reply

Your email address will not be published. Required fields are marked *