Linux基础:软件安装技巧--conda

2022-05-05  本文已影响0人  吕强强学生信

微信公众号:猪猪生信生信技能树粉丝,不断更新生树学徒作业,以及R语言和Linux学习笔记

配置conda频道

#一:官方频道
conda config --add channels bioconda 
conda config --add channels conda-forge
conda config --set show_channel_urls yes
#二:清华镜像频道
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes
#三:北外镜像频道
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes 

三种来源选取一个来源的频道配置即可,重复配置频道会造成冗余,降低软件安装速度

创建独立的环境

软件最好不要装在BASE环境里,尽量创建独立环境进行安装,这样不会造成软件依赖环境的冲突,也有利于项目管理

#列出已存在的小环境
conda env list 或  conda info --env
#创建名为rnaseq的conda小环境
conda create -n rnaseq
-n: 指定环境名称
#启动rnaseq这个conda小环境
conda activate rnaseq
#退出rnaseq这个conda小环境
conda deactivate
#删除已创建的小环境及安装的包
conda remove -n rnaseq --all
#重命名小环境,例如将Python2重命名为py2
conda create -n Python2 
conda create -n py2 --clone Python2
conda remove -n py2 --all

安装软件

创建好独立的小环境之后就可以在小环境内安装软件,首先要查找下自己想安装的软件是否可以用conda安装

  1. 网站查询
    https://anaconda.org/search
    https://bioconda.github.io/
  2. 使用命令行搜索
    conda search xxx
  3. 关键词搜索
#查询是否可以安装以及版本信息
conda search fastqc
#安装fastqc,加等号指定安装0.11.7版本的,也可以不指定
conda install fastqc=0.11.7
#加-y参数可以跳过确认步骤
conda install -y fastqc=0.11.7 
#删除软件
conda remove fastqc
#升级软件
conda update fastqc
#升级conda自身
conda update conda

conda进阶使用

#切换到base环境(确保安装在base)
conda activate base
#在base环境下安装mamba
conda install mamba

#搜索软件
mamba search fastqc
#更快搜素软件
mamba repoquery search fastqc
#安装软件
mamba install fastqc

#查看软件之间相互依赖关系
我依靠谁?
mamba repoquery depends -t samtools
谁依赖我
mamba repoquery whoneeds -t python

版本控制和迁移

方法一:用conda list的export功能

方法二:用conda env的export功能

删除没有用的包及更换镜像

#删除下载了但没有使用的包
conda clean -p
#更换镜像配置的时候记得先运行这一条
conda clean -i     

将conda安装到指定位置

#先创建一个biosoft的文件夹, 在里面创建一个samtools文件夹
mkdir -p ~/biosoft/samtools
#使用-p参数指定安装位置
conda install -p ~/biosoft/samtools samtools 

笔记总结于生信技能树B站卖萌哥2021公益课

本文使用 文章同步助手 同步

上一篇 下一篇

猜你喜欢

热点阅读