Skip to content

Instantly share code, notes, and snippets.

@adefelicibus
Last active April 3, 2024 20:49
Show Gist options
  • Save adefelicibus/f6fd06df1b4bb104ceeaccdd7325b856 to your computer and use it in GitHub Desktop.
Save adefelicibus/f6fd06df1b4bb104ceeaccdd7325b856 to your computer and use it in GitHub Desktop.
Install samtools, bcftools and htslib on linux

Install Samtools, BCFTools and htslib on linux

Install some build dependencies

sudo apt-get install autoconf automake make gcc perl zlib1g-dev libbz2-dev liblzma-dev libcurl4-gnutls-dev libssl-dev libncurses5-dev
$ wget https://github.com/samtools/samtools/releases/download/1.3.1/samtools-1.3.1.tar.bz2 -O samtools.tar.bz2
$ tar -xjvf samtools.tar.bz2
$ cd samtools-{version}
$ make
$ sudo make prefix=/usr/local/bin install
# if you have old version such as 0.x from samtools, you may remove it and create a link to new version
$ sudo apt remove samtools
$ sudo ln -s /usr/local/bin/bin/samtools /usr/bin/samtools
# Or, you can just use the path to call samtools
$ /usr/loca/bin/bin/samtools -h
$ wget https://github.com/samtools/bcftools/releases/download/1.3.1/bcftools-1.3.1.tar.bz2 -O bcftools.tar.bz2
$ tar -xjvf bcftools.tar.bz2
$ cd bcftools-{version}
$ make
$ sudo make prefix=/usr/local/bin install
$ sudo ln -s /usr/local/bin/bin/bcftools /usr/bin/bcftools
$ wget https://github.com/samtools/htslib/releases/download/1.3.2/htslib-1.3.2.tar.bz2 -O htslib.tar.bz2
$ tar -xjvf htslib.tar.bz2
$ cd htslib-{version}
$ make
$ sudo make install
@lowrymj
Copy link

lowrymj commented Dec 7, 2020

@zsewa Your proposal worked perfectly. I was struggling with the installation of dependencies. I appreciate your contribution!

@MjelleLab
Copy link

error in text: $ /usr/loca/bin/bin/samtools -h
should be: $ /usr/local/bin/bin/samtools -h

@phancanhtrinh
Copy link

After I run this: $ sudo make prefix=/usr/local/bin install
I got result below. It might be run well. But when I call samtools --- Command 'samtools' not found, but can be installed with:
Please help me

mkdir -p -m 755 /usr/local/bin/bin /usr/local/bin/bin /usr/local/bin/share/man/man1
install -p samtools /usr/local/bin/bin
install -p misc/ace2sam misc/maq2sam-long misc/maq2sam-short misc/md5fa misc/md5sum-lite misc/wgsim /usr/local/bin/bin
install -p misc/blast2sam.pl misc/bowtie2sam.pl misc/export2sam.pl misc/fasta-sanitize.pl misc/interpolate_sam.pl misc/novo2sam.pl misc/plot-ampliconstats misc/plot-bamstats misc/psl2sam.pl misc/sam2vcf.pl misc/samtools.pl misc/seq_cache_populate.pl misc/soap2sam.pl misc/wgsim_eval.pl misc/zoom2sam.pl /usr/local/bin/bin
install -p -m 644 doc/samtools*.1 misc/wgsim.1 /usr/local/bin/share/man/man1

Thank you very much!

@adefelicibus
Copy link
Author

@phancanhtrinh have you installed the dependencies?
Algo, I didn't understand why you needed to make the directories in the first row.
Could you post here all the commands you used?
You can algo install all these packages using conda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment