NGS数据分析实践:01. Conda环境配置及软件安装
1. 什么是Conda?
2. 关于几个Conda
3. Conda环境管理
4. 安装Conda
wget -m https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
bash Anaconda3-5.3.1-Linux-x86_64.sh #安装下载的sh文件
5. 配置仓库镜像
#一:官方频道
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
conda config --set ssl_verify False
6. 创建conda小环境
#base环境:
source ~/anaconda3/bin/activate #conda activate /home/hucy/anaconda3
conda create -n SNPseq #创建名为SNPseq的conda小环境 #-n:指定环境名称
conda env list # 或 conda info --env # 列出已存在的小环境
conda activate SNPseq #启动SNPseq这个conda小环境
conda activate base #切换到base环境(确保安装在base)
conda deactivate #退出SNPseq这个conda小环境
如需删除conda小环境及安装的包:
conda remove -n SNPseq --all
#重命名小环境,例如将Python2重命名为py2
conda create -n Python2
conda create -n py2 --clone Python2
conda remove -n py2 --all
7. conda环境安装软件
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 install -c bioconda fastqc -y #fastqc --help
conda install -c bioconda -c conda-forge multiqc #pip install multiqc
conda install -c bioconda fastp -y #https://www.jianshu.com/p/10d8daa57d1d
conda install -c bioconda fastx_toolkit -y #/home/hucy/anaconda3/envs/SNPseq/bin/fastx_clipper -h
conda install -c bioconda solexaqa -y
conda install -c bioconda trimmomatic -y
conda install -c bioconda hisat2 -y #HISAT2 is a fast and sensitive alignment program for mapping next-generation sequencing reads (both DNA and RNA) to a population of human genomes as well as to a single reference genome.
conda install bwa -y
conda install -c bioconda bowtie2 -y
conda install samtools -y
conda install -c bioconda picard -y
conda install -c bioconda bedtools -y
conda install -c bioconda snpeff -y
conda install -c bioconda bcftools -y
conda install -c bioconda freebayes -y
conda install -c bioconda varscan -y
conda install -c bioconda gatk -y
conda install -c bioconda gatk4 -y
# GenomeAnalysisTK -h 与gatk3 -h 显示结果一样
GenomeAnalysisTK -h
gatk3 -h
8. 设置环境变量
# 直接将conda的软件安装路径,写入.bashrc
export PATH="/home/hucy/anaconda3/envs/SNPseq/bin:$PATH"
#export是临时的,关闭终端就没有了,需写入~/.bashrc
cp ~/.bashrc{,.bak} # 修改系统文件.bashrc前,可以先快速备份一下
vim ~/.bashrc
# export PATH="/home/hucy/anaconda3/envs/SNPseq/bin:$PATH"
source ~/.bashrc #载入修改后的环境
echo $PATH
9. 创建软链接
mkdir ~/.soft #或创建一个文件夹,存储各种软件绝对路径的软链接,以便分享给Linux的其他用户
export PATH="/home/hucy/.soft:$PATH" #同理,可以将export PATH="/home/hucy/.soft:$PATH"写入root或者其他用户的.bashrc文件,以免重复安装过多软件。
which bwa #查找bwa的绝对路径
which samtools
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/fastqc ~/.soft #创建conda中已装软件的软链接
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/multiqc ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/trimmomatic ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/SolexaQA++ ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/bwa ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/bowtie2 ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/hisat2 ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/samtools ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/bedtools ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/picard ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/bcftools ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/gatk3 ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/gatk4 ~/.soft
# ln -s /home/hucy/anaconda3/envs/SNPseq/bin/GenomeAnalysisTK ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/varscan ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/freebayes ~/.soft
ln -s /home/hucy/anaconda3/envs/SNPseq/bin/snpEff ~/.soft
source ~/.bashrc
# ln -s /home/hucy/anaconda3/envs/SNPseq/share/picard-2.18.29-0/picard.jar ~/.soft
# ln -s /home/hucy/anaconda3/envs/SNPseq/share/snpeff-5.0-1/snpEff.jar ~/.soft
# ln -s /home/hucy/anaconda3/envs/SNPseq/share/varscan-2.4.4-1/VarScan.jar ~/.soft
10. 其他软件安装
# tar 解压缩命令详解 https://blog.csdn.net/example440982/article/details/51712973
# /home/hucy/biosoft/src
wget -c http://www.openbioinformatics.org/annovar/download/--apply--/annovar.latest.tar.gz
tar -zxvf ~/biosoft/src/annovar.latest.tar.gz -C ../
cd ~/biosoft/annovar/
perl /home/hucy/biosoft/annovar/annotate_variation.pl
11. 其他环境配置
# 0表示没有权限,1表示可执行权限,2表示可写权限,4表示可读权限,然后将其相加。
alias condaBase='source ~/anaconda3/bin/activate' #重命名简化激活condaBase环境命令
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/hucy/.dotnet/tools:/usr/local/java/bin:.:~"
export PATH="/home/hucy/anaconda3/envs/SNPseq/bin:$PATH"
export PATH="/home/hucy/.soft:$PATH"
# annovar 别名设置,简化命令行
vim ~/.bashrc
alias convert2annovar.pl="/home/hucy/biosoft/annovar/convert2annovar.pl"
alias annotate_variation.pl="/home/hucy/biosoft/annovar/annotate_variation.pl"
alias table_annovar.pl="/home/hucy/biosoft/annovar/table_annovar.pl"
alias coding_change.pl="/home/hucy/biosoft/annovar/coding_change.pl"
alias retrieve_seq_from_fasta.pl="/home/hucy/biosoft/annovar/retrieve_seq_from_fasta.pl"
alias variants_reduction.pl="/home/hucy/biosoft/annovar/variants_reduction.pl"
source ~/.bashrc
12. conda其他应用
12.1 版本控制和迁移
conda list -n rnaseq --export > conda_rnaseq_list.txt
# 输出文件格式:软件名=版本号=build
# 安装导出的信息
conda create -n rna -file conda_rnaseq_list.txt
conda env export -n rnaseq > rnaseq.yml
# 根据导出的yml文件创建环境
conda env create -f rnaseq.yml
# 根据导出的yml文件更新环境
conda env update -f rnaseq.yml # yml文件提供的信息更全面
12.2 删除没有用的包及更换镜像
conda clean -p
#更换镜像配置的时候记得先运行这一条
conda clean -i
12.3 将conda安装到指定位置
mkdir -p ~/biosoft/samtools
#使用-p参数指定安装位置
conda install -p ~/biosoft/samtools samtools
可重复的生信分析系列二:Conda的介绍
生信分析平台搭建(七):bioconda
conda的安装与使用(2021-04-27更新)
Linux基础:软件安装技巧–conda