auto_process_ngs.conda

Module providing utility classes and functions to help with managing conda environments:

  • CondaWrapper: wrapper for conda, including environment creation

  • CondaWrapperException: base class for exceptions from CondaWrapper

  • CondaCreateEnvError: exception for errors when creating environments

  • make_conda_env_name: construct consistent names for conda environments

exception auto_process_ngs.conda.CondaCreateEnvError(message=None, env_name=None, status=None, cmdline=None, output=None)

Exception raised when CondaWrapper class fails to create a new environment

Parameters:
  • message (str) – error message

  • env_name (str) – name of the environment

  • status (int) – status returned by the conda command

  • cmdline (str) – command line for the conda command that generated the error

  • output (str) – output from the conda command

class auto_process_ngs.conda.CondaWrapper(conda=None, env_dir=None, channels=None)

Class for installing conda and creating environments

Example usage:

>>> conda = Conda('/usr/local/miniconda/bin/conda',
...               channels=('bioconda','conda-forge'),
...               env_dir='_conda_envs')
>>> conda.install()
>>> conda.create_env('multiqc@1.9','multiqc=1.9')
activate_env_cmd(name)

Fetch command to activate a conda environment

Parameters:

name (str) – name/path of the environment to activate

Returns:

Command instance to activate the

named environment.

Return type:

Command

property conda

Path to conda executable

create_env(name, *packages, **args)

Create a new conda environment

Parameters:
  • name (str) – name of the new environment

  • packages (list) – package specifications for packages to install (e.g. ‘fastqc=0.11.3’)

property env_dir

Path to the directory for conda environments

install()

Install conda

Downloads and runs the miniconda installer if conda is not already installed

property is_installed

Check whether conda is installed

property list_envs

Return a list of environments in the ‘envs’ directory

verify_env(name)

Check whether conda environment can be activated

Parameters:

name (str) – name/path of the environment to check

Returns:

True if activate command returned status

zero, False otherwise.

Return type:

Boolean

property version

Return the conda version

exception auto_process_ngs.conda.CondaWrapperError

Base class for conda-specific exceptions

auto_process_ngs.conda.make_conda_env_name(*pkgs)

Return a name for a conda env based on package list

Constructs a name for a conda environment, based on the packages specified for inclusion in the environment.

The name consists of components of the form “NAME[@VERSION]” for each package specification “NAME[=VERSION]” (e.g. ‘star=2.4.2a’ becomes ‘star@2.4.2a’).

Components are joined by ‘+’ and are sorted by package name (regardless of the order they are supplied in).

Parameters:

pkgs (list) – list of conda package specifiers

Returns:

environment name constructed from package

list.

Return type:

String