Skip to content

Removing tostring() needlessly breaks backwards compatibility, deprecation shouldn't lead to removal! #1952

Closed

Description

@fgp

Commit 2f03509 removed Seq.tostring(), which was the previously recommended way of converting a sequence to a string without risk of the sequence being truncated during conversion. To quote the function documentation of __str__ in https://biopython.org/DIST/docs/api/Bio.Seq.Seq-class.html

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 old Biopython, you should continue to use my_seq.tostring() rather than str(my_seq).

After 2f03509, we are left with NO WAY of converting a sequence to a string that works correctly for both Biopython 1.44 and Biopython 1.73. Plus, the comment that explains this is still there, i.e. now pointing users towards functionality that no longer exists.

I have to say I'm very concerned about the general attitude towards compatibility of the Biopython project if commits like 2f03509 are applied WITHOUT need and WITHOUT even making sure that comments like the one I quoted are fixed. For users like me, libraries like biopython are a small part of a large software universe we use, and there is neither time nor desire to track the development of each of those. If I cannot trust that using a library like Biopython won't constantly break existing code without a good reason, than in the end depending on this library is more a burden than a benefit.

Activity

  1. peterjc commented on Mar 7, 2019

    @peterjc
    Member

    See pull request #1855

    Our standard deprecation policy is here:

    https://biopython.org/wiki/Deprecation_policy

    In the case of str(seq_obj) (aka the __str__ method) and seq_obj.tostring() we deliberately moved much slower with this change because we knew it could affect more people than usual, but changing __str__ was important to fix an unfortunate early design change which blocked making Seq objects more like the Python string.

    Biopython 1.44 was released back on 28 October 2007.

    Biopython 1.45 made str(seq_object) behave sensibly, and that was released in 22 March 2008, so we've had over ten years with that as the recommended usage.

    Since Biopython 1.64 (released 29 May 2014) using .tostring() would give a warning. That was over 4 and a half years with the warning in place.

    If you really need a compatible way to do this:

    from Bio.Seq import Seq
    seq_obj = Seq("ACGT")
    
    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 that truncates this
        as_string = str(seq_obj)

    Would you like that added to the DEPRECATED file?

    In our shoes would you have kept the .tostring() method in place indefinitely?

    CC @mdehoon

  2. fgp commented on Mar 7, 2019

    @fgp
    Author

    Would you like that added to the DEPRECATED file?

    I the light of Biopython 1.44 having been released 2007, I agree that this isn't necessary.

    In our shoes would you have kept the .tostring() method in place indefinitely?

    I would have kept it around until such time as there is some tangible benefit to removing it. Which for such a trivial function may very well mean indefinitely -- or it might not, depending on the further fate of the Seq class. But I fail to see the point in removing code just because it was deprecated for a long time.

    Anyway, thank you for submitting a documentation fix!

  3. mdehoon commented on Mar 8, 2019

    @mdehoon
    Contributor

    @fgp If we don't remove deprecated code at some point, then Biopython will become an unmanageable mess. Biopython already is very conservative in its deprecation policy.

  4. added a commit that references this issue on Mar 15, 2019
  5. peterjc commented on Dec 25, 2019

    @peterjc
    Member

    Belatedly closing this issue with the documentation improvement done in March.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions