Skip to content

Motifs optional alphabet - #1943

Closed
mdehoon wants to merge 166 commits into
biopython:masterfrom
mdehoon:motifs_optional_alphabet
Closed

mdehoon wants to merge 166 commits into
biopython:masterfrom
mdehoon:motifs_optional_alphabet

Conversation

@mdehoon

@mdehoon mdehoon commented Feb 28, 2019 •

Copy link
Copy Markdown
Contributor

This pull request removes alphabets as a requirement from Bio.motifs.

  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file and understand that AppVeyor and
    TravisCI will be used to confirm the Biopython unit tests and flake8 style
    checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

@mdehoon
mdehoon requested a review from peterjc February 28, 2019 02:15
@codecov

codecov Bot commented Feb 28, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #1943 into master will increase coverage by 0.01%.
The diff coverage is 77.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1943      +/-   ##
==========================================
+ Coverage   85.03%   85.04%   +0.01%     
==========================================
  Files         310      310              
  Lines       49960    49950      -10     
==========================================
- Hits        42481    42478       -3     
+ Misses       7479     7472       -7
Impacted Files Coverage Δ
Bio/motifs/alignace.py 98% <100%> (-0.04%) ⬇️
Bio/motifs/transfac.py 78.12% <100%> (-0.14%) ⬇️
Bio/motifs/mast.py 92.92% <100%> (-0.07%) ⬇️
Bio/motifs/meme.py 80.89% <100%> (-0.08%) ⬇️
Bio/motifs/minimal.py 85.32% <50%> (-0.14%) ⬇️
Bio/motifs/matrix.py 82.13% <72.5%> (+0.99%) ⬆️
Bio/motifs/__init__.py 81.5% <77.77%> (+1.04%) ⬆️
Bio/motifs/jaspar/__init__.py 44.7% <83.33%> (-0.51%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6543091...60d1e90. Read the comment docs.

Comment thread Bio/motifs/__init__.py
@@ -160,8 +160,12 @@ class Instances(list):

def __init__(self, instances=None, alphabet=None):
"""Initialize the class."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring ought to explain the arguments, especially as you are changing how the alphabet argument is interpreted.

Comment thread Bio/motifs/__init__.py
from Bio.Seq import Seq
try:
# Received an old-style alphabet
alphabet = alphabet.letters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you call the internal variable letters instead of alphabet here? I would find that clearer.

@peterjc

peterjc commented Feb 28, 2019

Copy link
Copy Markdown
Member

This seems premature without a wider decision on removing or simplifying alphabets.

I don't object to allowing passing a string of letters as an alternative input to an Alphabet object, but when you return a Seq object, could you not continue to set an alphabet object (even a generic one based on the letters in use)?

@mdehoon

mdehoon commented Feb 28, 2019

Copy link
Copy Markdown
Contributor Author

@peterjc The decision to remove alphabets has already been made.

@peterjc

peterjc commented Feb 28, 2019

Copy link
Copy Markdown
Member

@mdehoon has it? Have I missed some important emails?

anntzer and others added 9 commits March 13, 2019 17:19
Its only functionality (lowess) suffers from known bugs since 2014 and
has seen no activity (other than style fixes) since 2008.
)

* read nib header

* added test

* added a writer

* cleanup header

* cleanup

* allow python2

* add documentation

* include doctest

* flake issues

* flake issues

* making flake happy

* making flake happy

* making flake happy

* making flake happy

* making flake happy

* making flake happy

* making flake happy

* making flake happy

* fix test_SeqIO_write.py

* deal with nib special cases

* fixing issues raised by Peter and appveyor

* make nib files binary

* fix for python2.4

* dont decode for python2
Also fixed a docstring for PEP257:

'The one-line docstring should NOT be a signature reiterating the function/method parameters (which can be obtained by introspection).'
$ flake8 Scripts/Restriction/ranacompiler.py
Scripts/Restriction/ranacompiler.py:408:17: B007 Loop control variable 'n' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/Restriction/ranacompiler.py:671:21: B007 Loop control variable 'name' not used within the loop body. If this is intended, start the name with an underscore.

With minor restructuring we didn't need the variables at all.
Note B007 warning is from flake8-bugbear plugin,
https://github.com/PyCQA/flake8-bugbear
This was failing locally, but not on TravisCI, which is odd:

$ flake8 Scripts/
Scripts/query_pubmed.py:45:14: B007 Loop control variable 'arg' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/xbbtools/nextorf.py:198:26: B007 Loop control variable 'length' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/Performance/biosql_performance_read.py:23:5: B007 Loop control variable 'junk_id' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/Performance/biosql_performance_read.py:39:5: B007 Loop control variable 'junk_id' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/debug/debug_blast_parser.py:131:9: B007 Loop control variable 'err_file' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/debug/debug_blast_parser.py:131:19: B007 Loop control variable 'err_line' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/debug/debug_blast_parser.py:131:43: B007 Loop control variable 'err_text' not used within the loop body. If this is intended, start the name with an underscore.
Scripts/debug/debug_blast_parser.py:240:14: B007 Loop control variable 'arg' not used within the loop body. If this is intended, start the name with an underscore.

We currently ignore B007 in Bio/ etc.
@mdehoon

mdehoon commented May 16, 2019

Copy link
Copy Markdown
Contributor Author

@peterjc Now that Bio.Alphabet has been declared obsolete, can we proceed with this pull request?

@peterjc

peterjc commented May 16, 2019 •

Copy link
Copy Markdown
Member

If this just "removes alphabets as a requirement from Bio.motifs" I'd be happier, but it seems to go further and "removes Bio.Alphabets usage from Bio.motifs".

In particular, if I am reading the diff correctly, the Instances object's .alphabet property changes from a Bio.Alphabets object to a simple string. If you wanted to reduce the risk of breaking people's code, you could keep .alphabet as is for now (with a deprecation warning perhaps), and introduce .letters as a new string attribute?

Or if you are happy with a backward incompatible change, I would be OK with removing the old object attribute .alphabet and replacing it with a new string attribute .letters instead?

To me that naming is clearer, since .alphabet could just as easily mean the type (DNA/RNA/Protein/...) rather than the characters or letters expected, whereas we have the .letters convention well established.

Update: Cross reference #2050 which declared Bio.Alphabet obsolete.

@peterjc

peterjc commented May 16, 2019

Copy link
Copy Markdown
Member

Also, could we merge #1453 first, and then update this pull request to apply the needed alphabet changes in the new motif parsers that adds?

@mdehoon

mdehoon commented May 17, 2019

Copy link
Copy Markdown
Contributor Author

Starting a new pull request

@mdehoon mdehoon closed this May 17, 2019
@mdehoon mdehoon mentioned this pull request May 17, 2019
3 tasks done
@mdehoon
mdehoon deleted the motifs_optional_alphabet branch May 17, 2019 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.