Tutorial:Building mosdepth on macOS
Entering edit mode
4.0 years ago
ATpoint 82k

This is just a tiny tutorial on how to build mosdepth on Mac. There is currently no version for Mac available at conda (hope that changes soon, edit (3/2021): it did change, see https://anaconda.org/bioconda/mosdepth), and from what I've read building from source was a pain so far, still these simple steps worked for me (macOS 10.14.6). mosdepth is a wickedly fast tool from brentp for depth calculations (e.g. bedGraphs) starting from BAM and CRAM files.

=> Edit: brentp now also provides binaries for macOS, see here and here. Note that these are not static binaries so htslib still needs to be installed, see below. Unpack the linked archive, chmod +x the binary, get htslib and you should be ready to go. The macOS-one is labelled 10.15 but worked for me on 10.14.6 as well. If you have trouble please add a comment to the GitHub issue.

1. Install the Nim programming language

For this use choosenim via the command:

curl https://nim-lang.org/choosenim/init.sh -sSf | sh

The script will instruct you to put the folder that contains the binaries into your PATH. On Mac this is typically done by putting this into your ~/.bash_profile:

export PATH=$HOME/.nimble/bin:$PATH

2. Get htslib

Either compile from source or get it via a package manager such as conda:

For conda it is simply:

conda install -c bioconda htslib 

Be sure it is version >= 1.10 since the current hts-nim (which mosdepth automatically installs and depends on) does not support older versions. Put the path to the library (lib) folder that contains htslib.dylib into your LD_LIBRARY_PATH, e.g when using miniconda:

export LD_LIBRARY_PATH=$HOME/miniconda3/lib

For source compilation get the source from the Github release, then cd into the folder and type make, then (while being in the htslib folder) type

export LD_LIBRARY_PATH=$HOME/$(pwd)

3. Install mosdepth

Get the source, extract it into a folder of choice and cd into the folder, then install:

nimble install -y

A mosdepth binary should now be available in this folder. Feel free to comment if problems come up.

nim mosdepth • 3.0k views
Entering edit mode

Hello, I've been following your guide on how to build mosdepth on macOS. While the guide is comprehensive, I've encountered an issue during the final nimble install -y step that I couldn't resolve. I was hoping to bring it to your attention and seek guidance on how to troubleshoot it.

The build process failed with the following error message: Verifying dependencies for d4@0.0.3 Building mosdepth/mosdepth using c backend /Users/biocode/.nimble/pkgs2/hts-0.3.23-bf17f074ce5c44d6b11faccb68239af8c179c7e1/hts/bgzf/bgzi.nim(71, 3) Error: undeclared identifier: 'shallow'

I have also tried building from a previous commit but faced the same issue.

Would appreciate any help or insights you can provide. Thank you!

Entering edit mode

Use conda (LINK) to install mosdepth directly.


Login before adding your answer.

Traffic: 1159 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6