Documentation ¶
Overview ¶
Package cigar contains functions to manipulate cigar data in the SAM file format. More information on cigars can be found in http://samtools.github.io/hts-specs/SAMv1.pdf
Index ¶
- Constants
- func ByteCigarToString(cigar []ByteCigar) string
- func ByteCigarToUint32(cigar []ByteCigar) []uint32
- func ByteMatrixTrace(a int64, b int64, c int64) (int64, byte)
- func ConsumesQuery(r rune) bool
- func ConsumesReference(r rune) bool
- func IsValidCigar(op byte) bool
- func MatchLength(c []Cigar) int
- func MatrixSetup(size int) ([][]int64, [][]byte)
- func NumDeletions(input []Cigar) int
- func NumInsertions(input []Cigar) int
- func QueryLength(c []Cigar) int
- func QueryRunLen(c []ByteCigar) int
- func ReferenceLength(c []Cigar) int
- func ReverseBytesCigar(alpha []ByteCigar)
- func ToString(c []Cigar) string
- type ByteCigar
- type Cigar
Constants ¶
const ( Match byte = 'M' Insertion byte = 'I' Deletion byte = 'D' N byte = 'N' SoftClip byte = 'S' HardClip byte = 'H' Padded byte = 'P' Equal byte = '=' Mismatch byte = 'X' Unknown byte = '*' )
Defined const for byte cigar.
Variables ¶
This section is empty.
Functions ¶
func ByteCigarToString ¶
ByteCigarToString will process the cigar byte struct and parse and/or convert the data into a string.
func ByteCigarToUint32 ¶
ByteCigarToUint32 will convert a slice of []ByteCigar to a slice of []uint32.
func ByteMatrixTrace ¶
ByteMatrixTrace will trace smith-waterman matrix alignment and return one of 3 cigar Op's. M: matches or mismatches, I: insertions, D: for deletions.
func ConsumesQuery ¶
ConsumesQuery returns true for input runes that match query consuming characters for Cigars.
func ConsumesReference ¶
ConsumesReference returns true of the rune matches an operation character that is reference consuming for Cigars.
func IsValidCigar ¶
IsValidCigar will perform a check to make sure op is a valid byte.
func MatchLength ¶
MatchLength returns the number of bases in a Cigar slice that align to the reference.
func MatrixSetup ¶
MatrixSetup will allocate memory for smith-waterman matrix to be used with byte cigar opertations and trace back.
func NumDeletions ¶
NumDeletions calculates the number of deletions relative to a reference genome for an input Cigar slice.
func NumInsertions ¶
NumInsertions calculates the number of inserted bases relative to a reference genome for an input Cigar slice.
func QueryLength ¶
QueryLength calculates the length of the query read from a slice of Cigar structs.
func QueryRunLen ¶
QueryLength calculates the length of the query read from a slice of Cigar structs.
func ReferenceLength ¶
ReferenceLength calculates the number of reference positions that a Cigar slice spans.
func ReverseBytesCigar ¶
func ReverseBytesCigar(alpha []ByteCigar)
ReverseBytesCigar cigar will reverse the order of a cigar slice. Typically performed after matrix traceback from a local alignment.
Types ¶
type ByteCigar ¶
ByteCigar struct encodes sequence comparison operations and includes run length info.
func AddCigarByte ¶
AddCigarByte will add append a cigar byte to an existing slice. The function will perform a check on the tail of the slice and incurment the run length if the cigar Op values are the same.
func CatByteCigar ¶
CatByteCigar will concatenate two cigar slices into one merged.
func ReadToBytesCigar ¶
ReadToBytesCigar will process a byte slice and define a small.
func Uint32ToByteCigar ¶
Uint32ToByteCigar will process a uint32 slice and decode each number into a byte cigar struct. CIGAR operation lengths are limited to 2^28-1 in the current sam/bam formats.
type Cigar ¶
Cigar contains information on the runLength, operation, and DNA sequence associated with a particular cigar character.
func AddCigar ¶
AddCigar adds a cigar struct to the end of a slice, but is smart about checking to see if the addition is the same operation that is present at the end of the existing slice and just increasing the run length of that entry.
func CatCigar ¶
CatCigar cats two cigars together, but is smart about checking to see if the last element of the first slice is the same operation as the first element of the second slice. In this case it will compress that struct into a single element with a longer run length.
func FromString ¶
FromString parses an input string into a slice of Cigar structs.