1
0
Fork 0
mirror of https://github.com/MillironX/XAM.jl.git synced 2024-11-26 03:29:55 +00:00

Merge pull request #55 from MillironX/feature/bioalignments-3

This commit is contained in:
Thomas A. Christensen II 2022-10-13 14:15:58 -05:00 committed by GitHub
commit e2b22becf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 29 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Upgraded to BioAlignments v3 ([#53](https://github.com/BioJulia/XAM.jl/pull/53))
## [0.3.0] ## [0.3.0]
## Added ## Added

View file

@ -17,7 +17,7 @@ TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
[compat] [compat]
Automa = "0.7, 0.8" Automa = "0.7, 0.8"
BGZFStreams = "0.3.1" BGZFStreams = "0.3.1"
BioAlignments = "2.2" BioAlignments = "3"
BioGenerics = "0.1" BioGenerics = "0.1"
BioSequences = "3" BioSequences = "3"
FormatSpecimens = "1.1" FormatSpecimens = "1.1"

View file

@ -430,27 +430,11 @@ end
Get the alignment of `record`. Get the alignment of `record`.
""" """
function alignment(record::Record)::BioAlignments.Alignment function alignment(record::Record)::BioAlignments.Alignment
checkfilled(record) if ismapped(record)
if !ismapped(record) return BioAlignments.Alignment(cigar(record), 1, position(record))
return BioAlignments.Alignment(BioAlignments.AlignmentAnchor[])
end end
seqpos = 0
refpos = position(record) - 1 return BioAlignments.Alignment(BioAlignments.AlignmentAnchor[])
anchors = [BioAlignments.AlignmentAnchor(seqpos, refpos, BioAlignments.OP_START)]
for (op, len) in zip(cigar_rle(record)...)
if BioAlignments.ismatchop(op)
seqpos += len
refpos += len
elseif BioAlignments.isinsertop(op)
seqpos += len
elseif BioAlignments.isdeleteop(op)
refpos += len
else
error("operation $(op) is not supported")
end
push!(anchors, BioAlignments.AlignmentAnchor(seqpos, refpos, op))
end
return BioAlignments.Alignment(anchors)
end end
function hasalignment(record::Record) function hasalignment(record::Record)

View file

@ -79,10 +79,10 @@
@test BAM.flag(record) === UInt16(16) @test BAM.flag(record) === UInt16(16)
@test BAM.cigar(record) == "27M1D73M" @test BAM.cigar(record) == "27M1D73M"
@test BAM.alignment(record) == Alignment([ @test BAM.alignment(record) == Alignment([
AlignmentAnchor( 0, 1, OP_START), AlignmentAnchor( 0, 1, 0, OP_START),
AlignmentAnchor( 27, 28, OP_MATCH), AlignmentAnchor( 27, 28, 27, OP_MATCH),
AlignmentAnchor( 27, 29, OP_DELETE), AlignmentAnchor( 27, 29, 28, OP_DELETE),
AlignmentAnchor(100, 102, OP_MATCH)]) AlignmentAnchor(100, 102, 101, OP_MATCH)])
@test record["XG"] == 1 @test record["XG"] == 1
@test record["XM"] == 5 @test record["XM"] == 5
@test record["XN"] == 0 @test record["XN"] == 0

View file

@ -104,10 +104,10 @@
@test SAM.flag(record) == 16 @test SAM.flag(record) == 16
@test SAM.cigar(record) == "27M1D73M" @test SAM.cigar(record) == "27M1D73M"
@test SAM.alignment(record) == Alignment([ @test SAM.alignment(record) == Alignment([
AlignmentAnchor( 0, 1, OP_START), AlignmentAnchor( 0, 1, 0, OP_START),
AlignmentAnchor( 27, 28, OP_MATCH), AlignmentAnchor( 27, 28, 27, OP_MATCH),
AlignmentAnchor( 27, 29, OP_DELETE), AlignmentAnchor( 27, 29, 28, OP_DELETE),
AlignmentAnchor(100, 102, OP_MATCH)]) AlignmentAnchor(100, 102, 101, OP_MATCH)])
@test record["XG"] == 1 @test record["XG"] == 1
@test record["XM"] == 5 @test record["XM"] == 5
@test record["XN"] == 0 @test record["XN"] == 0