Skip to content

Commit

Permalink
Merge pull request #85 from BioJulia/release/v2.3.0
Browse files Browse the repository at this point in the history
Downstream tests are failing because the breaking change from
#44 was merged here.
  • Loading branch information
MillironX committed Oct 1, 2022
2 parents 782063c + eceafe6 commit b92ccf3
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 5 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Alignment position support (#44)

## [2.2.0]
## [2.3.0] - 2022-10-01

### Added
- Getter functions for `AlignedSequence`, `PairwiseAlignment`, and
`PairwiseAlignmentResult` (#83)

## [2.2.0] - 2022-07-07

### Added- Compact printing of alignments (#53)
- More SubstitutionMatrix operations (#60)
Expand Down Expand Up @@ -106,7 +112,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.1.0] - 2017-06-30
- This initial release extracted the alignment utilities out from Bio.jl into this dedicated package.

[Unreleased]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.2.0...HEAD
[Unreleased]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.3.0...HEAD
[2.2.1]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/BioJulia/BioAlignments.jl/compare/v2.0.0...v2.0.1
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BioAlignments"
uuid = "00701ae9-d1dc-5365-b64a-a3a3ebf5695e"
authors = ["Kenta Sato <bicycle1885@gmail.com>", "Sabrina J. Ward <sabrinajward@protonmail.com>"]
version = "2.2.0"
version = "2.3.0"

[deps]
BioGenerics = "47718e42-2ac5-11e9-14af-e5595289c2ea"
Expand Down
21 changes: 21 additions & 0 deletions docs/src/alignments.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,24 @@ julia> AlignedSequence(seq, ref)
ACGT--AAT--
```

You can get the underlying alignment and sequence back out of an
`AlignedSequence` by using the `alignment` and `sequence` functions.

```jldoctest
julia> aln = AlignedSequence(dna"ACGT--AAT--", dna"ACGTTTAT-GG")
········-··
ACGT--AAT--
julia> alignment(aln)
Alignment:
aligned range:
seq: 0-7
ref: 0-10
CIGAR string: 4=2D1=1X1I2D
julia> sequence(aln)
7nt DNA Sequence:
ACGTAAT
```
3 changes: 3 additions & 0 deletions docs/src/pairalign.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ PairwiseAlignment{BioSequences.LongSequence{BioSequences.DNAAlphabet{4}}, BioSeq
||| || || |
ref: 1 ACCT-GGTATGATAGCG 16
julia> sequence(res)
10nt DNA Sequence:
CCTAGGAGGG
julia> count_matches(aln)
8
Expand Down
3 changes: 2 additions & 1 deletion src/BioAlignments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export
score,
distance,
alignment,
hasalignment
hasalignment,
sequence

using BioGenerics
import BioGenerics: distance
Expand Down
15 changes: 15 additions & 0 deletions src/alignedseq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@ function AlignedSequence(seq::BioSequences.BioSequence, seqpos::Integer,
return AlignedSequence(newseq, anchors)
end

# Getter functions
"""
alignment(aligned_sequence)
Gets the [`Alignment`](@ref) of `aligned_sequence`.
"""
alignment(alnseq::AlignedSequence) = alnseq.aln

"""
sequence(aligned_sequence)
Return the sequence of `aligned_sequence`.
"""
sequence(alnseq::AlignedSequence) = alnseq.seq

# First position in the reference sequence.
function IntervalTrees.first(alnseq::AlignedSequence)
return alnseq.aln.firstref
Expand Down
15 changes: 15 additions & 0 deletions src/pairwise/alignment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ mutable struct PairwiseAlignment{S1,S2}
b::S2
end

# Getter functions
"""
alignment(pairwise_alignment)
Gets the underlying [`Alignment`](@ref) from `pairwise_alignment`.
"""
alignment(aln::PairwiseAlignment) = alignment(aln.a)

"""
sequence(pairwise_alignment)
Gets the query sequence of `pairwise_alignment`.
"""
sequence(aln::PairwiseAlignment) = sequence(aln.a)

function Base.iterate(aln::PairwiseAlignment, ij=(2,1))
i, j = ij
if i > lastindex(aln.a.aln.anchors)
Expand Down
12 changes: 11 additions & 1 deletion src/pairwise/result.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ hasalignment(aln::PairwiseAlignmentResult) = aln.aln !== nothing
"""
alignment(alignment_result)
Return alignment if any.
Return the alignment if any as a [`PairwiseAlignment`](@ref). To get the
[`Alignment`](@ref), nest the function, e.g. `alignment(alignment(alignment_result))`.
This function returns a `PairwiseAlignment` instead of an `Alignment` for
backwards-compatibility reasons.
See also: `hasalignment`
"""
Expand All @@ -64,6 +67,13 @@ function alignment(aln::PairwiseAlignmentResult)
return aln.aln
end

"""
sequence(alignment_result)
Return the query sequence of `alignment_result`, if it exists.
"""
sequence(aln::PairwiseAlignmentResult) = sequence(alignment(aln))


# Printer
# -------
Expand Down

0 comments on commit b92ccf3

Please sign in to comment.