Skip to content

pairwise2: Improved format_alignment for local alignments and alignments of lists - #1505

Merged
MarkusPiotrowski merged 4 commits into
biopython:masterfrom
MarkusPiotrowski:pairwise2
Mar 18, 2019
Merged

MarkusPiotrowski merged 4 commits into
biopython:masterfrom
MarkusPiotrowski:pairwise2

Conversation

@MarkusPiotrowski

Copy link
Copy Markdown
Contributor

This pull request builds upon #1352 where the pretty print output of pairwise2 was already improved by changing the match line for distinguishing between matches and mismatches.

This PR addresses local alignments and alignments of lists:

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 am happy be thanked by name in the NEWS.rst and CONTRIB.rst files,
and have added myself to those files as part of this pull request. (This
acknowledgement is optional. Note we list the names sorted alphabetically.
)

@MarkusPiotrowski

Copy link
Copy Markdown
Contributor Author

OK, need to have a look at the tutorial.

@codecov

codecov Bot commented Jan 16, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #1505 into master will increase coverage by 1.32%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1505      +/-   ##
==========================================
+ Coverage   83.71%   85.04%   +1.32%     
==========================================
  Files         310      311       +1     
  Lines       50077    50137      +60     
==========================================
+ Hits        41923    42640     +717     
+ Misses       8154     7497     -657
Impacted Files Coverage Δ
Bio/pairwise2.py 83.54% <100%> (+0.36%) ⬆️
Bio/PDB/mmtf/DefaultParser.py 100% <0%> (ø)
Bio/Entrez/Parser.py 81.75% <0%> (+0.53%) ⬆️
Bio/Restriction/Restriction.py 83.42% <0%> (+0.56%) ⬆️
Bio/Cluster/__init__.py 82.92% <0%> (+0.73%) ⬆️
Bio/Application/__init__.py 87.74% <0%> (+1.18%) ⬆️
Bio/Blast/Applications.py 85.91% <0%> (+1.4%) ⬆️
Bio/PDB/PDBParser.py 89.83% <0%> (+1.69%) ⬆️
Bio/SeqIO/NibIO.py 91.3% <0%> (+2.17%) ⬆️
Bio/PDB/Residue.py 81.01% <0%> (+2.53%) ⬆️
... and 21 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 47497d6...ab2bd18. Read the comment docs.

@peterjc

peterjc commented Jan 16, 2018

Copy link
Copy Markdown
Member

Ping @JoaoRodrigues and @bow who also joined in the earlier discussion.

I know we talked about this before (on #1352), but one-based coordinates make me a little uneasy. I won't attempt to veto this, as I accept this is being used in a human facing pretty-print, rather than a developer facing __repr__ where I would want a Python style zero-based coordinate.

Otherwise this looks good to merge.

@bow

bow commented Jan 16, 2018

Copy link
Copy Markdown
Member

Would it improve things if we are explicit about the coordinate system? IMO part of the problem with 0/1-based coordinates is that we often have to guess which one is being used.

For pretty-printing, I don't think it would hurt if we simply also output whether we are using 0 or 1-based coordinate.

@MarkusPiotrowski

Copy link
Copy Markdown
Contributor Author

My reason for using the 1-based start position is that the output of format_alignment is similar to a typical blast output or the output of EMBOSS' needle/water, which both use a 1-based numbering, so that most people seeing something like

6 GGGAATTCCC
  ||||.|||||
8 GGGATTTCCC
  Score=9

just expect that this is 1-based. (Actually I do not know any software that uses 0-based numbering in pretty print output, but I only know a few) People who need the real coordinates won't fetch them from the pretty print output, these numbers are given in the alignment result itself.

I don't like the idea to add something in the pretty print output regarding the coordinate system for several reasons:

  • The docstring explains this already
  • The starting position is only printed if (1) we have a local alignment and (2) if the local alignment does not cover the whole sequence. So for all global alignments and some local alignments the starting positions are not printed
  • The align function will often return several alignments, which can be nicely listed (and compared) using a for loop and the format_alignment function. Another text line would somehow disturb this picture.

@peterjc

peterjc commented Mar 16, 2019

Copy link
Copy Markdown
Member

Apologies that this PR got forgotten about. @mdehoon - do you agree with merging this?

@mdehoon

mdehoon commented Mar 17, 2019

Copy link
Copy Markdown
Contributor

I have no objections.

@MarkusPiotrowski

Copy link
Copy Markdown
Contributor Author

Thank you very much for approving, merging this now.

@dturaev

dturaev commented Jul 3, 2019

Copy link
Copy Markdown

Sorry, I'm a little confused about the coordinates right now: The SeqIO documentation says "When storing sequence coordinates (start and end values), Bio.SearchIO uses the Python-style slice convention: zero-based and half-open intervals. For example, if in a BLAST XML output file the start and end coordinates of an HSP are 10 and 28, they would become 9 and 28 in Bio.SearchIO." However, I'm parsing a blast xml output, and I'm under the impression that the coordinates (especially hsp.query_start) are actually 1-based. (In general, keeping the 1-based coordinates as given by blast might better correspond to the Principle of Least Surprise, than converting them to 0-based, no?)

@dturaev

dturaev commented Jul 3, 2019

Copy link
Copy Markdown

Sorry, my fault, I just noticed that I used Bio.Blast.NCBIXML as the parser, not SeqIO. That probably explains it. Thanks.

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.

5 participants