create_concat: AttributeError: 'str' object has no attribute 'decode'
TobyBaril opened this issue · 4 comments
Hi!
I am trying to make a supermatrix of BUSCO genes.
I have made the txt file containing the full path to the files containing the alignments of each gene, and I have checked that the fasta headers are the same for each species in every fasta.
I have had lots of success using phykit in the past, but I am trying it on a new system and keep getting the following error:
Traceback (most recent call last):
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/services/alignment/create_concatenation_matrix.py", line 218, in fasta_file_write
concatenated.append(s._data.decode("utf-8"))
AttributeError: 'str' object has no attribute '_data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/administrator/anaconda3/envs/phykit/bin/phykit", line 10, in <module>
sys.exit(main())
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/phykit.py", line 1956, in main
Phykit()
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/phykit.py", line 229, in __init__
self.run_alias(args.command, sys.argv[2:])
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/phykit.py", line 309, in run_alias
return self.create_concatenation_matrix(argv)
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/phykit.py", line 1895, in create_concatenation_matrix
CreateConcatenationMatrix(args).run()
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/services/alignment/create_concatenation_matrix.py", line 18, in run
self.create_concatenation_matrix(self.alignment_list_path, self.prefix)
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/services/alignment/create_concatenation_matrix.py", line 330, in create_concatenation_matrix
self.fasta_file_write(
File "/home/administrator/anaconda3/envs/phykit/lib/python3.9/site-packages/phykit/services/alignment/create_concatenation_matrix.py", line 221, in fasta_file_write
concatenated.append(s.decode("utf-8"))
AttributeError: 'str' object has no attribute 'decode'
I would be really grateful for any help in solving this,
Many thanks,
Toby
Hi Toby,
Thank you for reaching out and for using PhyKIT!
Would you be able to provide the version number you are using for PhyKIT and biopython?
All the best,
Jacob
Phykit version 1.4.1
Biopython version 1.79
Installed in a new conda environment
Great - thanks for the information!
I think I know the issue and it is an easy fix. To be sure, would you be able to send your input files over? You can email them. My contact info is here https://jlsteenwyk.com/contact.html
Thank you for working with me on this Toby!
best,
Jacob
Hi Toby,
Thank you for your assistance in working out this bug. The issue was simple.
In line 221, concatenated.append(s.decode("utf-8"))
had to be changed to concatenated.append(s)
because a string does not need to be decoded.
Together with other integration tests, the function that gave this error now has 100% code coverage. Thus, you will likely never run into that error again.
These changes are implemented in PhyKIT, v1.4.2.
Thank you again for your help and interest in PhyKIT.
All the best,
Jacob L. Steenwyk