macs3-project / MACS

MACS -- Model-based Analysis of ChIP-Seq
https://macs3-project.github.io/MACS/
BSD 3-Clause "New" or "Revised" License
702 stars 268 forks source link

MACS2 can't find python files after fresh conda install #155

Open abalter opened 8 years ago

abalter commented 8 years ago

I install macs2 using conda and which can find it, but MACS2 throws errors when I try to run it about not being able to find files.

balter@server:~$ conda install macs2
Fetching package metadata ...........
Solving package specifications: ..........

Package plan for installation in environment <server path>/users/balter/miniconda2:

The following NEW packages will be INSTALLED:

    macs2: 2.1.1.20160309-r3.2.2_0 bioconda

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|###########################################################################################| 100%
balter@server:~$ which macs2
<server path>/users/balter/miniconda2/bin/macs2
balter@server:~$ macs2 -h
Traceback (most recent call last):
  File "<server path>/users/balter/miniconda2/bin/macs2", line 4, in <module>
    __import__('pkg_resources').run_script('MACS2==2.1.1.20160309', 'macs2')
  File "<server path>/users/balter/miniconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/__init__.py", line 719, in run_script
  File "<server path>/users/balter/miniconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/__init__.py", line 1496, in run_script
pkg_resources.ResolutionError: No script named 'macs2'
balter@server:~$ macs2 --version
Traceback (most recent call last):
  File "<server path>/users/balter/miniconda2/bin/macs2", line 4, in <module>
    __import__('pkg_resources').run_script('MACS2==2.1.1.20160309', 'macs2')
  File "<server path>/users/balter/miniconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/__init__.py", line 719, in run_script
  File "<server path>/users/balter/miniconda2/lib/python2.7/site-packages/setuptools-23.0.0-py2.7.egg/pkg_resources/__init__.py", line 1496, in run_script
pkg_resources.ResolutionError: No script named 'macs2'

I'm wondering if it has something to do with my python path settings. Here they are:

balter@server:~$ grep -i python* .bashrc
# Python environment variables
export PYTHONLIB="<server path>/users/balter/miniconda2/lib"
export PYTHONPATH="<server path>/users/balter/miniconda2/lib/python2.7/site-packages"
export PYTHONUSERBASE="<server path>/users/balter/miniconda2"

balter@server:~$ grep -i path .bashrc
# Custom PATH variable
export PATH="/bin:/usr/local/bin:/usr/bin:/opt/condor/bin:<server path>/CompBio/bin"
export PATH="<server path>/users/balter/miniconda2/bin:$PATH"

Cross-posted here: https://www.biostars.org/p/216312/ and here: http://stackoverflow.com/questions/40008344/macs2-python-files-not-found-after-clean-install-with-conda

taoliu commented 7 years ago

Hi @abalter, could you find out where the 'conda' installed MACS2? Especially, where is the 'egg' for MACS2? According to my knowledge of 'easyinstall', it will package actual python scripts (macs2) and the library files (such as .pyc or .o files) in 'egg' then put it somewhere (such as /users/balter/miniconda2/lib/python2.7/site-packages/). Then it will create a virtual script (such as /users/balter/miniconda2/bin/macs2) and instruct the system where the egg is. To find the egg, it will look for a file named 'easy-install.pth' and in that file there must be a line like 'somepath/MACS2-2.1.1.20160309-py2.7-xxxxxxxxx.egg' (the egg is in fact a directory). Python will try to insert 'somepath/MACS2-2.1.1.20160309-py2.7-xxxxxxxxx.egg' to sys.path so that it will locate the actual 'macs2' script and its library files. The actual 'macs2' script should be in 'xxx.egg/EGG-INFO/scripts/macs2', and library files should be in 'xxx.egg/MACS2/'. Yes. It's so complicated and I really hate that :) The conclusion is... if you installed python package in this way -- through easyinstall (the setup tools), your hack on PYTHONPATH will not be that useful anymore! So, try not to use PYTHONPATH if your python software is installed through this 'conda' script. Instead, try to figure out where the .pth and .egg are and to check if conda successfully write a line about 'MACS2' in the .pth file...

taoliu commented 7 years ago

@abalter Disclaimer: I have never used miniconda so the actual .pth filename might be different. But the mechanism of this setuptools should be the same...

brianpenghe commented 5 years ago

I didn't use conda but still got the same error.

brianpenghe commented 5 years ago

This is what I got: Traceback (most recent call last): File "/usr/local/bin/macs2", line 4, in <module> __import__('pkg_resources').run_script('MACS2==2.1.2', 'macs2') File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 658, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1429, in run_script .format(**locals()), pkg_resources.ResolutionError: Script 'scripts/macs2' not found in metadata at '/home/ubuntu/tools/MACS2-2.1.2/MACS2-2.1.2.egg-info'

abalter commented 5 years ago

I would recommend installing with conda. Seems to work perfectly now.

(base) balter@spectre3:~/deseq-learn/taxa_filtered_data$ conda create -n macs macs2
(base) balter@spectre3:~/deseq-learn/taxa_filtered_data$ conda activate macs
(macs) balter@spectre3:~/deseq-learn/taxa_filtered_data$ which macs2
/home/balter/conda/envs/macs/bin/macs2
(macs) balter@spectre3:~/deseq-learn/taxa_filtered_data$ macs2 -h
usage: macs2 [-h] [--version]
             {callpeak,bdgpeakcall,bdgbroadcall,bdgcmp,bdgopt,cmbreps,bdgdiff,filterdup,predictd,pileup,randsample,refinepeak}
             ...

macs2 -- Model-based Analysis for ChIP-Sequencing

positional arguments:
  {callpeak,bdgpeakcall,bdgbroadcall,bdgcmp,bdgopt,cmbreps,bdgdiff,filterdup,predictd,pileup,randsample,refinepeak}
    callpeak            Main MACS2 Function: Call peaks from alignment
                        results.
    bdgpeakcall         Call peaks from bedGraph output. Note: All regions on
                        the same chromosome in the bedGraph file should be
                        continuous so only bedGraph files from MACS2 are
                        accpetable.
    bdgbroadcall        Call broad peaks from bedGraph output. Note: All
                        regions on the same chromosome in the bedGraph file
                        should be continuous so only bedGraph files from MACS2
                        are accpetable.
    bdgcmp              Deduct noise by comparing two signal tracks in
                        bedGraph. Note: All regions on the same chromosome in
                        the bedGraph file should be continuous so only
                        bedGraph files from MACS2 are accpetable.
    bdgopt              Operations on score column of bedGraph file. Note: All
                        regions on the same chromosome in the bedGraph file
                        should be continuous so only bedGraph files from MACS2
                        are accpetable.
    cmbreps             Combine BEDGraphs of scores from replicates. Note: All
                        regions on the same chromosome in the bedGraph file
                        should be continuous so only bedGraph files from MACS2
                        are accpetable.
    bdgdiff             Differential peak detection based on paired four
                        bedgraph files. Note: All regions on the same
                        chromosome in the bedGraph file should be continuous
                        so only bedGraph files from MACS2 are accpetable.
    filterdup           Remove duplicate reads at the same position, then save
                        the rest alignments to BED or BEDPE file. If you use
                        '--keep-dup all option', this script can be utilized
                        to convert any acceptable format into BED or BEDPE
                        format.
    predictd            Predict d or fragment size from alignment results.
                        *Will NOT filter duplicates*
    pileup              Pileup aligned reads with a given extension size
                        (fragment size or d in MACS language). Note there will
                        be no step for duplicate reads filtering or sequencing
                        depth scaling, so you may need to do certain pre/post-
                        processing.
    randsample          Randomly sample number/percentage of total reads.
    refinepeak          (Experimental) Take raw reads alignment, refine peak
                        summits and give scores measuring balance of
                        waston/crick tags. Inspired by SPP.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

For command line options of each command, type: macs2 COMMAND -h