Tutorial:How to Install SamTools, HTSLib, and BCFTools on Ubuntu 18.04
1
46
Entering edit mode
4.4 years ago
otwtgin2010 ▴ 500

Just thought I would contribute this since figuring it all out was a super confusing process consisting of a few hundred google searches. It's likely it was just me, but maybe there are a few other people like me who will benefit from being able to avoid the process. This was a clean Ubuntu 18.04 install. Probably most people do not have that luxury.

Install Updates and Required Packages

sudo apt-get update
sudo apt-get install gcc
sudo apt-get install make
sudo apt-get install libbz2-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libncurses5-dev 
sudo apt-get install libncursesw5-dev
sudo apt-get install liblzma-dev

Install HTSLIB

cd /usr/bin
wget https://github.com/samtools/htslib/releases/download/1.9/htslib-1.9.tar.bz2
tar -vxjf htslib-1.9.tar.bz2
cd htslib-1.9
make

Install SAMTOOLS

cd ..
wget https://github.com/samtools/samtools/releases/download/1.9/samtools-1.9.tar.bz2
tar -vxjf samtools-1.9.tar.bz2
cd samtools-1.9
make

Install BCFTools

cd ..
wget https://github.com/samtools/bcftools/releases/download/1.9/bcftools-1.9.tar.bz2
tar -vxjf bcftools-1.9.tar.bz2
cd bcftools-1.9
make

Export To Path And Refresh

export PATH="$PATH:/usr/bin/bcftools-1.9"
export PATH="$PATH:/usr/bin/samtools-1.9"
export PATH="$PATH:/usr/bin/htslib-1.9"
source ~/.profile
samtools bcftools htslib Tutorial • 65k views
ADD COMMENT
11
Entering edit mode

Thank you otwtgin2010 for the work. Others may benefit from it, if they want to compile these softwares from source. Another option would be to use the Anaconda package manager. With conda, things are as easy as conda install -c bioconda samtools, taking care of the dependencies internally.

ADD REPLY
3
Entering edit mode

Good direction to find an installer package for Samtools. As an FYI based on the original poster, here is the full instructions for Noobs:

Note that the installer for Conda is for the Python2.7, 64-bit version. Select the appropriate path for something else. The Conda installer takes care of other dependencies including Python itself. It could be even simpler if they registered an install package for Miniconda in APT :)

sudo apt-get update
wget https://repo.anaconda.com/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh
rm Miniconda2-latest-Linux-x86_64.sh
source ~/.bashrc
conda install -c bioconda samtools bcftools
ADD REPLY
1
Entering edit mode

This is the best way to go about it, IMO. Neither apt-get nor brew allow creating environments.

ADD REPLY
1
Entering edit mode

+1 for sharing your experiences with other users. Keep on contributing!

As Ram said, in this case one should follow the instruction given by the authors of the program.

fin swimmer

ADD REPLY
0
Entering edit mode

this was super helpful for my attempt to get HTSlib working

ADD REPLY
0
Entering edit mode

That was an extremely helpful walk-through. I've been trying to install BCFtools following their guidelines, but failing miserably (the operation would stop due to not finding curl:curl.h directory). Now, it has worked just fine.

And sorry for the lay question - I am still taking slow steps in learning Unix - but what is the meaning of the last step, "export to path and refresh"? I tried looking on the export --help, but I am still quite not sure what it does.

Many thanks, @otwtgin2010 !

ADD REPLY
2
Entering edit mode

It means that you have to put the folder where the executable is in into your .bashrc or .bash_profile like

export PATH=$PATH:/path/to/folder/with/executable

Still, it would be easier to use a package manager such as conda.

ADD REPLY
0
Entering edit mode

The reason why you got an error when building bcftools was that there is one missing dependency. Adding one more following then you will be fine:

apt-get install -y libcurl4-openssl-dev
ADD REPLY
0
Entering edit mode

I just wanted to thank you! This still works as of 12/21/21 and version 1.14 for all software

ADD REPLY
4
Entering edit mode
4.4 years ago
Ram 37k

EDIT

Wait, you're using apt-get to install prerequisites but not the actual software you need? Why is that? Pretty sure samtools is available on apt-get.


source ~/.profile might override your $PATH settings if there is a statement in the profile file that overwrites (not appends to) the $PATH variable. You're better off with, say:

mkdir ~/myBinaries/
cd ~/myBinaries/
find /usr/bin/bcftools-1.9/ -type f -executable | xargs -I v_b ln -s v_b ./
find /usr/bin/samtools-1.9/ -type f -executable | xargs -I v_b ln -s v_b ./
find /usr/bin/htslib-1.9/ -type f -executable | xargs -I v_b ln -s v_b ./
cd -
echo 'export PATH=$PATH:~/myBinaries' >>~/.profile
source ~/.profile

Or, use a package manager and not worry about adding stuff to $PATH :-)

ADD COMMENT
1
Entering edit mode

Got it - thank-you for the clarification! i tried apt-get but it was installing old versions. And the old versions were super buggy and didn't work with a lot of my sample files.

ADD REPLY
1
Entering edit mode

I see. Also, this information is available directly on the htslib site: http://www.htslib.org/download/

Plus the post contains less information than what's available on that site. Why create this post?

ADD REPLY
1
Entering edit mode

Thanks. Yeah, for someone who knows as much as they should, that would no doubt be plenty. But i guess for those who knows as little as i do :) - the things like how you download the file, how you extract it (or even that you need to extract it), that you need "make" installed are not self-evident.

ADD REPLY
1
Entering edit mode

You're right, but that's a rabbit hole. We have to stick to some pre-requisites that we can assume people that come here know. Command line basics is one of them. How to download a file (not necessarily using the command line), un-archive it (tar options, computer science stuff), cd into directories, know sudo stuff, etc. People who do not know that should be working with bioinformaticians who do and learning in the process, not searching online.

ADD REPLY
1
Entering edit mode

Thanks and true! i guess i have a tendency to create my roof before my foundation, and the assumption that most others are the same way is an invalid one. And i don't mean this to be my personal beef about documentation that is not sufficient enough to make up for my lack of basic knowledge. Just hoping it will help someone else.

ADD REPLY
0
Entering edit mode

Not every beginner has access to bioinformaticians who come from CS. And some of us who've spent decades in biology are still beginners in bioinformatics. I learned a lot from this thread - both the original post and the comments that followed. I can see the perspective of a basal level of required knowledge, but not every bioinformatics expert is a good teacher, and even if they are good teachers, they are busy people. People who invest time in online forums like biostars are sharing people and make the world of science a better place. Thanks to everyone who contributed to this thread.

ADD REPLY

Login before adding your answer.

Traffic: 1468 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6