Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: invalid mode: 'rU' when running emapper.py with the --md5 option #432

Closed
samuelruizperez opened this issue Dec 7, 2022 · 6 comments
Labels

Comments

@samuelruizperez
Copy link

samuelruizperez commented Dec 7, 2022

Hi!

After installing eggnog-mapper v2.1.9 through conda (Python 3.11.0) and running emapper.py with the --md5 option I got this error:

Creating md5 hashes of input sequences

Parsing fasta file /path/to/proteins.fa...

Traceback (most recent call last):
  File "/home/usr/.conda/envs/env_name/bin/emapper.py", line 704, in <module>
    n, elapsed_time = emapper.run(args, args.input, args.annotate_hits_table, args.cache_file)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/usr/.conda/envs/env_name/lib/python3.11/site-packages/eggnogmapper/emapper.py", line 342, in run
    annotated_hits = self.annotate(args, hits, annotate_hits_table, queries_file, cache_dir)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/usr/.conda/envs/env_name/lib/python3.11/site-packages/eggnogmapper/emapper.py", line 232, in annotate
    annotated_hits = annotator.annotate(annot_in,
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/usr/.conda/envs/env_name/lib/python3.11/site-packages/eggnogmapper/annotation/annotator.py", line 108, in annotate
    md5_queries = md5_seqs(queries_file, translate, self.trans_table)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/usr/.conda/envs/env_name/lib/python3.11/site-packages/eggnogmapper/annotation/annotator.py", line 407, in md5_seqs
    for name, seq in iter_fasta_seqs(fasta_file, translate=translate, trans_table=trans_table):
  File "/home/usr/.conda/envs/env_name/lib/python3.11/site-packages/eggnogmapper/search/hmmer/hmmer_seqio.py", line 26, in iter_fasta_seqs
    _source = open(source, "rU")
              ^^^^^^^^^^^^^^^^^^
ValueError: invalid mode: 'rU'

I'm not sure if this is the correct place to post this bug, but I guess the problem is that the 'U' option is the default behavior of the open() function since Python 3.0, and it was deprecated in Python 3.11. I removed the 'U' from _source = open(source, "rU") and it is working fine.

Thanks!

@Cantalapiedra
Copy link
Collaborator

Hi @samuelruizperez ,

Thank you for reporting this.
Did you try with a python version previous to 3.11?

@samuelruizperez
Copy link
Author

Yes! Works fine with Python 3.9.15.

@Cantalapiedra
Copy link
Collaborator

Thank you Samuel! And sorry for the headaches

@Cantalapiedra
Copy link
Collaborator

This should be fixed in version 2.1.10.
Please, re-open if needed.

@taylorreiter
Copy link

I encountered this error with mode --translate, also fixed by downgrading python. I think it might be from this line of code:

_source = open(source, "rU")

@Cantalapiedra
Copy link
Collaborator

Thank you very much!
We will try to fix it ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants