美文网首页
conda安装软件与环境管理

conda安装软件与环境管理

作者: shine_9457 | 来源:发表于2021-01-31 09:14 被阅读0次
    利用bioconda 安装生物信息软件

    通过conda安装软件,首先从官网查找该软件是否被conda支持;若可以:
    输入以下的命令进行安装:conda install -y fastqc(软件名)
    使用 which softname或者find -name softname可以查看软件位置

    安装指定版本的软件

    conda install softname=1.0 1.0代指版本
    先使用conda search softname参看当先版本。

    使用conda建立环境

    conda可以建立不同的环境,每种环境单独存在,互不干扰。
    最好为不同的处理和软件建立不同的环境conda官网说明

    • 建立一个新环境
      conda create -n myenv #参数-n代表设置环境名称,myenv是具体的环境名,可以替换成自己想要的名称
    • 建立一个新环境,同时指定该坏境中python的版本(看软件的要求)
      conda create -n myenv python=2.7
    • 还可以建立环境的同时安装软件
      conda create -n myenv
      conda create -n myenv Scipy=0.15.0
    • 环境建立成功后,会提示环境的激活和关闭的方法 #要记住
      source activate myenv
      deactivate myenv
    • 查看已有的环境
      conda info --envs
    • 删除某个环境
      conda remove -n myenv --all
    • 或者更加粗暴
      rm -rf ~/miniconda3/envs/myenv/ #该路径是要删除的环境所在的路径

    在这里我想分享一下之前自己遇到的一个BUG;# 与软件以及Python版本密切相关(虽然到现在我也不知道是为什么,但是希望我给出的方案能够帮到和我一样情况的小白)

    deeptools-ImportError.png
    当时遇到这个问题,查了一些网上的资料,并没有解决;于是请教了一位老师,给出的点拨是:是服务器的依赖库有问题;导致的软件没发使用。
    现在仔细的检查报错的信息,发现__init__.py标识;补充一点知识点:__init__.py是Python中package的标识。
    报错情况:
    (chipseq) [yangjy@GSCG01 ~]$  bamCoverage -h
    Traceback (most recent call last):
      File "/home/yangjy/miniconda3/envs/chipseq/bin/bamCoverage", line 6, in <module>
        from deeptools import writeBedGraph
      File "/home/yangjy/miniconda3/envs/chipseq/lib/python2.7/site-packages/deeptools/writeBedGraph.py", line 8, in <module>
        from deeptools.countReadsPerBin import getCoverageOfRegion, getSmoothRange
      File "/home/yangjy/miniconda3/envs/chipseq/lib/python2.7/site-packages/deeptools/countReadsPerBin.py", line 7, in <module>
        import bamHandler
      File "/home/yangjy/miniconda3/envs/chipseq/lib/python2.7/site-packages/deeptools/bamHandler.py", line 3, in <module>
        import pysam
      File "/home/yangjy/miniconda3/envs/chipseq/lib/python2.7/site-packages/pysam/__init__.py", line 5, in <module>
        from pysam.libchtslib import *
    ImportError: libhts.so.2: cannot open shared object file: No such file or directory
    
    正常情况:
    (deeptools) [yangjy@GSCG01 ~]$ bamCoverage -h
    usage: An example usage is:$ bamCoverage -b reads.bam -o coverage.bw
    
    This tool takes an alignment of reads or fragments as input (BAM file) and generates a coverage track (bigWig or bedGraph) as output. The coverage is
    calculated as the number of reads per bin, where bins are short consecutive counting windows of a defined size. It is possible to extended the length of
    the reads to better reflect the actual fragment length. *bamCoverage* offers normalization by scaling factor, Reads Per Kilobase per Million mapped reads
    (RPKM), counts per million (CPM), bins per million mapped reads (BPM) and 1x depth (reads per genome coverage, RPGC).
    
    Required arguments:
      --bam BAM file, -b BAM file
                            BAM file to process (default: None)
    
    Output:
      --outFileName FILENAME, -o FILENAME
                            Output file name. (default: None)
      --outFileFormat {bigwig,bedgraph}, -of {bigwig,bedgraph}
                            Output file type. Either "bigwig" or "bedgraph". (default: bigwig)
    
    Optional arguments:
      --help, -h            show this help message and exit
      --scaleFactor SCALEFACTOR
                            The computed scaling factor (or 1, if not applicable) will be multiplied by this. (Default: 1.0)
    
    Read coverage normalization options:
      --effectiveGenomeSize EFFECTIVEGENOMESIZE
                            The effective genome size is the portion of the genome that is mappable. Large fractions of the genome are stretches of NNNN that
                            should be discarded. Also, if repetitive regions were not included in the mapping of reads, the effective genome size needs to be
                            adjusted accordingly. A table of values is available here:
                            http://deeptools.readthedocs.io/en/latest/content/feature/effectiveGenomeSize.html . (default: None)
    
    Read processing options:
      --extendReads [INT bp], -e [INT bp]
                            This parameter allows the extension of reads to fragment size. If set, each read is extended, without exception. *NOTE*: This
                            feature is generally NOT recommended for spliced-read data, such as RNA-seq, as it would extend reads over skipped regions.
                            *Single-end*: Requires a user specified value for the final fragment length. Reads that already exceed this fragment length will
                            not be extended. *Paired-end*: Reads with mates are always extended to match the fragment size defined by the two read mates.
                            Unmated reads, mate reads that map too far apart (>4x fragment length) or even map to different chromosomes are treated like
                            single-end reads. The input of a fragment length value is optional. If no value is specified, it is estimated from the data (mean
                            of the fragment size of all mate reads). (default: False)
                         ...........................
    

    注:这里使用的是deeptools软件
    可以注意到两个的conda环境不同;报错时我激活的是chipseq的conda环境;而正常时 我激活的是deeptools的conda环境----------这中间经历了什么呢?

    • 首先,我使用conda重新安装了deeptools;
    • 尝试刚刚的命令,同样的报错
    • 老师让我查看了deeptools的版本
    (chipseq) [yangjy@GSCG01 ~]$ conda list deeptools
    # packages in environment at /home/yangjy/miniconda3/envs/chipseq:
    #
    # Name                    Version                   Build  Channel
    deeptools                 1.5.9.1                       0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
    
    #重点来了:Version = 1.5.9.1

    而最新的deeptools有:

    (chipseq) [yangjy@GSCG01 ~]$ conda search deeptools
    Loading channels: done
    # Name                       Version           Build  Channel
    deeptools                    1.5.8.2               0  anaconda/cloud/bioconda
    deeptools                    1.5.9.1               0  anaconda/cloud/bioconda
    deeptools                      2.0.0          py27_0 
    .......................... 此处省略x.x.x版本 。。。en........
    deeptools                      3.4.2            py_0  anaconda/cloud/bioconda
    deeptools                      3.4.3            py_0  anaconda/cloud/bioconda
    deeptools                      3.5.0            py_0  anaconda/cloud/bioconda
    

    所以我的版本是最低的;

    • 于是我使用了 conda update deeptools,but=====>
      怎么也更新不了???
      update deeptools
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    (chipseq) [yangjy@GSCG01 ~]$ conda list deeptools
    #
    # Name                    Version                   Build  Channel
    deeptools                 1.5.9.1                       0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
    
    • 再更新(重复了三次)还是一样的版本,还是不能bamCoverage -h正常的显示。
    • 随后,使用conda install deeptools=3.5.0#指定安装版本;
      but----it still Version = 1.5.9.1;
      bug
    (chipseq) [yangjy@GSCG01 ~]$ conda install deeptools=3.5.0
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.
    Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.
    Solving environment: -
    Found conflicts! Looking for incompatible packages.                                                                                                        failed
    
    UnsatisfiableError: The following specifications were found
    to be incompatible with the existing python installation in your environment:
    
    Specifications:
    
      - deeptools=3.5.0 -> python[version='>=3']
    
    Your python: python=2
    
    If python is on the left-most side of the chain, that's the version you've asked for.
    When python appears to the right, that indicates that the thing on the left is somehow
    not available for the python version you are constrained to. Note that conda will not
    change your python version to a different minor version unless you explicitly specify
    that.
    

    报错信息解读:

    • 处理环境,失败 ;关于 Solving environment: failed with initial frozen solve,有提供的资料
    • UnsatisfiableError:与已有环境中的python不兼容
      细节就在这里:
      -deeptools = 3.5.0-> python [version = '> = 3']
      意思安装deeptools = 3.5.0需要python的版本大于3以上;而我现在chipseq环境中的python = 2
      注意,除非明确指定,否则conda不会将python版本更改为其他版本。(也就是我建立的chipseq指定了python的版本)
      了解了这些信息,于是,总结下来
    • (1)python的版本与软件版本的兼容性(管理Python)
    • (2)使用conda search package_name --info 来查看你想要安装的软件的配置细节。
    • (3)查看当前环境的Python版本:
    (chipseq) [yangjy@GSCG01 ~]$ python --version #chipseq环境的Python版本
    Python 2.7.15
    (deeptools) [yangjy@GSCG01 ~]$ python --version #deeptools环境的Python版本
    Python 3.8.6
    
    • 所以,最后怎么处理上面的bug呢?

    创建一个新的conda环境并安装deeptoolsconda create -n deeptools deeptools=3.5.0 python=3.8.6
    激活这个环境 conda activate deeptools
    尝试 bamCoverage -h

    参考网站:
    biostars

    相关文章

      网友评论

          本文标题:conda安装软件与环境管理

          本文链接:https://www.haomeiwen.com/subject/nphktltx.html