Macs in Chemistry

Insanely great science

 

Creating a Bioconda recipe

A little while back I mentioned BioConda. You can read more details in this publication "Bioconda: A sustainable and comprehensive software distribution for the life sciences", DOI. Conda is a platform- and language-independent package manager that sports easy distribution, installation and version management of software.

The conda package manager has recently made installing software a vastly more streamlined process. Conda is a combination of other package managers you may have encountered, such as pip, CPAN, CRAN, Bioconductor, apt-get, and homebrew. Conda is both language- and OS-agnostic, and can be used to install C/C++, Fortran, Go, R, Python, Java etc

The bioconda channel is a Conda channel providing bioinformatics related packages for Linux and Mac OS. Looking through the packages it is clear there it already contains a number of chemistry packages. These include:

Bioconda offers a collection of over 3100 software tools, which are continuously maintained, updated, and extended by a growing global community of more than 330 contributors. Rather than try to duplicate this effort for a Chemconda" it seems more efficient to encourage chemists to contribute to Bioconda. If you do package a chemistry application for Bioconda please let me know and I'll publicise it on my blog and add it to the list above. To start things rolling I've added PubChem.py to Bioconda and hopefully the instructions below for PubChemPy will encourage people to contribute.

PubChemPy provides a way to interact with PubChem in Python. It allows chemical searches by name, substructure and similarity, chemical standardization, conversion between chemical file formats, depiction and retrieval of chemical properties.

Setup

Click "Fork" on Github bioconda-recipes

Clone the fork to local machine:

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

This local git repository has your fork as the remote called "origin".

Add the actual bioconda remote as "upstream":

git remote add upstream https://github.com/bioconda/bioconda-recipes.git

Regularly run "git pull upstream master" to pull changes from the main bioconda github repository into the local repository. Run "git push origin master" to push these changes to your github fork.

Creating a recipe

Create a new branch for a recipe:

git checkout -b pubchempy

Create a new directory for the recipe:

cd recipes
mkdir pubchempy

Simple python recipes only need a single "meta.yaml" file.

{% set version = "1.0.4" %}

package:
 name: pubchempy
 version: {{ version }}

source:
 fn: PubChemPy-{{ version }}.tar.gz
 url: https://pypi.io/packages/source/P/PubChemPy/PubChemPy-{{ version }}.tar.gz
 sha256: 24e9dc2fc90ab153b2764bf805e510b1410700884faf0510a9e7cf0d61d8ed0e

build:
  noarch: python
  number: 0
  script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:
  build:
    - python
    - setuptools
  run:
    - python

test:
  imports:
    - pubchempy

about:
  home: https://github.com/mcs07/PubChemPy
  license: MIT
  license_file: LICENSE
  summary: 'A simple Python wrapper around the PubChem PUG REST API.'
  doc_url: http://pubchempy.readthedocs.io/
  dev_url: https://github.com/mcs07/PubChemPy

Some notes about this recipe:

Building locally

To build a package locally, use conda-build. This needs to be installed:

conda install conda-build

Then build the package from the recipe:

cd recipes/pubchempy
conda build .

You can specify a specific python version if you want:

conda build . --python=3

Note that you can only build packages for your own platform. Submit to bioconda so their automated build system can build for both linux and MacOS, and upload it to anaconda.org.

Submitting a recipe

Commit the recipe:

git add recipes/pubchempy/meta.yaml
git commit -m "Add PubChemPy 1.0.4"

and push it to your remote on Github:

git push origin pubchempy

On Github, go to your fork and open a pull request against the main bioconda repository.

Once submitted, an automated build will start.

It is also worth mentioning the conda skeleton pypi/cran/cpan generators that can automatically create conda recipes from PyPI (Python), CRAN (R), and CPAN (Perl).

Using and installing bioconda recipes

Add to conda config:

conda config --add channels conda-forge
conda config --add channels bioconda

Now, when doing "conda install ...", packages and their dependencies will be resolved from these channels, with bioconda as the highest priority, followed by conda-forge, then the defaults channel..

Further reading:

Updated 24 November 2017