Documentation
¶
Index ¶
- Constants
- Variables
- func Op(op uint64) (byte, uint32)
- func RecycleAligner(algn *Aligner)
- func RecycleAlignmentResult(cigar *AlignmentResult)
- func RecycleAlignmentText(Q, A, T *[]byte)
- func RecycleComponent(cpt *Component)
- func RecycleWaveFront(wf *WaveFront)
- type AdaptiveReductionOption
- type Aligner
- func (algn *Aligner) AdaptiveReduction(ad *AdaptiveReductionOption) error
- func (algn *Aligner) Align(q, t []byte) (*AlignmentResult, error)
- func (algn *Aligner) AlignPointers(q, t *[]byte) (*AlignmentResult, error)
- func (algn *Aligner) Plot(q, t *[]byte, wtr io.Writer, _M *Component, notChangeToMatch bool, ...)
- type AlignmentResult
- func (cigar *AlignmentResult) Add(op byte)
- func (cigar *AlignmentResult) AddN(op byte, n uint32)
- func (cigar *AlignmentResult) AlignmentText(q0, t0 *[]byte, onlyAignedRegion bool) (*[]byte, *[]byte, *[]byte)
- func (cigar *AlignmentResult) CIGAR(onlyAignedRegion bool) string
- func (cigar *AlignmentResult) Update(n uint32)
- type Component
- func (cpt *Component) Delete(s uint32, k int)
- func (cpt *Component) Get(s uint32, k int) (uint32, uint32, bool)
- func (cpt *Component) GetAfterDiff(s uint32, diff uint32, k int) (uint32, uint32, bool)
- func (cpt *Component) GetRaw(s uint32, k int) (uint32, bool)
- func (cpt *Component) GetRawAfterDiff(s uint32, diff uint32, k int) (uint32, bool)
- func (cpt *Component) HasScore(s uint32) bool
- func (cpt *Component) Increase(s uint32, k int, delta uint32)
- func (cpt *Component) KRange(s, diff uint32) (int, int)
- func (cpt *Component) Print(wtr io.Writer, name string)
- func (cpt *Component) Reset()
- func (cpt *Component) Set(s uint32, k int, offset uint32, wfaType uint32)
- func (cpt *Component) SetRaw(s uint32, k int, offset uint32)
- type Options
- type Penalties
- type WaveFront
- func (wf *WaveFront) Delete(k int)
- func (wf *WaveFront) Get(k int) (uint32, uint32, bool)
- func (wf *WaveFront) GetRaw(k int) (uint32, bool)
- func (wf *WaveFront) Increase(k int, delta uint32)
- func (wf *WaveFront) Set(k int, offset uint32, wfaType uint32)
- func (wf *WaveFront) SetRaw(k int, offsetWithType uint32)
- func (wf *WaveFront) String() string
Constants ¶
const MaskLower32 = 4294967295
const MaxSeqLen int = 1<<(32-wfaTypeBits) - 1
MaxSeqLen is the allowed longest sequence length.
const OpD = uint64('D')
const OpH = uint64('H')
const OpI = uint64('I')
const OpM = uint64('M')
const OpX = uint64('X')
Variables ¶
var DefaultAdaptiveOption = &AdaptiveReductionOption{
MinWFLen: 10,
MaxDistDiff: 50,
CutoffStep: 1,
}
DefaultAdaptiveOption provides a default option with parameters from the official repo. attributes.heuristic.min_wavefront_length = 10; attributes.heuristic.max_distance_threshold = 50; attributes.heuristic.steps_between_cutoffs = 1;
var DefaultOptions = &Options{ GlobalAlignment: true, }
DefaultOptions is the default option
var DefaultPenalties = &Penalties{
Mismatch: 4,
GapOpen: 6,
GapExt: 2,
}
DefaultPenalties is from the WFA paper.
var ErrEmptySeq error = fmt.Errorf("wfa: invalid empty sequence")
ErrEmptySeq means the query or target sequence is empty.
var ErrSeqTooLong error = fmt.Errorf("wfa: sequences longer than %d are not supported", MaxSeqLen)
ErrSeqTooLong means the sequence is too long.
var OFFSETS_BASE_SIZE = 128
OFFSETS_BASE_SIZE is the base size of the offset slice.
var WAVEFRONTS_BASE_SIZE = 2048
WAVEFRONTS_BASE_SIZE is the base size of the wavefront slice.
Functions ¶
func RecycleAlignmentResult ¶ added in v0.2.0
func RecycleAlignmentResult(cigar *AlignmentResult)
RecycleAlignmentResult recycles a CIGAR object.
func RecycleAlignmentText ¶ added in v0.2.0
func RecycleAlignmentText(Q, A, T *[]byte)
RecycleAlignmentText recycle alignment text.
func RecycleComponent ¶ added in v0.2.0
func RecycleComponent(cpt *Component)
RecycleComponent recycles a Component.
func RecycleWaveFront ¶ added in v0.2.0
func RecycleWaveFront(wf *WaveFront)
RecycleWaveFront recycles a WaveFront.
Types ¶
type AdaptiveReductionOption ¶
type AdaptiveReductionOption struct { MinWFLen uint32 MaxDistDiff uint32 CutoffStep uint32 // not used yet. }
AdaptiveReductionOption contains the parameters for adaptive reduction
type Aligner ¶
type Aligner struct {
M, I, D *Component
// contains filtered or unexported fields
}
Aligner is the object for aligning, which can apply to multiple pairs of query and ref sequences. But it's not occurrence safe, which means you can't call Align() in multiple goroutines. Instead, you can create multiple aligners, one for each goroutine. Aligner objects are from a object pool, in case a large number of alignments are needed. Just remember to recyle it with RecycleAligner().
func New ¶
New returns a new Aligner from the object pool. Do not forget to call RecycleAligner() after using it.
func (*Aligner) AdaptiveReduction ¶
func (algn *Aligner) AdaptiveReduction(ad *AdaptiveReductionOption) error
AdaptiveReduction sets the adaptive reduction parameters
func (*Aligner) Align ¶
func (algn *Aligner) Align(q, t []byte) (*AlignmentResult, error)
Align performs alignment with two sequences.
func (*Aligner) AlignPointers ¶
func (algn *Aligner) AlignPointers(q, t *[]byte) (*AlignmentResult, error)
AlignPointers performs alignment with two sequences. The arguments are pointers.
func (*Aligner) Plot ¶
func (algn *Aligner) Plot(q, t *[]byte, wtr io.Writer, _M *Component, notChangeToMatch bool, maxScore int)
Plot plots one WFA component as a tab-delimited text table.
A table cell contains the alignment type symbol and the score. Symbols:
⊕ Unknown, ⟼ Gap open (Insertion) 🠦 Gap extension (Insertion) ↧ Gap open (Deletion) 🠧 Gap extension (Deletion) ⬂ Mismatch ⬊ Match
type AlignmentResult ¶ added in v0.2.0
type AlignmentResult struct { // Ops []*CIGARRecord Ops []uint64 // 24-bit null + 8 bit Op + 32-bit N Score uint32 // Alignment score TBegin, TEnd int // 1-based location of the alignment in target seq, no including flanking clipping/insertion sequences QBegin, QEnd int // 1-based location of the alignment in query seq, no including flanking clipping/insertion sequences // Stats of the aligned region, no including flanking clipping/insertion sequences AlignLen uint32 Matches uint32 Gaps uint32 GapRegions uint32 // contains filtered or unexported fields }
AlignmentResult represent a AlignmentResult structure.
func NewAlignmentResult ¶ added in v0.2.0
func NewAlignmentResult(globalAlignment bool) *AlignmentResult
NewAlignmentResult returns a new CIGAR from the object pool.
func (*AlignmentResult) Add ¶ added in v0.2.0
func (cigar *AlignmentResult) Add(op byte)
Add adds a new record in backtrace.
func (*AlignmentResult) AddN ¶ added in v0.2.0
func (cigar *AlignmentResult) AddN(op byte, n uint32)
Add adds a new record in backtrace and set its number as n.
func (*AlignmentResult) AlignmentText ¶ added in v0.2.0
func (cigar *AlignmentResult) AlignmentText(q0, t0 *[]byte, onlyAignedRegion bool) (*[]byte, *[]byte, *[]byte)
AlignmentText returns the formated alignment text for Query, Alignment, and Target. Do not forget to recycle them with RecycleAlignmentText().
func (*AlignmentResult) CIGAR ¶ added in v0.2.0
func (cigar *AlignmentResult) CIGAR(onlyAignedRegion bool) string
CIGAR returns the CIGAR string.
func (*AlignmentResult) Update ¶ added in v0.2.0
func (cigar *AlignmentResult) Update(n uint32)
Update updates the last record.
type Component ¶ added in v0.2.0
type Component struct { IsM bool // if it is true, the visualization is slightly different WaveFronts []*WaveFront // WaveFronts }
Component is the wavefront component, it's a list of wavefronts for different scores. To support fast access, we use a list to them, the nil data means there's no such wavefront for a given score.
func NewComponent ¶ added in v0.2.0
func NewComponent() *Component
NewComponent returns a new Component object. If you do not need it, do not remember to use RecycleComponent() to recycle it.
func (*Component) GetAfterDiff ¶ added in v0.2.0
GetAfterDiff returns offset, wfaType, existed for s-diff and k.
func (*Component) GetRawAfterDiff ¶ added in v0.2.0
GetRaw returns "offset<<wfaTypeBits | wfaType", existed for s-diff and k.
func (*Component) Increase ¶ added in v0.2.0
Increase increases the offset by delta. Here delta does not contain the backtrace type
func (*Component) KRange ¶ added in v0.2.0
KRange returns the lowest and highest values of k for score s-diff. Since scores are saved in uint32, if diff > s, s-diff would be a large value. So we have to check the two values first.
func (*Component) Reset ¶ added in v0.2.0
func (cpt *Component) Reset()
Reset clears all existing wavefronts for new using.
type Options ¶
type Options struct {
GlobalAlignment bool
}
Options represents a list of options. Currently it only support global or semi-global alignment.
type WaveFront ¶ added in v0.2.0
type WaveFront struct {
Lo, Hi int // Lowest and Highest k.
Offsets []uint32 // offset data. We preset 2048 values to avoid frequent append operation.
}
WaveFront is a list of offsets for different k values. We also use the low 3 bits to store the backtrace type.
Since k might be negative and usually the values are symmetrical, we store them like this (ZigZag encoding):
index: 0, 1, 2, 3, 4, 5, 6 k: 0, -1, 1, -2, 2, -3, 3
if the value is 0, it means there's no records for that k.
func NewWaveFront ¶ added in v0.2.0
func NewWaveFront() *WaveFront
NewWaveFront creates a new WaveFront object. If you do not need it, do not remember to use RecycleWaveFront() to recycle it.
func (*WaveFront) Increase ¶ added in v0.2.0
Increase increases the offset by delta. Here delta does not contain the backtrace type.