brown and black snake on brown tree branch

How to Locally Build and Test a Bioconda Program

in

— 2 reads

Bioconda is a curated set of packages and programs useful in computational biology and bioinformatics. It’s similar to Anaconda, or more accurately, a channel of Conda, providing platform-independent bioinformatics related packages.

I came to fully appreciate the Conda package manager for Python and R (and some other command-line tools) once I started heavily analyzing biological big data in a cluster computing facility. Since different programs can have different dependencies, having them available in isolated virtual environments and keeping them separated from one another made total sense, because in this way one software does not conflict with another.

Sometime you write your own software and want to make it available via bioconda.

Let’s say you have written your own software and want to make it available via Bioconda. For that, you need functional software in the first place. Additionally, you will need a recipe and build script, which will list the required dependencies and provide instructions to install them. When a user installs your package, these files essentially tell conda to follow the recipe, install the dependencies, and build the environment so that the user can run the software you wrote.

Ideally, you would fork the existing Bioconda recipe GitHub repository, create a new subdirectory for your software under recipes, and add the recipe and build script there. Once you have your recipe and build script ready, you need to submit a pull request to the Bioconda GitHub repository. This will initiate an automatic test that will build your program, allowing you to download the build, install it, and test if your software works in a new environment.

Alternatively you can make your own build as well. Making your own build in a local computer has some benefit. For example, the Azure CI platform which is used by bioconda can be down. It may take a while to make a build, or you may hit a resource limitation.

To locally build your bioconda software, do the following:

  1. Fork bioconda-recipie. Make your changes and commit them. For example, I was working with this fork: https://github.com/acarafat/bioconda-recipes

2. Now, on your local machine, make a new empty environment.

conda create -n bioconda

3. Activate it.

conda activate bioconda

4. Clone your bioconda fork in a suitable location.

git clone https://github.com/acarafat/bioconda-recipes

5. Enter in the local repository:

cd bioconda-recipes/

6. Let’s build it:

bioconda-utils build --packages beav

If you have docker installed, you can also use:

bioconda-utils build --docker --mulled-test --packages beav

If the build is successful, the files will be saved a location like this: ~/home/opt/conda/envs/bioconda/conda-bld

7. Okay now that you have a build, you want to install your software in a new environment, and test if it is working properly. For that, let’s make a new conda environment:

conda deactivate # sign off from bioconda environment
conda create -n conda_test
conda activate conda_test

8. Now install new package. The trick here is, we will be installing the conda build from previous step sitting in the bioconda environment, inside the new `conda_test` environment:

conda install -c ~/home/opt/conda/envs/bioconda/conda-bld my_package

For faster resolving and installation of the environment, use mamba:

mamba install -c ~/home/opt/conda/envs/bioconda/conda-bld my_package

Now your software should be installed from this build. Test it, and if everything looks good, release the update in bioconda!

This is originally written for myself, but I hope this is also useful for you!


Comments

Leave a Reply

Join as a subscriber

Only the posts on data visualization, bioinformatics how to tutorials, web-development, and general comments on research and science will be sent.

Join 10 other subscribers