biobakery / biobakery_workflows

bioBakery workflows is a collection of workflows and tasks for executing common microbial community analyses using standardized, validated tools and parameters.
http://huttenhower.sph.harvard.edu/biobakery_workflows
Other
97 stars 33 forks source link

problems with writing reslults to a file in rna_dna_norm.py #18

Closed hilasha2 closed 2 years ago

hilasha2 commented 2 years ago

When I ran biobakery in the wmtx_wmgs workflow it crashed when it reached to the task of rna_dna_norm.py You can follow the description of my problem here: (https://forum.biobakery.org/t/wmgx-wmtx-worfklow-rna-dna-norm-py-failure-why-is-metagenome-needed-in-metatranscriptome-analysis/2856/2)

I will copy the error message I got:

Error executing action 0. Original Exception: 
  Traceback (most recent call last):
    File "~/miniconda3/envs/$ENV_NAME/lib/python3.7/site-packages/anadama2/runners.py", line 201, in _run_task_locally
      action_func(task)
    File "~/miniconda3/envs/$ENV_NAME/lib/python3.7/site-packages/anadama2/helpers.py", line 89, in actually_sh
      ret = _sh(s, **kwargs)
    File "~/miniconda3/envs/$ENV_NAME/lib/python3.7/site-packages/anadama2/util/__init__.py", line 320, in sh
      raise ShellException(proc.returncode, msg.format(cmd, ret[0], ret[1]))
  anadama2.util.ShellException: [Errno 1] Command `rna_dna_norm.py --input-dna $OUTPUT_PATH/whole_metagenome_shotgun/humann/merged/genefamilies.tsv --input-rna $OUTPUT_PATH/whole_metatranscriptome_shotgun/humann/merged/genefamilies.tsv --output $OUTPUT_PATH/humann/rna_dna_norm/genes --reduce-sample-name' failed. 
  Out: b'Reading RNA table\nReading DNA table\nCompute unstratified features\nNormalize DNA\nNormalize RNA\nCompute stratified features\nNormalize DNA\nNormalize RNA\nCompute only classified features\nNormalize DNA\nNormalize RNA\nWriting unstratified table\n'
  Err: b'Traceback (most recent call last):\n  File "~/miniconda3/envs/$ENV_NAME/bin/rna_dna_norm.py", line 272, in <module>\n    main()\n  File "~/miniconda3/envs/$ENV_NAME/bin/rna_dna_norm.py", line 258, in main\n    output_unstrat_file)\n  File "~/miniconda3/envs/$ENV_NAME/bin/rna_dna_norm.py", line 180, in write_file\n    file_handle.write("\\t".join(column_labels)+"\\n")\nTypeError: a bytes-like object is required, not \'str\'\n'

I think one of the problems of why this task has crashed was because you open the results file using 'wb' mode (i.e. in binary format) instead of simply 'w'. I changed the code in rna_dna_norm.py, line 179 from:

with open(file, "wb") as file_handle:

to:

with open(file, "w") as file_handle:

This helped the code to not crash, however, I don't think it's the last of the problems. As I mentioned in the attached link I also had problems when I included a mapping file mapping RNA sample IDs to the DNA ones.

github-actions[bot] commented 2 years ago

Thank you for creating this issue. We currently field issues through our bioBakery Discourse Support Forum. If you would please post the issue to discourse we would be happy to sync up with you to get it resolved.