Documentation ¶
Overview ¶
Package alignment handles aligned sequences stored as columns.
Index ¶
- type QRow
- func (r QRow) Alphabet() alphabet.Alphabet
- func (r QRow) At(i int) alphabet.QLetter
- func (r QRow) Clone() seq.Sequence
- func (r QRow) CloneAnnotation() *seq.Annotation
- func (r QRow) Conformation() feat.Conformation
- func (r QRow) Description() string
- func (r QRow) EAt(i int) float64
- func (r QRow) Encoding() alphabet.Encoding
- func (r QRow) End() int
- func (r QRow) Format(fs fmt.State, c rune)
- func (r QRow) Len() int
- func (r QRow) Location() feat.Feature
- func (r QRow) Name() string
- func (r QRow) New() seq.Sequence
- func (r QRow) QEncode(i int) byte
- func (r QRow) RevComp()
- func (r QRow) Reverse()
- func (r QRow) Set(i int, l alphabet.QLetter) error
- func (r QRow) SetConformation(c feat.Conformation) error
- func (r QRow) SetE(i int, e float64) error
- func (r QRow) SetEncoding(e alphabet.Encoding) error
- func (r QRow) SetOffset(o int) error
- func (r QRow) SetSlice(_ alphabet.Slice)
- func (r QRow) Slice() alphabet.Slice
- func (r QRow) Start() int
- func (r QRow) String() string
- type QSeq
- func (s *QSeq) Add(n ...seq.Sequence) error
- func (s *QSeq) AppendColumns(a ...[]alphabet.QLetter) error
- func (s *QSeq) AppendEach(a [][]alphabet.QLetter) error
- func (s *QSeq) Clone() seq.Rower
- func (s *QSeq) Column(pos int, _ bool) []alphabet.Letter
- func (s *QSeq) ColumnQL(pos int, _ bool) []alphabet.QLetter
- func (s *QSeq) Consensus(_ bool) *linear.QSeq
- func (s *QSeq) Delete(i int)
- func (s *QSeq) Encoding() alphabet.Encoding
- func (s *QSeq) End() int
- func (s *QSeq) Format(fs fmt.State, c rune)
- func (s *QSeq) Len() int
- func (s *QSeq) New() *QSeq
- func (s *QSeq) RevComp()
- func (s *QSeq) Reverse()
- func (s *QSeq) Row(i int) seq.Sequence
- func (s *QSeq) Rows() int
- func (s *QSeq) SetEncoding(e alphabet.Encoding) error
- func (s *QSeq) SetSlice(sl alphabet.Slice)
- func (s *QSeq) Slice() alphabet.Slice
- func (s *QSeq) Start() int
- func (s *QSeq) String() string
- type Row
- func (r Row) Alphabet() alphabet.Alphabet
- func (r Row) At(i int) alphabet.QLetter
- func (r Row) Clone() seq.Sequence
- func (r Row) CloneAnnotation() *seq.Annotation
- func (r Row) Conformation() feat.Conformation
- func (r Row) Description() string
- func (r Row) End() int
- func (r Row) Format(fs fmt.State, c rune)
- func (r Row) Len() int
- func (r Row) Location() feat.Feature
- func (r Row) Name() string
- func (r Row) New() seq.Sequence
- func (r Row) RevComp()
- func (r Row) Reverse()
- func (r Row) Set(i int, l alphabet.QLetter) error
- func (r Row) SetConformation(c feat.Conformation) error
- func (r Row) SetOffset(o int) error
- func (r Row) SetSlice(_ alphabet.Slice)
- func (r Row) Slice() alphabet.Slice
- func (r Row) Start() int
- func (r Row) String() string
- type Seq
- func (s *Seq) Add(n ...seq.Sequence) error
- func (s *Seq) AppendColumns(a ...[]alphabet.QLetter) error
- func (s *Seq) AppendEach(a [][]alphabet.QLetter) error
- func (s *Seq) Clone() seq.Rower
- func (s *Seq) Column(pos int, _ bool) []alphabet.Letter
- func (s *Seq) ColumnQL(pos int, _ bool) []alphabet.QLetter
- func (s *Seq) Consensus(_ bool) *linear.QSeq
- func (s *Seq) Delete(i int)
- func (s *Seq) End() int
- func (s *Seq) Format(fs fmt.State, c rune)
- func (s *Seq) Len() int
- func (s *Seq) New() *Seq
- func (s *Seq) RevComp()
- func (s *Seq) Reverse()
- func (s *Seq) Row(i int) seq.Sequence
- func (s *Seq) Rows() int
- func (s *Seq) SetSlice(sl alphabet.Slice)
- func (s *Seq) Slice() alphabet.Slice
- func (s *Seq) Start() int
- func (s *Seq) String() string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type QRow ¶
A Row is a pointer into an alignment that satisfies the seq.Sequence and seq.Scorer interfaces.
func (QRow) CloneAnnotation ¶
func (r QRow) CloneAnnotation() *seq.Annotation
func (QRow) Conformation ¶
func (r QRow) Conformation() feat.Conformation
func (QRow) Description ¶
func (QRow) End ¶
End returns the end position of the sequence in coordinates relative to the sequence location.
func (QRow) Format ¶
Format is a support routine for fmt.Formatter. It accepts the formats 'v' and 's' (string), 'a' (fasta) and 'q' (fastq). String, fasta and fastq formats support truncated output via the verb's precision. Fasta format supports sequence line specification via the verb's width field. Fastq format supports optional inclusion of the '+' line descriptor line with the '+' flag. The 'v' verb supports the '#' flag for Go syntax output. The 's' and 'v' formats support the '-' flag for omission of the sequence name.
func (QRow) QEncode ¶
QEncode encodes the quality at position i to a letter based on the sequence encoding setting.
func (QRow) SetConformation ¶
func (r QRow) SetConformation(c feat.Conformation) error
type QSeq ¶
type QSeq struct { seq.Annotation SubAnnotations []seq.Annotation Seq alphabet.QColumns ColumnConsense seq.ConsenseFunc Threshold alphabet.Qphred // Threshold for returning valid letter. QFilter seq.QFilter // How to represent below threshold letter. Encode alphabet.Encoding }
A QSeq is an aligned sequence with quality scores.
func NewQSeq ¶
func NewQSeq(id string, subids []string, ql [][]alphabet.QLetter, alpha alphabet.Alphabet, enc alphabet.Encoding, cons seq.ConsenseFunc) (*QSeq, error)
NewSeq creates a new Seq with the given id, letter sequence and alphabet.
Example ¶
qm, err := NewQSeq("example alignment", []string{"seq 1", "seq 2", "seq 3"}, [][]alphabet.QLetter{ {{'A', 40}, {'A', 40}, {'A', 40}}, {{'C', 40}, {'C', 40}, {'C', 40}}, {{'G', 40}, {'G', 40}, {'G', 40}}, {{'C', 40}, {'G', 40}, {'A', 40}}, {{'T', 40}, {'T', 40}, {'T', 40}}, {{'G', 40}, {'G', 40}, {'G', 40}}, {{'A', 40}, {'A', 40}, {'A', 40}}, {{'C', 40}, {'C', 40}, {'C', 40}}, {{'T', 40}, {'C', 40}, {'G', 40}}, {{'T', 40}, {'T', 40}, {'T', 40}}, {{'G', 40}, {'G', 40}, {'G', 40}}, {{'G', 40}, {'G', 40}, {'G', 40}}, {{'T', 40}, {'C', 40}, {'C', 40}}, {{'G', 40}, {'G', 40}, {'G', 40}}, {{'C', 40}, {'C', 40}, {'C', 40}}, {{'A', 40}, {'G', 40}, {'T', 40}}, {{'C', 40}, {'C', 40}, {'C', 40}}, {{'G', 40}, {'A', 40}, {'A', 40}}, {{'T', 40}, {'T', 40}, {'T', 40}}, }, alphabet.DNA, alphabet.Sanger, seq.DefaultQConsensus) if err == nil { fmt.Printf("%-s\n\n%-s\n", qm, qm.Consensus(false)) }
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgntgacntggcgcncat
func (*QSeq) Add ¶
Add sequences n to Alignment. Sequences in n must align start and end with the receiving alignment. Additional sequence will be clipped.
Example ¶
fmt.Printf("%v %-s\n", qm.Rows(), qm.Consensus(false)) qm.Add(linear.NewQSeq("example DNA", []alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}}, alphabet.DNA, alphabet.Sanger)) fmt.Printf("%v %-s\n", qm.Rows(), qm.Consensus(false))
Output: 3 acgntgacntggcgcncat 4 acgctgacntggcgcncat
func (*QSeq) AppendColumns ¶
AppendColumns appends each Qletter of each element of a to the appropriate sequence in the receiver.
func (*QSeq) AppendEach ¶
AppendEach appends each []alphabet.QLetter in a to the appropriate sequence in the receiver.
func (*QSeq) Consensus ¶
Consensus returns a quality sequence reflecting the consensus of the receiver determined by the ColumnConsense field.
func (*QSeq) Delete ¶
Delete removes the sequence represented at row i of the alignment. It panics if i is out of range.
func (*QSeq) End ¶
End returns the end position of the sequence in coordinates relative to the sequence location.
func (*QSeq) Format ¶
Format is a support routine for fmt.Formatter. It accepts the formats 'v' and 's' (string), 'a' (fasta) and 'q' (fastq). String, fasta and fastq formats support truncated output via the verb's precision. Fasta format supports sequence line specification via the verb's width field. Fastq format supports optional inclusion of the '+' line descriptor line with the '+' flag. The 'v' verb supports the '#' flag for Go syntax output. The 's' and 'v' formats support the '-' flag for omission of the sequence name.
func (*QSeq) RevComp ¶
func (s *QSeq) RevComp()
RevComp reverse complements the sequence. RevComp will panic if the alphabet used by the receiver is not a Complementor.
Example ¶
fmt.Printf("%-s\n\n%-s\n\n", qm, qm.Consensus(false)) qm.RevComp() fmt.Printf("%-s\n\n%-s\n", qm, qm.Consensus(false))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgCtg------------- acgctgacntggcgcncat ACGTGCACCAAGTCAGCGT ATGCGCGCCAGGTCACCGT ATGAGCGCCACGTCATCGT -------------caGcgt atgngcgccangtcagcgt
func (*QSeq) Reverse ¶
func (s *QSeq) Reverse()
Reverse reverses the order of letters in the the sequence without complementing them.
func (*QSeq) Row ¶
Row returns the sequence represented at row i of the alignment. It panics is i is out of range.
func (*QSeq) SetEncoding ¶
SetEncoding sets the quality encoding scheme to e.
func (*QSeq) SetSlice ¶
SetSlice sets the sequence data represented by the Seq. SetSlice will panic if sl is not a QColumns.
type Row ¶
A Row is a pointer into an alignment that satisfies the seq.Sequence interface.
func (Row) CloneAnnotation ¶
func (r Row) CloneAnnotation() *seq.Annotation
func (Row) Conformation ¶
func (r Row) Conformation() feat.Conformation
func (Row) Description ¶
func (Row) End ¶
End returns the end position of the sequence in coordinates relative to the sequence location.
func (Row) Format ¶
Format is a support routine for fmt.Formatter. It accepts the formats 'v' and 's' (string), 'a' (fasta) and 'q' (fastq). String, fasta and fastq formats support truncated output via the verb's precision. Fasta format supports sequence line specification via the verb's width field. Fastq format supports optional inclusion of the '+' line descriptor line with the '+' flag. The 'v' verb supports the '#' flag for Go syntax output. The 's' and 'v' formats support the '-' flag for omission of the sequence name.
func (Row) SetConformation ¶
func (r Row) SetConformation(c feat.Conformation) error
type Seq ¶
type Seq struct { seq.Annotation SubAnnotations []seq.Annotation Seq alphabet.Columns ColumnConsense seq.ConsenseFunc }
A Seq is an aligned sequence.
func NewSeq ¶
func NewSeq(id string, subids []string, b [][]alphabet.Letter, alpha alphabet.Alphabet, cons seq.ConsenseFunc) (*Seq, error)
NewSeq creates a new Seq with the given id, letter sequence and alphabet.
Example ¶
m, err := NewSeq("example alignment", []string{"seq 1", "seq 2", "seq 3"}, [][]alphabet.Letter{ []alphabet.Letter("AAA"), []alphabet.Letter("CCC"), []alphabet.Letter("GGG"), []alphabet.Letter("CGA"), []alphabet.Letter("TTT"), []alphabet.Letter("GGG"), []alphabet.Letter("AAA"), []alphabet.Letter("CCC"), []alphabet.Letter("TCG"), []alphabet.Letter("TTT"), []alphabet.Letter("GGG"), []alphabet.Letter("GGG"), []alphabet.Letter("TCC"), []alphabet.Letter("GGG"), []alphabet.Letter("CCC"), []alphabet.Letter("AGT"), []alphabet.Letter("CCC"), []alphabet.Letter("GAA"), []alphabet.Letter("TTT"), }, alphabet.DNA, seq.DefaultConsensus) if err == nil { fmt.Printf("%-s\n\n%-s\n", m, m.Consensus(false)) }
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgntgacntggcgcncat
func (*Seq) Add ¶
Add adds the sequences n to Seq. Sequences in n should align start and end with the receiving alignment. Additional sequence will be clipped and missing sequence will be filled with the gap letter.
Example ¶
fmt.Printf("%v %-s\n", m.Rows(), m.Consensus(false)) m.Add(linear.NewQSeq("example DNA", []alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}}, alphabet.DNA, alphabet.Sanger)) fmt.Printf("%v %-s\n", m.Rows(), m.Consensus(false))
Output: 3 acgntgacntggcgcncat 4 acgctgacntggcgcncat
func (*Seq) AppendColumns ¶
AppendColumns appends each Qletter of each element of a to the appropriate sequence in the receiver.
func (*Seq) AppendEach ¶
AppendEach appends each []alphabet.QLetter in a to the appropriate sequence in the receiver.
func (*Seq) Consensus ¶
Consensus returns a quality sequence reflecting the consensus of the receiver determined by the ColumnConsense field.
func (*Seq) Delete ¶
Delete removes the sequence represented at row i of the alignment. It panics if i is out of range.
func (*Seq) End ¶
End returns the end position of the sequence in coordinates relative to the sequence location.
func (*Seq) Format ¶
Format is a support routine for fmt.Formatter. It accepts the formats 'v' and 's' (string), 'a' (fasta) and 'q' (fastq). String, fasta and fastq formats support truncated output via the verb's precision. Fasta format supports sequence line specification via the verb's width field. Fastq format supports optional inclusion of the '+' line descriptor line with the '+' flag. The 'v' verb supports the '#' flag for Go syntax output. The 's' and 'v' formats support the '-' flag for omission of the sequence name.
func (*Seq) RevComp ¶
func (s *Seq) RevComp()
RevComp reverse complements the sequence. RevComp will panic if the alphabet used by the receiver is not a Complementor.
Example ¶
fmt.Printf("%-s\n\n%-s\n", m, m.Consensus(false)) fmt.Println() m.RevComp() fmt.Printf("%-s\n\n%-s\n", m, m.Consensus(false))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgCtg------------- acgctgacntggcgcncat ACGTGCACCAAGTCAGCGT ATGCGCGCCAGGTCACCGT ATGAGCGCCACGTCATCGT -------------caGcgt atgngcgccangtcagcgt
func (*Seq) Reverse ¶
func (s *Seq) Reverse()
Reverse reverses the order of letters in the the sequence without complementing them.
func (*Seq) Row ¶
Row returns the sequence represented at row i of the alignment. It panics is i is out of range.
func (*Seq) SetSlice ¶
SetSlice sets the sequence data represented by the Seq. SetSlice will panic if sl is not a Columns.