The `conda` or `conda-like` package and environment manager usage and practical

The conda or conda-like package and environment manager usage and practical

1. Version Differences : what are the differences between conda 、 anaconda 、 bioconda 、 miniconda ?

conda : can download and install packages and all of its dependencies. The information on where to download and what the dependencies are for each packages are stored in a database called a "channel"

bioconda : a conda channel which contains names, locations, and dependencies of many bioinformatics tools.

miniconda : slimmed-down distribution version of Anaconda. It has all the components of the Anaconda distribution, except the 200+ pre-installed data science applications.

anaconda : open-source python distribution. It is purpose-built for such applications as machine learning, data science, and large-scale data processing. This distribution includes the core python language, along with more than 200 packages, and a package management tool.

2. install miniconda

2.1 download and install packages Miniconda3-py38_4.10.3-Linux-x86_64.sh
$ bash Miniconda3-py38_4.10.3-Linux-x86_64.sh

to make the installation take effect, you should close the current terminal and re-open it.

(base) [biocodee@localhost ~]$ conda --version 
conda 4.10.3

the conda has been installed correctly.

3. find packages

use command conda search

(base) [biocodee@localhost ~]$ conda search numpy
Loading channels: done
# Name                       Version           Build  Channel             
numpy                          1.9.3 py27_nomklhbee5d10_3  pkgs/main           
numpy                          1.9.3  py27h1b885b7_7  pkgs/main           
numpy                          1.9.3  py27h28100ab_5  pkgs/main           
...
(base) [biocodee@localhost ~]$ conda config --show channels
channels:
  - conda-forge
  - bioconda
  - defaults
(base) [biocodee@localhost ~]$ conda search samtools
Loading channels: done
# Name                       Version           Build  Channel             
samtools                      0.1.12               0  bioconda            
samtools                      0.1.12               1  bioconda            
samtools                      0.1.12               2  bioconda            
samtools                      0.1.13               0  bioconda           ... 
#    
(base) [biocodee@localhost ~]$ conda search samtools | tail -n1
samtools                        1.14      hb421002_0  bioconda    

4. conda environments :

  • A (mostly) self-contained directory with a set of compatible packages
  • Uses links to reduce disk space when possible
  • Linking is relative to packages!
  • No more conflicting dependencies between versions!
Conda environments – common commands
  • lists available environments
(base) [biocodee@localhost ~]$ conda info --envs
# conda environments:
#
base                  *  /home/biocodee/miniconda3

(base) [biocodee@localhost ~]$ conda env list
# conda environments:
#
base                  *  /home/biocodee/miniconda3
  • create/remove environments : can specify packages versions and mix/max versions
##############################################################################
###new env default path 
(base) [biocodee@localhost ~]$ conda create --name=myenv python=3.8 numpy 'pysam>=0.16'
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##

  environment location: /home/biocodee/miniconda3/envs/myenv

  added / updated specs:
    - numpy
    - pysam[version='>=0.16']
    - python=3.8


The following packages will be downloaded:
...
Proceed ([y]/n)? n


CondaSystemExit: Exiting.

(base) [biocodee@localhost ~]$ conda env list
# conda environments:
#
base                  *  /home/biocodee/miniconda3


#can remove envs using cmd following : 
$ conda env remove --name=myenv

###############################################################################
### module `venv`, specifying new env path
#Specifying a location for an environment
  • activates / deactivates an environment
$ command -v samtools
$ conda activate samtools
$ command -v samtools
/home/gcb2020/conda/envs/samtools/bin/samtools
$ conda deactivate
$ command -v samtools
#disable the automatic base activation
$ conda config --set auto_activate_base false
#check conda version
[biocodee@localhost ~]$ conda --version 
conda 4.10.3
#activate conda
[biocodee@localhost ~]$ conda activate
#deactive conda
(base) [biocodee@localhost ~]$ conda deactivate
[biocodee@localhost ~]$ conda --version
conda 4.10.3
  • conda install / conda remove
  • conda list

Tip

  • Keep your base env clean! (only the package manager + its deps)
  • Generously create/remove environments for different tools/workflows!

reference :
[1] GCB 2020 Tutorial. site

[2] Conda, bioconda, anaconda, are they different? site

[3] Conda site

[4] Conda channels.site

[5] The Definitive Guide to Conda Environments.site

上一篇:查询oracle中所有用户信息


下一篇:conda channels