Compare commits

..

No commits in common. "9776d5a31e042845f5a812d4f67b72177603ad90" and "4e6c781c602e4ad944802f37854122080b25c8df" have entirely different histories.

3 changed files with 8 additions and 14 deletions

View file

@ -7,12 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [0.2.1] - 2023-01-11
### Added
- `translate` functionality for `Haplotype`s ([#31](https://github.com/BioJulia/SequenceVariation.jl/pull/31))
- More informative errors when constructing invalid `Haplotype`s ([#34](https://github.com/BioJulia/SequenceVariation.jl/pull/34))
## [0.2.0] - 2023-01-10
@ -70,8 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Variant` constructor to automatically detect mutations from a `BioAlignments.PairwiseAlignment`
- Methods to get reference and alternate bases from a `Variation`
[unreleased]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.2.1...HEAD
[0.2.1]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.2.0...v0.2.1
[unreleased]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.1.4...v0.2.0
[0.1.4]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/BioJulia/SequenceVariation.jl/compare/v0.1.2...v0.1.3

View file

@ -1,7 +1,7 @@
name = "SequenceVariation"
uuid = "eef6e190-9969-4f06-a38f-35a110a8fdc8"
authors = ["Jakob Nybo Nissen <jakobnybonissen@gmail.com>", "Thomas A. Christensen II <25492070+MillironX@users.noreply.github.com>"]
version = "0.2.1"
version = "0.2.0"
[deps]
BioAlignments = "00701ae9-d1dc-5365-b64a-a3a3ebf5695e"

View file

@ -29,8 +29,7 @@ function Haplotype{S,T}(
) where {S<:BioSequence,T<:BioSymbol}
sort!(edits; by=x -> x.pos)
result = Haplotype{S,T}(ref, edits, Unsafe())
valid, message = _is_valid(result)
valid || error(message)
_is_valid(result) || error("TODO") # report what kind of error message?
return result
end
@ -63,12 +62,11 @@ function _is_valid(h::Haplotype)
op = edit.x
# Sanity check: for this to be a valid variant, it must be comprised of valid
# variations
_is_valid(Variation(h.ref, edit)) || return (false, "Invalid Variation")
_is_valid(Variation(h.ref, edit)) || return false
# For substitutions we simply do not allow another modification of the same base
if op isa Substitution
pos in valid_positions ||
return (false, "Multiple modifications at same position")
pos in valid_positions || return false
valid_positions = (first(valid_positions) + 1):last(valid_positions)
last_was_insert = false
# Insertions affect 0 reference bases, so it does not modify the valid positions
@ -77,18 +75,18 @@ function _is_valid(h::Haplotype)
elseif op isa Insertion
pos in
((first(valid_positions) - 1 + last_was_insert):(last(valid_positions) + 1)) ||
return (false, "Multiple insertions at same position")
return false
last_was_insert = true
# Deletions obviously invalidate the reference bases that are deleted.
elseif op isa Deletion
len = length(op)
pos in (first(valid_positions):(last(valid_positions) - len + 1)) ||
return (false, "Deletion out of range")
return false
valid_positions = (first(valid_positions) + len):last(valid_positions)
last_was_insert = false
end
end
return (true, "")
return true
end
function Haplotype(