Skip to content

Should we remove/replace Bio.Alphabet? #2046

Closed

Description

@peterjc

Filing this meta-issue, since we don't seem to have a single place discussing this on GitHub.

My (likely biased) summary from those discussions is no one likes the current alphabet system, and most people ignore it.

Biopython has a complicated hard to use legacy alphabet system in Bio.Alphabet which is used as a typing system (e.g. can't do reverse-complement on a protein), can store some useful information like the expected letters, if gapped and the gap character (although only one), and a stop codon symbol (although only one).

The objects in Bio.Alphabet cover three-letter alphabets as well as the more commonly used one-letter alphabets, although the Seq object effectively assumes the later only. Three-letter alphabets can be used with the array-based MutableSeq object, but it is very fragile and many things break - thus #1681.

Note we do not (currently) validate the expected letters when making a sequence object with an alphabet with an explicit set of expected letters - #1040.

Discussion on #1674 (hiding alphabets) has meant we now hide the alphabet in the Seq object representation if it is the default alphabet. Discussion there, and on #1681, and on the mailing list suggests going further and removing Bio.Alphabet entirely.

Note that removal is not as simple as it might sound - it will require some delicate modifications, for example several of the parsers in Bio.SeqIO use the alphabet to store the sequence type (important metadata in more than one file format).

I personally do like the typing system aspect of the alphabet system, but think we only need a much simpler DNA/RNA/nucleotide/protein/other system (more like an enum). I started looking at that on this branch which aimed to break as little existing code as possible: https://github.com/peterjc/biopython/tree/alpha_lite

Activity

  1. mdehoon commented on May 5, 2019

    @mdehoon
    Contributor

    I don't think it's productive to restart this discussion. We have been discussing this since 2005 (this is not a typo), if not earlier.

    As a reminder, in August 2018 we called for a Biopython Enhancement Proposal on alphabets, where we invited people in favor of having alphabets in Biopython to work out a detailed proposal on the purpose and implementation of alphabets:
    https://lists.open-bio.org/pipermail/biopython/2018-August/016524.html
    with a time limit of January 1, 2020 after which alphabets would be removed from Biopython if no agreement on a proposal was reached.

    Overall, there was little interest from users and developers. Thomas Wemyss stepped up to work out a proposal, but in the end concluded that it was better to remove alphabets:
    https://lists.open-bio.org/pipermail/biopython/2018-October/016556.html

    @peterjc Can you take over from Thomas and write a BEP?

  2. peterjc commented on May 5, 2019

    @peterjc
    MemberAuthor

    This wasn't meant to restart the conversation - but be a visible marker. To that end, I'll lock this issue.

  3. locked and limited conversation to collaborators on May 5, 2019
  4. mdehoon commented on May 6, 2019

    @mdehoon
    Contributor

    @peterjc OK, thanks!

  5. peterjc commented on May 6, 2019

    @peterjc
    MemberAuthor

    Locking the issue preventing GitHub automatically linking pull request #2050 (just merged) which declared Bio.Alphabet as obsolete, and added a PendingDeprecationWarning (which is silent by default).

    See also our https://biopython.org/wiki/Deprecation_policy

  6. peterjc commented on Aug 16, 2019

    @peterjc
    MemberAuthor

    Note to self for a possible reduced sequence type system: enum34 (available on PyPI) is the new Python stdlib enum module available in Python 3.4 backported for previous versions of Python from 2.4 to 3.3. tested on 2.6, 2.7, and 3.3+

  7. peterjc commented on Jan 22, 2020

    @peterjc
    MemberAuthor

    See also #2488, which includes a reminder that for many people the only place they need to use Bio.Alphabet is in constructing SeqRecord objects for output in GenBank or other formats which need to know DNA vs RNA vs Protein explicitly.

  8. peterjc commented on Jun 26, 2020

    @peterjc
    MemberAuthor

    Following the release of Biopython 1.77 (May 2020) which was focused on removing Python 2 specific code, we are currently removing internal use of Bio.Alphabet objects. The Seq objects will no long use this attribute for type checking.

    Where recording the molecule type is required (some file formats need this), the SeqRecord annotation is used instead. Specifically, the .annotations['molecule_type'] field which was already used in the GenBank/EMBL parser. This should be a string containing "DNA", "RNA", "protein". It can be a longer string like "mRNA".

  9. unlocked this conversation on Jul 29, 2020
  10. peterjc commented on Jul 29, 2020

    @peterjc
    MemberAuthor

    With the recent work up to and including #3168, Biopython no longer uses Bio.Alphabet internally and we should be OK to remove or deprecate it in the next release (Biopython 1.78). We still need to look at documentation and helping people transition, see e.g. examples on #3156.

  11. added a commit that references this issue on Nov 18, 2020
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