Skip to content

Added special case for minimum alignment matrices in the NJ algorithm - #1891

Merged
peterjc merged 12 commits into
biopython:masterfrom
ZykeDev:patch-3
Feb 12, 2019
Merged

peterjc merged 12 commits into
biopython:masterfrom
ZykeDev:patch-3

Conversation

@ZykeDev

@ZykeDev ZykeDev commented Jan 8, 2019 •

Copy link
Copy Markdown
Contributor

This pull request addresses issue #1323

  • 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.)

@ZykeDev
ZykeDev requested a review from etal as a code owner January 8, 2019 18:50
Comment thread Bio/Phylo/TreeConstruction.py Outdated
clades[1].branch_length = 0
clades[1].clades.append(clades[0])
root = clades[1]
while len(dm) > 2:

@peterjc peterjc Jan 11, 2019 •

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.

I think rather than indenting all the old code one level using:

# special case for Minimum Alignment Matrices
if len(dm) == 2:
    # new code
else:
    while len(dm) > 2:
        # old code (indented)

you could leave it as:

if len(dm) == 2:
    # new code
while len(dm) > 2:
    # old code (unchanged)

This should make the diff much smaller, and be easier to review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, much better now that I think about it.

@codecov

codecov Bot commented Jan 11, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1891 into master will decrease coverage by 0.03%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1891      +/-   ##
==========================================
- Coverage    85.5%   85.46%   -0.04%     
==========================================
  Files         303      303              
  Lines       49447    49459      +12     
==========================================
- Hits        42279    42272       -7     
- Misses       7168     7187      +19
Impacted Files Coverage Δ
Bio/Phylo/TreeConstruction.py 92.15% <87.5%> (-2.02%) ⬇️
Bio/_py3k/__init__.py 72.61% <0%> (-3.58%) ⬇️
Bio/Application/__init__.py 86.56% <0%> (-1.19%) ⬇️
Bio/File.py 87.01% <0%> (-0.26%) ⬇️
Bio/Entrez/Parser.py 83.27% <0%> (-0.19%) ⬇️

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 cabc278...1a1926d. Read the comment docs.

@codecov

codecov Bot commented Jan 11, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #1891 into master will decrease coverage by 0.47%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1891      +/-   ##
==========================================
- Coverage    85.5%   85.02%   -0.48%     
==========================================
  Files         303      310       +7     
  Lines       49447    49951     +504     
==========================================
+ Hits        42279    42472     +193     
- Misses       7168     7479     +311
Impacted Files Coverage Δ
Bio/Phylo/TreeConstruction.py 93.96% <85.71%> (-0.21%) ⬇️
Bio/Graphics/KGML_vis.py 68.89% <0%> (-1.75%) ⬇️
Bio/SearchIO/BlastIO/blast_text.py 93.33% <0%> (-0.29%) ⬇️
Bio/SeqIO/InsdcIO.py 93.03% <0%> (-0.24%) ⬇️
Bio/phenotype/phen_micro.py 85.22% <0%> (ø) ⬆️
Bio/motifs/__init__.py 80.46% <0%> (ø) ⬆️
Bio/Phylo/PhyloXML.py 81.39% <0%> (ø) ⬆️
Bio/Seq.py 98.21% <0%> (ø) ⬆️
Bio/KDTree/__init__.py 100% <0%> (ø) ⬆️
Bio/motifs/thresholds.py 78.37% <0%> (ø) ⬆️
... and 47 more

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 cabc278...71a7c38. Read the comment docs.

The root var was being overwritten after the last commit. Now the minimum alignment case immediately returns the tree.
@peterjc

peterjc commented Jan 11, 2019

Copy link
Copy Markdown
Member

Much clearer now - what do you think @etal?

@peterjc peterjc assigned peterjc and etal and unassigned peterjc Jan 11, 2019
Added a case for matrices of length 1 which returns a trivial tree with 1 node.
@peterjc

peterjc commented Jan 22, 2019

Copy link
Copy Markdown
Member

@etal or @lijax does this look ready to merge?

@ZykeDev

ZykeDev commented Jan 29, 2019 •

Copy link
Copy Markdown
Contributor Author

Appveyor seems to run into this error, but I doubt it's in any way related to TreeConstruction:

File "C:\Py\lib\site-packages\PIL\Image.py", line 94, in <module> from . import _imaging as core ImportError: DLL load failed: The specified module could not be found

Should I fork from the latest commit (710fc1b), open another Pull Request and retry from there? My branch is 14 commits behind biopython:master.
I was also thinking about adding tests for minimal matrices to the NJ part of the Test Suite.

@peterjc

peterjc commented Feb 1, 2019

Copy link
Copy Markdown
Member

A similar PIL DLL problem showed up on another pull request, it may have been sorted out now...

The latest TravisCI flake8 problems (F117 and F632) were caused by a recent flake8 update, just fixed on the master branch. Any minor update to your branch should trigger a rebuild merged into the latest master branch (and thus fix that).

I don't think you need to, but the way to 'move' all your work to be on top of the a recent commit from the official master branch (or simply the latest master branch) would be with git rebase. Something like this:

git fetch origin  # get latest changes from official repository
git checkout patch-3  # make sure we're on your branch
git rebase origin/master  # rewrite branch history as if was starting from latest master
git push ZykeDev patch-3 --force  # update this pull request

You'd need to adjust origin and ZykeDev here if your remotes are named something else, perhaps upstream and origin respectively?

Note this is about the only time you'd ever use git push with --force as it will re-write the git history of the branch.

@ZykeDev

ZykeDev commented Feb 2, 2019

Copy link
Copy Markdown
Contributor Author

If flake8 and the other issues have been fixed then I guess I don't need to rebase. Thanks for the info tho.

@peterjc

peterjc commented Feb 3, 2019

Copy link
Copy Markdown
Member

Thank you.

If there are no comments/objections from @etal, @lijax (or anyone else familiar with this area of the code), I will aim to merge this at the end of the coming week.

@peterjc
peterjc merged commit ed27efd into biopython:master Feb 12, 2019
@peterjc

peterjc commented Feb 12, 2019

Copy link
Copy Markdown
Member

Squash-and-merged, thank you.

I'm assuming you don't want to be acknowledged by name as a contributor - but if you do, please just ask.

@lijax

lijax commented Feb 13, 2019

Copy link
Copy Markdown
Contributor

Sorry for the late reply. And thanks for your contribution @ZykeDev . As it's been 5 years since the first version of this library, and I'm currently not working in this field, it would be nice if you or someone else can maintain it with more clear knowledge in this field.

@peterjc

peterjc commented Feb 13, 2019

Copy link
Copy Markdown
Member

Great - thanks @lijax

peterjc added a commit to peterjc/biopython that referenced this pull request Nov 1, 2019
Original author Yanbo Ye and contributors since as
tracked with version control have all agreed:

 - Adhemar Zerlotini (@azneto)
   biopython#1412 (comment)
 - Carlos Pena (@carlosp420)
   biopython#898 (comment)
 - Chris Rands (@chris-rands)
   biopython#1301
 - Christian Brueffer (@cbrueffer)
   biopython#898 (comment)
 - Eric Talevich (@etal)
   biopython#898 (comment)
 - Jordan Willis (@jwillis0720)
   biopython#292 (comment)
 - Marco Vincenzi (@ZykeDev)
   biopython#1891
 - @morrme
   biopython#1172 (comment)
 - Peter Cock (@peterjc)
   biopython#898 (comment)
 - Ralf Stephan (@rwst)
   biopython#1900
 - Sergio Valqui (@svalqui)
   biopython#1749
 - Suresh Panneerselvam (@Amrithasuresh)
   biopython#1575
 - Travis Wrightsman (@twrightsman)
   biopython#898 (comment)
 - Yanbo Ye (@lijax)
   biopython#898 (comment)
peterjc added a commit to peterjc/biopython that referenced this pull request Nov 29, 2019
Original author Yanbo Ye and contributors since as
tracked with version control have all agreed:

 - Adhemar Zerlotini (@azneto)
   biopython#1412 (comment)
 - Carlos Pena (@carlosp420)
   biopython#898 (comment)
 - Chris Rands (@chris-rands)
   biopython#1301
 - Christian Brueffer (@cbrueffer)
   biopython#898 (comment)
 - Eric Talevich (@etal)
   biopython#898 (comment)
 - Jordan Willis (@jwillis0720)
   biopython#292 (comment)
 - Marco Vincenzi (@ZykeDev)
   biopython#1891
 - @morrme
   biopython#1172 (comment)
 - Peter Cock (@peterjc)
   biopython#898 (comment)
 - Ralf Stephan (@rwst)
   biopython#1900
 - Sergio Valqui (@svalqui)
   biopython#1749
 - Suresh Panneerselvam (@Amrithasuresh)
   biopython#1575
 - Travis Wrightsman (@twrightsman)
   biopython#898 (comment)
 - Yanbo Ye (@lijax)
   biopython#898 (comment)
peterjc added a commit that referenced this pull request Dec 3, 2019
Original author Yanbo Ye and contributors since as
tracked with version control have all agreed:

 - Adhemar Zerlotini (@azneto)
   #1412 (comment)
 - Carlos Pena (@carlosp420)
   #898 (comment)
 - Chris Rands (@chris-rands)
   #1301
 - Christian Brueffer (@cbrueffer)
   #898 (comment)
 - Eric Talevich (@etal)
   #898 (comment)
 - Jordan Willis (@jwillis0720)
   #292 (comment)
 - Marco Vincenzi (@ZykeDev)
   #1891
 - @morrme
   #1172 (comment)
 - Peter Cock (@peterjc)
   #898 (comment)
 - Ralf Stephan (@rwst)
   #1900
 - Sergio Valqui (@svalqui)
   #1749
 - Suresh Panneerselvam (@Amrithasuresh)
   #1575
 - Travis Wrightsman (@twrightsman)
   #898 (comment)
 - Yanbo Ye (@lijax)
   #898 (comment)
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.

4 participants