picrust / picrust2

Code, unit tests, and tutorials for running PICRUSt2
GNU General Public License v3.0
328 stars 104 forks source link

tests/test_place_seqs.py shows failed status upon running the 'pytest' command #330

Closed chrissy005 closed 8 months ago

chrissy005 commented 1 year ago

I have installed the latest version of picrust2 (v2.5.2).

While the installation prompted that installation was successful, runnin the pytest command showed the following error:

==================================================================== test session starts ==================================================================== platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0 rootdir: /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2 plugins: cov-4.1.0 collected 61 items

tests/test_hsp.py ........ [ 13%] tests/test_metagenome_pipeline.py ............... [ 37%] tests/test_pathway_pipeline.py .... [ 44%] tests/test_place_seqs.py ........F [ 59%] tests/test_util.py .................... [ 91%] tests/test_workflow.py ..... [100%]

========================================================================= FAILURES ========================================================================== ____ place_seqs_tests.test_run_place_seqs_pipelinesepp ____

self =

def test_run_place_seqs_pipeline_sepp(self):
    '''Basic test of full place seqs pipeline with SEPP. Just run to
       see if any errors occur'''
    with TemporaryDirectory() as temp_dir:
        tmp_tree = path.join(temp_dir, "out.tre")
      place_seqs_pipeline(study_fasta=test_study_seqs,

ref_dir=default_ref_dir, placement_tool="sepp", out_tree=tmp_tree, threads=1, out_dir=temp_dir, min_align=0.8, chunk_size=5000, verbose=True)

tests/test_place_seqs.py:160:


picrust2/place_seqs.py:95: in place_seqs_pipeline run_sepp(tree=tree, picrust2/place_seqs.py:458: in run_sepp system_call_check(sepp_command, print_command=print_cmds,


cmd = ['run_sepp.py', '--tree', '/hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro...isg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.raxml_info', '--cpu', ...] print_command = True, print_stdout = True, print_stderr = True

def system_call_check(cmd, print_command=False, print_stdout=False,
                      print_stderr=False):
    '''Run system command and throw and error if return is not 0. Input command
    can be a list containing the command or a string.'''

    # Convert command to list if input as string.
    if type(cmd) is str:
        cmd = cmd.split()

    # Print command out if option set.
    if print_command:
        print(" ".join(cmd), file=sys.stderr)

    stdout_log = ""
    stderr_log = ""

    # Write stdout and stderr of command to temporary files.
    # Only output the content of these files if the job fails.
    with TemporaryDirectory() as temp_dir:

        stdout_file = join(temp_dir, "stdout.txt")
        stderr_file = join(temp_dir, "stderr.txt")

        with open(stdout_file, "wb") as stdout_fh, \
             open(stderr_file, "wb") as stderr_fh:

            return_value = call(cmd, stdout=stdout_fh,
                                stderr=stderr_fh)

        # Capture stdout and stderr.
        with open(stdout_file, 'r') as stdout_fh:
            stdout_log = stdout_fh.read()

        with open(stderr_file, 'r') as stderr_fh:
            stderr_log = stderr_fh.read()

        # Exit with error if command did not finish successfully.
        if return_value != 0:
            print("\nError running this command:\n" + " ".join(cmd),
                  file=sys.stderr)

            if stdout_log:
                print("\nStandard output of the above failed command:\n" +
                      stdout_log, file=sys.stderr)

            if stderr_log:
                print("\nStandard error of the above failed command:\n" +
                      stderr_log, file=sys.stderr)
          sys.exit(1)

E SystemExit: 1

picrust2/util.py:258: SystemExit ------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------

------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------- hmmalign --trim --dna --mapali /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.fna --informat FASTA -o /tmp/tmpcn6ncfol/query_align.stockholm /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.hmm /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/tests/test_data/place_seqs/study_seqs_test.fasta

All raw input sequences were the same length (400)

run_sepp.py --tree /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.tre --raxml /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.raxml_info --cpu 1 --molecule dna --outdir /tmp/tmpcn6ncfol/sepp_out -seed 297834 --alignment /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.fna --fragment /tmp/tmpcn6ncfol/study_seqs_filtered.fasta

Error running this command: run_sepp.py --tree /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.tre --raxml /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.raxml_info --cpu 1 --molecule dna --outdir /tmp/tmpcn6ncfol/sepp_out -seed 297834 --alignment /hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/picrust2/default_files/prokaryotic/pro_ref/pro_ref.fna --fragment /tmp/tmpcn6ncfol/study_seqs_filtered.fasta

Standard error of the above failed command: Traceback (most recent call last): File "/home/svu/chrisg25/TMFZ/postDADA2/picrust2-2.5.2/miniforge3/envs/picrust2/bin/run_sepp.py", line 3, in from sepp.exhaustive import ExhaustiveAlgorithm File "/hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/miniforge3/envs/picrust2/lib/python3.8/site-packages/sepp/exhaustive.py", line 6, in from sepp.algorithm import AbstractAlgorithm File "/hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/miniforge3/envs/picrust2/lib/python3.8/site-packages/sepp/algorithm.py", line 11, in from sepp.tree import PhylogeneticTree File "/hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/miniforge3/envs/picrust2/lib/python3.8/site-packages/sepp/tree.py", line 25, in from dendropy.datamodel.treemodel import _convert_node_to_root_polytomy as \ ImportError: cannot import name '_convert_node_to_root_polytomy' from 'dendropy.datamodel.treemodel' (/hpctmp/chrisg25/R_out/TMFZ/postDADA2/picrust2-2.5.2/miniforge3/envs/picrust2/lib/python3.8/site-packages/dendropy/datamodel/treemodel/init.py)

================================================================== short test summary info ================================================================== FAILED tests/test_place_seqs.py::place_seqs_tests::test_run_place_seqs_pipeline_sepp - SystemExit: 1 ========================================================= 1 failed, 60 passed in 905.97s (0:15:05) =

R-Wright-1 commented 1 year ago

Hi there, how did you install it? Please note that on the installation instructions page , it says "Run the tests to verify the installation (note that this wont work if you followed the bioconda install instructions, unless you also downloaded the source code and navigated to the main directory)"

ArnaudBelcour commented 1 year ago

Hi,

I had the same error, it is an issue with sepp and a version of dendropy (it has been described in this other issue: https://github.com/picrust/picrust2/issues/312). To solve this, you can use dendropy version 4.5.2 by installing it with pip install dendropy==4.5.2.

R-Wright-1 commented 8 months ago

Thanks for this fix @ArnaudBelcour!