Skip to content

Install macs2

Tao Liu (τν) edited this page May 5, 2015 · 32 revisions

MACS2 can be found at PyPI website https://pypi.python.org/pypi/MACS2/ (more stable release) or at GitHub https://github.com/taoliu/MACS/ (developmental version)

Table of Contents

Typical Installation Instructions

Platform

A *nix system including Linux, Mac OSX and other *nix variants

Requirements

  • Python 2.7 (Note that Python 2.7.4 has a bug which causes error while reading compressed BAM file'. Fix it according to this report in MACS user group. This bug has been fixed in Python 2.7.5 which was released on 5/12/2013.')
  • Numpy (I recommend you install your own through rpm for Redhat variants or dpkg for Debian variant linux, or install from source code. Although if you are lucky, you can let pip to fix the dependancies.) Note, you need numpy header files to compile MACS2 and some Linux distribution has numpy-dev package separately.
  • GCC compiler. As for Mac OSX users, it means you have to install Xcode then select 'install command line tools' within Xcode program. As a sidenote, current setup script for MACS2 needs GCC>=4.6 so that the optimization flag '-Ofast' can be accepted. If you have older version of GCC or saw an error complaining 'invalid option argument ‘-Ofast’', please manually download MACS2 source code and modify the 'setup.py' script to replace '-Ofast' with '-O3'.

Compile from source code

  • Normally, you need to have root permission to install software. If you want to install MACS2 to your user space, check the section "Manually install Python software to your home directory" for detail.
  • Download source code package from MACS2 page on PyPI then type
    $ python setup.py install
  • If you don't have Numpy, install Numpy first either through source code (recommended) or rpm/dpkg (including numpy and numpy-dev).

Easy installation through PyPI

  • Follow this instruction to get pip if it's not available in your system. Normally, you need to have root permission to install software with pip, unless you have installed a different Python distribution by your own. You may want to check the solution of 'virtual environment' to install software to your own user space, check the section "The virtual environment" for detail.
  • Under command line, type
    $ pip install MACS2
    PyPI will install Numpy automatically if they are absent.
  • To upgrade, type
    $ pip install -U MACS2
    It will check currently installed MACS2, compare the version with the one on PyPI repository, download and install new version while necessary.
  • Sometimes, you don't want pip to fix dependencies. For example, you already have a workable Numpy, and when 'pip install -U MACS2', pip downloads newest Numpy but unable to compile and install them. This will fail the whole installation. You can pass '--no-deps' option to pip and let it skip all dependencies. Type
    $ pip install -U --no-deps MACS2 

Install MACS2/any Python software into your user space

To install MACS2 globally is not always a good option, especially while you don't have permission to write to '/usr/' or /usr/local/', or you find the required Python library, Numpy, is not available in the system. Here are several options. Please use this instruction as a general guidance to install any Linux/Unix software to your own user space for full control.

Manually install Python software to your home directory

Normally, Linux/Unix users tend to install software to their home directory where they can fully control, such as '/home/foobar'. To do so with Python setup script, first, you need to setup PYTHONPATH and PATH, type:

$ export PYTHONPATH=$HOME/lib/python2.7/site-packages/:$PYTHONPATH
$ export PATH=$HOME/bin/:$PATH
then, install both Numpy and MACS2 by going to their source code directories:
$ python setup.py install --prefix=$HOME
One thing you have to remember is that PYTHONPATH and PATH need to be set, by using export commands as previously shown, every time you enter the terminal/shell. To save your time, you can put the two export commands at the bottom of your '.bashrc' file if you are using BASH.

The virtual environment

As a general recommendation to all people processing their own data on Linux/Unix and wondering how to control bioinformatics tools by themselves, the 'virtualenv' tool will help to establish a virtual environment that users can install/remove/upgrade software. The website for 'virtualenv' can be found at https://virtualenv.pypa.io/en/latest/. On the project PyPI page https://pypi.python.org/pypi/virtualenv/, you can download the source code as a tar ball. You will find a script inside to make a virtual python environment isolated from the one for whole system:

$ tar xvfz virtualenv-X.X.tar.gz
$ cd virtualenv-X.X
$ ls virtualenv.py

Now you can create your own virtual environment located anywhere you want, for example '/home/foobar/MyVE':

$ python virtualenv.py /home/foobar/MyVE

Note if you have already installed numpy system-wide, you can use 'virtualenv.py --system-site-packages /home/foobar/MyVE' to let your virtual Python environment have access to system-wide numpy library so that you don't need to install them again.

Your own virtual environment now can be activated by this command

$ source /home/foobar/MyVE/bin/activate
And you will see your shell looks like:
[MyVE]$

In this environment, you can install/remove/upgrade any software especially python software you want since 'virtualenv' has activated and set all necessary environmental variables such as PATH or PYTHONPATH for you. Another advantage is that the 'pip' command will be set especially for this virtual environment so you can install/upgrade software as what we discussed in the section "Easy installation through PyPI". For example:

[MyVE]$ pip install numpy
[MyVE]$ pip install MACS2

There is no need to ask administrators. You may be able to find some good tutorial on virtualenv on the web.