hsgweon / pipits

Automated pipeline for analyses of fungal ITS from the Illumina
GNU General Public License v3.0
30 stars 16 forks source link

Error: None zero returncode: conda list #25

Closed grayfall closed 5 years ago

grayfall commented 5 years ago

My colleagues faced the following issue with a fresh Pipits installation from conda and asked me to investigate.

(pipits) $ pipits_funits -i test/out_seqprep/prepped.fasta -o test/out_funits -x ITS2                             
pipits_funits 2.2, the PIPITS Project
https://github.com/hsgweon/pipits
---------------------------------

2018-12-30 23:54:23 Error: None zero returncode: conda list

I had figured this might be a version incompatibility issue, so I downgraded both pipits and conda

(pipits) $ conda list
# packages in environment at /home/anaconda/conda/envs/pipits:
#
# Name                    Version                   Build  Channel
biom-format               2.1.6                    py36_1    bioconda
blas                      1.0                         mkl  
bzip2                     1.0.6                h470a237_2    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py36_1000    conda-forge
click                     7.0                        py_0    conda-forge
cython                    0.29.2           py36hfc679d8_0    conda-forge
fastx_toolkit             0.0.14                        0    bioconda
future                    0.17.1                py36_1000    conda-forge
h5py                      2.9.0            py36he5c79e1_0    conda-forge
hdf5                      1.10.4          nompi_h5598ddc_1105    conda-forge
hmmer                     3.2.1                hfc679d8_0    bioconda
intel-openmp              2019.1                      144  
itsx                      1.1b                          1    bioconda
libffi                    3.2.1                hfc679d8_5    conda-forge
libgcc-ng                 7.2.0                hdf63c60_3    conda-forge
libgfortran               3.0.0                         1    conda-forge
libgfortran-ng            7.2.0                hdf63c60_3    conda-forge
libgtextutils             0.7                  h470a237_4    bioconda
libstdcxx-ng              7.2.0                hdf63c60_3    conda-forge
mkl                       2018.0.3                      1  
mkl_fft                   1.0.10                   py36_0    conda-forge
mkl_random                1.0.2                    py36_0    conda-forge
ncurses                   6.1                  hfc679d8_2    conda-forge
nose                      1.3.7                 py36_1002    conda-forge
numpy                     1.15.0           py36h1b885b7_0  
numpy-base                1.15.0           py36h3dfced4_0  
openjdk                   11.0.1              h470a237_14    conda-forge
openssl                   1.0.2p               h470a237_1    conda-forge
pandas                    0.23.4           py36hf8a1672_0    conda-forge
perl                      5.26.2               h470a237_0    conda-forge
pip                       18.1                  py36_1000    conda-forge
pipits                    2.1                        py_5    bioconda
pispino                   1.1                        py_1    bioconda
python                    3.6.7                h5001a0f_1    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
pytz                      2018.7                     py_0    conda-forge
rdptools                  2.0.2                         1    bioconda
readline                  7.0                  haf1bffa_1    conda-forge
scipy                     1.1.0            py36hc49cb51_0  
setuptools                40.6.3                   py36_0    conda-forge
six                       1.12.0                py36_1000    conda-forge
sqlite                    3.26.0               hb1c47c0_0    conda-forge
tk                        8.6.9                ha92aebf_0    conda-forge
vsearch                   2.10.3               h96824bc_0    bioconda
wheel                     0.32.3                   py36_0    conda-forge
xz                        5.2.4                h470a237_1    conda-forge
zlib                      1.2.11               h470a237_3    conda-forge

Alas, the issue persisted. I debugged the code and introduced the following modifications to make it run:

  1. In /home/anaconda/conda/envs/pipits/lib/python3.6/site-packages/pispino/runcmd.py
def run_cmd(command, log_file, verbose):

    FNULL = open(os.devnull, 'w')

    p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

    for l in p.stdout:
        if verbose:
            logger(str(l, 'utf-8').rstrip(), log_file, display = True, timestamp = False)
        else:
            logger(str(l, 'utf-8').rstrip(), log_file, display = False, timestamp = False)

    p.wait()
    FNULL.close()

    # MODIFICATION: raise an error instead of calling `exit(1)`
    if p.returncode != 0:
        raise RuntimeError("Error: None zero returncode: " + command)
  1. in /home/anaconda/conda/envs/pipits/bin/pipits_funits
    # Log versions
    # MODIFICATION: add exception handling; add `import logging` to the header
    try:
        cmd = " ".join(["conda list"])
        run_cmd(cmd, version_file, False)
    except RuntimeError:
        logging.exception('Hotfixed conda list call failure')

This is clearly a hotfix, yet I think it would be more convenient in the long run to introduce exception handling into your sources instead of exiting abruptly (as is the case in the original run_cmd function).

hsgweon commented 5 years ago

Thanks for this. Please feel free to make a branch and make any adjustments. I will test the code and merge as soon as I can. PIPITS is getting more popular but I just don't have funding/students/time to support this (and I don't want this tool to be yet another dead bioinformatics tool). Again, thanks for this!