A note on getting start with samtools on Mac OsX 10.8.5 Mountain Lion

samtools is a handy tool for sequence alignment and mapping (http://samtools.sourceforge.net/

For more information, please refer to the original article here:

  • Li H.*, Handsaker B.*, Wysoker A., Fennell T., Ruan J., Homer N., Marth G., Abecasis G., Durbin R. and 1000 Genome Project Data Processing Subgroup (2009) The Sequence alignment/map (SAM) format and SAMtools. Bioinformatics, 25, 2078-9. [PMID: 19505943]

To get it to work on mac, I’ve decided to compile it.

First, get the sourcecode from http://sourceforge.net/projects/samtools/files/samtools/

Then, decompress the files in ~/bin

Compile it as usual

make install

You might need to have administrative right to write to system folder as well.

Next, we'll need to add a path to ~/.bash_profile

Include this in ~/.bash_profile to point to SAMTOOLS_HOME

export SAMTOOLS_HOME=~/bin/samtools-0.1.19
export PATH=$SAMTOOLS_HOME/bcftools/:$PATH

Now, samtools should be ready for you to use.


Download files from a webpage with wget.

Recently phylotree just release another update of mitochndrial phylogentic trees (19Feb2014). Besides the updated tree, a very nice feature of http://www.phylotree.org website is that they have a great curation of mitochondrial sequences publicly available for download. You can check out their website here http://www.phylotree.org/mtDNA_seqs.htm

If you have a curious mind, you may want to download all the sequences, construct your own trees or use the data to do something else creatively.

In this case wget might be your best friends, although you might be able to write a python script to do something similar.

 wget -r --accept "*.ext" --level 2 http://www.website.com/pagewithLink.html

As a reminder, if you are behind a proxy firewall, take a look at my previous post  https://bhoom.wordpress.com/2013/07/26/how-to-wget-with-proxy-authentication/


Converting virtual machine raw image .img to vmdk

OK, you got “.img” virtual machine image. Now what?
Diving in VMWare, Oracle Virutal Machine, etc, etc, there is not a shadow of the option to choose “new virutal machine” from .img image.

What should I do?

1. Download Qemu (ported version for OSX) http://www.kju-app.org/

2. After installing it on Mac (works fine for me on Maverick),

cd /Application/Q.app/Contents/MacOS/qemu-img
./qemu-img convert -f raw -O vmdk /Volumes/xxx/rawdisk200gb.img /Volumes/xxx/vdisk200gb.vmdk

3. Next, open up vmware to create a new virtual machine.
4. Choose continue without disk > choose an existing virtual disk
5. Follow the instruction to start up your new machine 🙂

Thanks to http://www.igorkromin.net/?x=entry:entry130909-170324 for written up the solution for mac.