Anaconda-生信软件安装和管理的必备
在Linux系统下,不同软件包之间如果没有一个单独的环境,很容易发生安装冲突。比如某个软件基于Python2开发,另一个基于Python3,安装时就会产生冲突。因此,必须将它们隔离在单独的环境中安装运行。好比Van和魔男进了同一个更衣室,肯定要大♂战300回合。
一山难容二虎
Docker是一个很好的解决方案,但对很多软件来说没必要这么麻烦(其实是笔者还不怎么会用...)。而Anaconda作为一个开源的Python包管理软件,类似于手机上的应用商店,可以很好地安装管理这些包,每个包可以在单独的环境下运行,之间互相隔离,解决了兼容的问题。对于新手来说,精简版的miniconda即可满足大部分的需求。
下载与安装
首先,wget命令下载最新的miniconda3 linux-x86_64 安装脚本。
wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
图片切换到安装脚本所在的文件夹,bash命令运行脚本
bash Miniconda3-latest-Linux-x86_64.sh
安装完毕后,更新系统环境
source ~/.bashrc
输入conda -h命令检查是否安装成功
root@LAPTOP-VINCENT:~# conda -h
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
positional arguments:
command
clean Remove unused packages and caches.
compare Compare packages between conda environments.
config Modify configuration values in .condarc. This is modeled after the git config command. Writes to
the user .condarc file (/root/.condarc) by default. Use the --show-sources flag to display all
identified configuration locations on your computer.
create Create a new conda environment from a list of specified packages.
info Display information about current conda install.
init Initialize conda for shell interaction.
install Installs a list of packages into a specified conda environment.
list List installed packages in a conda environment.
package Low-level conda package utility. (EXPERIMENTAL)
remove (uninstall)
Remove a list of packages from a specified conda environment.
rename Renames an existing environment.
run Run an executable in a conda environment.
search Search for packages and display associated information.The input is a MatchSpec, a query
language for conda packages. See examples below.
update (upgrade) Updates conda packages to the latest compatible version.
notices Retrieves latest channel notifications.
options:
-h, --help Show this help message and exit.
-V, --version Show the conda version number and exit.
conda commands available from other packages (legacy):
content-trust
env
更换国内镜像源
和apt一样,conda也是需要换源,才能保证下载的速度。这里以浙大镜像为例,首先找到用户文件夹下的.condarc文件,用vim打开换成以下内容
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.zju.edu.cn/anaconda/pkgs/main
- https://mirrors.zju.edu.cn/anaconda/pkgs/r
- https://mirrors.zju.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.zju.edu.cn/anaconda/cloud
msys2: https://mirrors.zju.edu.cn/anaconda/cloud
bioconda: https://mirrors.zju.edu.cn/anaconda/cloud
menpo: https://mirrors.zju.edu.cn/anaconda/cloud
pytorch: https://mirrors.zju.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.zju.edu.cn/anaconda/cloud
simpleitk: https://mirrors.zju.edu.cn/anaconda/cloud
按ESC,输入wq保存退出。运行以下命令清除缓存
conda clean -i
创建环境&安装软件
以安装snippy为例,首先输入以下命令
(base) root@LAPTOP-VINCENT:~# conda create -n snippy
创建完毕后,激活snippy环境
root@LAPTOP-VINCENT:~# conda activate snippy
(snippy)root@LAPTOP-VINCENT:~# 激活后括号里会显示snippy
再用search命令找一下conda里是否有这个软件
Loading channels: done
# Name Version Build Channel
snippy 2.9 1 bioconda
snippy 2.9 pl5.22.0_0 bioconda
snippy 3.0 0 bioconda
snippy 3.0 1 bioconda
snippy 3.0 pl5.22.0_1 bioconda
snippy 3.1 0 bioconda
snippy 3.1 4 bioconda
snippy 3.1 pl5.22.0_1 bioconda
snippy 3.1 pl5.22.0_2 bioconda
snippy 3.1 pl5.22.0_3 bioconda
snippy 3.2 pl5.22.0_1 bioconda
snippy 4.0.2 0 bioconda
snippy 4.0.5 0 bioconda
snippy 4.0.7 0 bioconda
snippy 4.1.0 0 bioconda
snippy 4.2.3 0 bioconda
snippy 4.3.3 0 bioconda
snippy 4.3.5 0 bioconda
snippy 4.3.6 0 bioconda
snippy 4.4.0 0 bioconda
snippy 4.4.0 1 bioconda
snippy 4.4.0 2 bioconda
snippy 4.4.1 0 bioconda
snippy 4.4.3 0 bioconda
snippy 4.4.3 1 bioconda
snippy 4.4.5 0 bioconda
snippy 4.4.5 1 bioconda
snippy 4.5.0 0 bioconda
snippy 4.5.1 0 bioconda
snippy 4.6.0 0 bioconda
snippy 4.6.0 hdfd78af_1 bioconda
snippy 4.6.0 hdfd78af_2 bioconda
snippy 4.6.0 hdfd78af_3 bioconda
输入安装命令,即可安装snippy软件了,可以指定安装版本
conda install -c bioconda snippy
使用时,激活snippy的环境即可