maxplanck-ie / HiCAssembler

Software to assemble contigs/scaffolds into chromosomes using Hi-C data
27 stars 4 forks source link

ImportError: No module named HiCMatrix #21

Open ddelgadillod opened 3 years ago

ddelgadillod commented 3 years ago

Hi

I tried to run HiC Assembler over conda environment with Python 2.7 and an old version of some packages as hicexplorer v2.2 and biopython v1.76 (last supported for Python 2.7), when I tried to execute assemble command, It doesn't can import hicexplorer.HiCMatrix

(HiCAssemblerPy27) ddelgadillo@COMOSPLNXU09:~/Software$ assemble
Traceback (most recent call last):
  File "/home/ddelgadillo/miniconda3/envs/HiCAssemblerPy27/bin/assemble", line 11, in <module>
    import hicassembler.HiCAssembler as HiCAssembler
  File "/home/ddelgadillo/miniconda3/envs/HiCAssemblerPy27/lib/python2.7/site-packages/hicassembler/HiCAssembler.py", line 8, in <module>
    import hicexplorer.HiCMatrix as HiCMatrix
ImportError: No module named HiCMatrix

I check hicexplorer and everything looks well, Its it another dependency or hicexplorer complement that I forget to install?

I appreciate so much your help

Diego D

ostueker commented 3 years ago

I ran into the same issue today. It seems that import hicexplorer.HiCMatrix as HiCMatrix should be changed to import hicmatrix.HiCMatrix as HiCMatrix.

In the checked out repository one can easily find all of the imports with:

$ git grep "import hicexplorer.HiCMatrix"
hicassembler/HiCAssembler.py:import hicexplorer.HiCMatrix as HiCMatrix
hicassembler/Scaffolds.py:import hicexplorer.HiCMatrix as HiCMatrix
hicassembler/plotScaffoldInteractive.py:import hicexplorer.HiCMatrix as HiCMatrix
hicassembler/plotScaffoldsHiC.py:import hicexplorer.HiCMatrix as HiCMatrix
hicassembler/test/test_Scaffolds.py:import hicexplorer.HiCMatrix as HiCMatrix

and change the imports with:

sed -i  's/import hicexplorer.HiCMatrix/import hicmatrix.HiCMatrix/' hicassembler/*py hicassembler/test/*.py

Would be nice if the devs would provide a new release that fixes this issue.

pgonzale60 commented 3 years ago

Another way of avoiding that error is by trying recreating an environment with the versions they used in their last release. This worked for me just now. conda create -n hicex -c bioconda -c conda-forge 'hicexplorer==2.1.1' 'python=2.7' 'pytest=2.9' 'versioneer=0.18' 'networkx=2.2' 'future=0.16' 'six=1.10' 'pandas=0.20' 'pysam=0.11'

With this the dependencies will be satisfied. To avoid upgrading to incompatible ones, empty the 'requirements.txt' file. After that you can safely install with pip.

conda activate hicex
cd HiCAssembler
echo "" > requirements.txt
sed -i "s/'\*.txt'/['requirements.txt']/" setup.py
pip install -e .