BioJulia / BioAlignments.jl

Sequence alignment tools
MIT License
60 stars 24 forks source link

Allow compact printing of alignments #53

Closed jakobnissen closed 3 years ago

jakobnissen commented 3 years ago

This changes printing of PairwiseAlignment and PairwiseAlignmentResult, such that they are displayed compactly in vectors and other structs. (I was getting annoyed by having my terminal wrecked when printing vectors of alignments).

When compact, they are now displayed like this:

julia> [aln]
1-element Vector{PairwiseAlignment{LongDNASeq, LongDNASeq}}:
 PairwiseAlignment{LongDNASeq, LongDNASeq}()

julia> [alnresult]
1-element Vector{PairwiseAlignmentResult{Int64, LongDNASeq, LongDNASeq}}:
 PairwiseAlignmentResult{Int64, LongDNASeq, LongDNASeq}(score=15)

This does violate the principle that the thing being printed should contain all the relevant information in the object, but in this case, I think there is no way to do this.

codecov[bot] commented 3 years ago

Codecov Report

Merging #53 (2c6f47f) into master (492cd58) will decrease coverage by 0.58%. The diff coverage is 36.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #53      +/-   ##
==========================================
- Coverage   88.32%   87.73%   -0.59%     
==========================================
  Files          17       16       -1     
  Lines        1079     1052      -27     
==========================================
- Hits          953      923      -30     
- Misses        126      129       +3     
Impacted Files Coverage Δ
src/pairwise/result.jl 43.47% <0.00%> (-9.16%) :arrow_down:
src/pairwise/alignment.jl 98.21% <87.50%> (-0.86%) :arrow_down:
src/operations.jl 85.71% <0.00%> (-4.61%) :arrow_down:
src/pairwise/algorithms/banded_needleman_wunsch.jl 76.35% <0.00%> (-2.96%) :arrow_down:
src/pairwise/algorithms/common.jl 90.32% <0.00%> (-0.86%) :arrow_down:
src/pairwise/algorithms/needleman_wunsch.jl 84.29% <0.00%> (-0.38%) :arrow_down:
src/BioAlignments.jl
src/submat.jl 98.07% <0.00%> (+0.01%) :arrow_up:
src/alignment.jl 79.16% <0.00%> (+0.83%) :arrow_up:
src/anchors.jl 100.00% <0.00%> (+16.66%) :arrow_up:

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 492cd58...2c6f47f. Read the comment docs.

BioTurboNick commented 3 years ago

Is there some summary information that would be useful to print? aligned length, ungapped length of each sequence?

CiaranOMara commented 3 years ago

Does IOContext offer anything here?

jakobnissen commented 3 years ago

Does IOContext offer anything here?

Not 100% sure, but the docs for show states:

Checking the :compact IOContext property of io in such methods is recommended, since some containers show their elements by calling this method with :compact => true.

But yeah, good point @BioTurboNick , I'll add some more info. And also a few more tests of printing, just to make codecov happy :)

jakobnissen commented 3 years ago

Codecov is acting up, this is most definitely covered by the tests. Merging