Closed poliu2s closed 4 years ago
Hmh, the documentation says:
Note that Biopython 1.44 and earlier would give a truncated version of repr(my_seq) for str(my_seq). If you are writing code which need to be backwards compatible with really old Biopython, you should continue to use my_seq.tostring() as follows:
try:
# The old way, removed in Biopython 1.73
as_string = seq_obj.tostring()
except AttributeError:
# The new way, needs Biopython 1.45 or later.
# Don't use this on Biopython 1.44 or older as truncates
as_string = str(seq_obj)
Doesn't that imply that this change breaks compatibility with modern versions of biopython?
Good point.
I have added the exception handling to accommodate as per the documentation.
Thanks a lot for the PR @poliu2s and thanks for pointing that out @croth1 !
Everything looks good to me, I also would have been fine with breaking backwards compatibility for Biopython versions that are > 12 years old
I changed the title to reflect that this adds backward compatibility to very early versions of biopython. I also think this is fine now!
I have been recently using the convert_alignment.py script to convert some FASTA files, however it was failing because the tostring() method.
Update to string parsing method to conform to new Seq class - https://biopython.org/DIST/docs/api/Bio.Seq.Seq-class.html