Software Environment Management with Modules: my notebook
The following question was recently asked on Biostar "Bioinformatics: how to version control small scripts located all over the server". I suggested to put the scripts in a central repository (under git or whatever ) and to use symbolic links in the workspaces to manage the files. On the other hand, Alex Reynolds suggested to use a Module to deploy versions of a given package.
This tool was also suggested on cited by Lex Nederbragt on twitter:
@yokofakun Yep, module system would allow central place for code/binaries. Load module where/when needed. Loading can be scripted too.
/ Lex Nederbragt (@lexnederbragt) October 5, 2013
I've just played with Modules, here is my (short) experience.
I've got two versions of samtools on my server : 0.1.18 and 0.1.19, I want to easily switch from one version to another.
I created a hidden directory in my home:
mkdir ~/.modulesit contains a directory "samtools" that will contain the two 'modules files' for the two versions of samtools:
mkdir ~/.modules/samtools
The directory '~/.modules' is added to the variable ${MODULESPATH} ( The path that the module command searches when looking for modulefiles )
$ export MODULEPATH=${MODULEPATH}:${HOME}/.modules
Create the Module File
'${HOME}/.modules/samtools/0.1.18'
for samtools 0.1.18: This module file add the PATH to samtools0.1.18 and bcftools0.1.18#%Module1.0 proc ModulesHelp { } { global dotversion puts stderr "\tSamtools" } module-whatis "Samtools 0.1.18" prepend-path PATH /commun/data/packages/samtools-0.1.18/ prepend-path PATH /commun/data/packages/samtools-0.1.18/bcftools
Create the Module File
'${HOME}/.modules/samtools/0.1.19'
for samtools 0.1.19: This module file add the PATH to samtools0.1.19 and bcftools0.1.19#%Module1.0 proc ModulesHelp { } { global dotversion puts stderr "\tSamtools" } module-whatis "Samtools 0.1.19" prepend-path PATH /commun/data/packages/samtools-0.1.19/ prepend-path PATH /commun/data/packages/samtools-0.1.19/bcftools
We also create a file '${HOME}/.modules/samtools/.version' to define the default version of samtools:
#%Module1.0 set ModulesVersion "0.1.19"
On startup the shell doesn't know samtools or bcftools:
$ which samtools /usr/bin/which: no samtools in (/commun/sge_root/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lindenb/bin) $ which bcftools /usr/bin/which: no bcftools in (/commun/sge_root/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lindenb/bin)List the available modules :
$ module avail
------------------------------------------------ /usr/share/Modules/modulefiles ------------------------------------------------
dot module-cvs module-info modules mpich2-x86_64 null use.own
---------------------------------------------------- /home/lindenb/.modules ----------------------------------------------------
samtools/0.1.18 samtools/0.1.19(default)
Let's load the default configuration for samtools:$ module load samtools
now, the shell know the PATH to samtools:
$ which samtools /commun/data/packages/samtools-0.1.19/samtools $ which bcftools /commun/data/packages/samtools-0.1.19/bcftools/bcftools
Unload the module for samtools:
$ module unload samtools $ which samtools /usr/bin/which: no samtools in (/commun/sge_root/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lindenb/bin) $ which bcftools /usr/bin/which: no bcftools in (/commun/sge_root/bin/lx24-amd64:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lindenb/bin)
Now load the (old) version 0.1.18 of samtools
$ module load samtools/0.1.18
The old versions of samtools and bcftools are now in the $PATH:
$ which samtools /commun/data/packages/samtools-0.1.18/samtools $ which bcftools /commun/data/packages/samtools-0.1.18/bcftools/bcftoolsThat's it,
Pierre