Using Package Managers | Installing Programs Manually | Install Locally Use Globally

Using Package Managers

When installing programs it is sometimes easiest to start off by checking if the programs you are interested in are available through your package manager. You can use Mac Ports if you are using a Mac or Apt if you are using a Debian Linux distribution. You will need sudo privileges to install programs using a package manager.
#Search for bowtie using mac ports
port search bowtie
bowtie @0.12.7 (science, biology)
    an ultrafast, memory-efficient short read aligner
#Install bowtie using mac ports
sudo port install bowtie
#Search for bowtie using apt
apt-cache search bowtie
bowtie - ultrafast memory-efficient short read aligner
bowtie-examples - Examples for bowtie, the ultrafast memory-efficient short read aligner
fastx-toolkit - FASTQ/A short nucleotide reads pre-processing tools
#Install bowtie using apt
sudo apt-get install bowtie

Installing Programs Manually

If you don't have sudo privileges (see section bellow for more options in this case) or don't find the program or version of the program you are interested in using a package manager you will have to install the program manually. The first thing you need to do is download the program, see the section on wget on the working on remote machines page if you need to download the program to a remote machine. Note: if you are downloading a file from sourceforge you will need to use some trickery with wget.
#Downloading bowtie from sourceforge. Use the -O flag to specify the name to download the file as.
wget "http://sourceforge.net/projects/bowtie-bio/files/bowtie/0.12.7/bowtie-0.12.7-linux-x86_64.zip/download"
-O bowtie-0.12.7-linux-x86_64.zip
After downloading the program start by looking at the README for the installation specifications. Most programs can be installed with some variation of the following sequence of commands:
#Move to the install directory
cd /install/directory
#Execute the configuration script to create the make file
./configure
#Install the program
make
#Test the installed program
make test
#Make the program globally available
sudo make install

Install Locally Use Globally

Sometimes you will not be able to use make install to create a globally available program and will have to use an absolute path whenever you need to execute the program (for instance this will happen if you don't have sudo privlages). There are several ways to make a locally installed program globally available.

With sudo:

All programs in your bin will be globally available. After locally installing a program you can symbolically link that program to your bin using the ln command with the -s flag.
#Create a symbolic link from bowtie in a local installation directory to the bin.
#Be sure to use the absolute path to the installed program.
sudo ln -s /home/ngs_programs/bowtie-0.12.7/bowtie /bin/bowtie
Now you should be able to use bowtie from any directory by issuing the command bowtie.

Without sudo:

Without sudo privileges you can add a directory that belongs to you to your PATH and use this directory just like the bin. Your PATH is a collection of places your computer looks for programs when you issue the command to execute a program without an absolute path. You can have a look at your PATH using echo.
echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
You can add a directory to your path by editing the .bashrc file. This file should be in your home directory the commands below assume that it does not exist yet.
#Create a bin folder in your home directory
mkdir /home/me/bin
#Create .bashrc in your home directory
touch ~/.bashrc
#Open the created file for editing and add the following line to add /home/me/bin to your PATH
export PATH=${PATH}:/home/me/bin
The change to your .bashrc will take effect the next time your start the terminal. Now you can use ~/bin as the install location for your programs.

If configuring is part of the installation process you can use the --prefix flag to install programs in the bin of the specified prefix directory the default is /usr/local. A complete list of flags that can be used with configure scripts can be found here.
#To install in /home/me/bin
./configure --prefix=/home/me
#Or you can just use the $HOME variable
./configure --prefix=$HOME
#You can proceed to using make and make install without sudo
You can also create symbolic links to your new bin just as described above.
#Create a symbolic link from bowtie in a local installation directory to /home/me/bin.
#Be sure to use the absolute path to the installed program.
ln -s /home/ngs_programs/bowtie-0.12.7/bowtie /home/me/bin/bowtie