Documentation ¶
Overview ¶
Package multi handles collections of sequences as alignments or sets.
Index ¶
- func RegisterJoiner(p seq.Sequence, f JoinFunc)
- type JoinFunc
- type Multi
- func (m *Multi) Add(n ...seq.Sequence) error
- func (m *Multi) Append(i int, a ...alphabet.QLetter) (err error)
- func (m *Multi) AppendColumns(a ...[]alphabet.QLetter) (err error)
- func (m *Multi) AppendEach(a [][]alphabet.QLetter) (err error)
- func (m *Multi) Clone() seq.Rower
- func (m *Multi) Column(pos int, fill bool) []alphabet.Letter
- func (m *Multi) ColumnQL(pos int, fill bool) []alphabet.QLetter
- func (m *Multi) Compose(fs feat.Set) error
- func (m *Multi) Conformation() feat.Conformation
- func (m *Multi) Consensus(includeMissing bool) *linear.QSeq
- func (m *Multi) Delete(i int)
- func (m *Multi) Encoding() alphabet.Encoding
- func (m *Multi) End() int
- func (m *Multi) Flush(where int, fill alphabet.Letter)
- func (m *Multi) Format(fs fmt.State, c rune)
- func (m *Multi) IsFlush(where int) bool
- func (m *Multi) Join(a *Multi, where int) error
- func (m *Multi) Len() int
- func (m *Multi) RevComp()
- func (m *Multi) Reverse()
- func (m *Multi) Row(i int) seq.Sequence
- func (m *Multi) Rows() int
- func (m *Multi) SetConformation(c feat.Conformation)
- func (m *Multi) SetEncoding(e alphabet.Encoding)
- func (m *Multi) SetOffset(o int) error
- func (m *Multi) Start() int
- func (m *Multi) Stitch(fs feat.Set) error
- func (m *Multi) String() string
- func (m *Multi) Subseq(start, end int) (*Multi, error)
- func (m *Multi) Truncate(start, end int) error
- type Set
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterJoiner ¶
Types ¶
type Multi ¶
type Multi struct { seq.Annotation Seq []seq.Sequence ColumnConsense seq.ConsenseFunc Encode alphabet.Encoding }
func NewMulti ¶
Create a new Multi sequence.
Example ¶
m, err := NewMulti("example multi", []seq.Sequence{ linear.NewSeq("example DNA 1", []alphabet.Letter("ACGCTGACTTGGTGCACGT"), alphabet.DNA), linear.NewSeq("example DNA 2", []alphabet.Letter("ACGGTGACCTGGCGCGCAT"), alphabet.DNA), linear.NewSeq("example DNA 3", []alphabet.Letter("ACGATGACGTGGCGCTCAT"), alphabet.DNA), }, seq.DefaultConsensus) if err != nil { return } fmt.Printf("%- s\n\n%-s\n", m, m.Consensus(false))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgntgacntggcgcncat
func (*Multi) Add ¶
Add adds sequences n to the multiple sequence.
Example ¶
var err error fmt.Printf("%v %-s\n", m.Rows(), m.Consensus(false)) err = m.Add(linear.NewQSeq("example DNA", []alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}}, alphabet.DNA, alphabet.Sanger)) if err != nil { fmt.Println(err) return } fmt.Printf("%v %-s\n", m.Rows(), m.Consensus(false)) err = m.Add(linear.NewQSeq("example RNA", []alphabet.QLetter{{'a', 40}, {'c', 39}, {'g', 40}, {'C', 38}, {'t', 35}, {'g', 20}}, alphabet.RNA, alphabet.Sanger)) if err != nil { fmt.Println(err) return }
Output: 3 acgntgacntggcgcncat 4 acgctgacntggcgcncat multi: inconsistent alphabets
func (*Multi) AppendColumns ¶
Append each byte of each a to the appropriate sequence in the receiver.
func (*Multi) AppendEach ¶
AppendEach appends each []alphabet.QLetter in a to the appropriate sequence in the receiver.
func (*Multi) Compose ¶
Compose produces a composition of the receiver defined by the features in fs. The result is stored in the receiver and all contributing sequences are modified.
func (*Multi) Conformation ¶
func (m *Multi) Conformation() feat.Conformation
Conformation returns the sequence conformation.
func (*Multi) Consensus ¶
Consensus returns a quality sequence reflecting the consensus of the receiver determined by the ColumnConsense field.
func (*Multi) Delete ¶
Delete removes the sequence represented at row i of the alignment. It panics if i is out of range.
func (*Multi) End ¶
End returns the end position of the sequence in coordinates relative to the sequence location.
func (*Multi) Flush ¶
Flush fills ragged sequences with the receiver's gap letter so that all sequences are flush.
func (*Multi) 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 and in conjunction with this, the ' ' flag for alignment justification.
func (*Multi) IsFlush ¶
IsFlush returns a boolean indicating whether the end specified by where is flush - that is all the contributing sequences start at the same offset.
Example ¶
m.Row(3).SetOffset(13) fmt.Printf("%- s\n\n%-s\n", m, m.Consensus(false)) fmt.Printf("\nFlush at left: %v\nFlush at right: %v\n", m.IsFlush(seq.Start), m.IsFlush(seq.End)) m.Flush(seq.Start, '-') fmt.Printf("\n%- s\n\n%-s\n", m, m.Consensus(false)) fmt.Printf("\nFlush at left: %v\nFlush at right: %v\n", m.IsFlush(seq.Start), m.IsFlush(seq.End))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT acgCtg acgntgacntggcgcgcat Flush at left: false Flush at right: true ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT -------------acgCtg acgntgacntggcgcgcat Flush at left: true Flush at right: true
func (*Multi) Join ¶
Join joins a to the receiver at the end specied by where.
Example ¶
fmt.Printf("%- s\n\n%-s\n", n, n.Consensus(false)) n.Join(m, seq.End) fmt.Printf("\n%- s\n\n%-s\n", n, n.Consensus(false))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGtTGACGTGGCGCTCAT acgCtg acgctgacntggcgcncat ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT acgCtg--------------------------acgCtg acgctgacntggcgcncatacgntgacntggcgcgcat
func (*Multi) Len ¶
Len returns the length of the alignment.
Example ¶
fmt.Println(m.Len())
Output: 19
func (*Multi) RevComp ¶
func (m *Multi) RevComp()
RevComp reverse complements the sequence.
Example ¶
fmt.Printf("%- s\n\n%-s\n\n", m, m.Consensus(false)) m.RevComp() fmt.Printf("%- s\n\n%-s\n", m, m.Consensus(false))
Output: ACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCAT ACGATGACGTGGCGCTCAT -------------acgCtg acgntgacntggcgcgcat ACGTGCACCAAGTCAGCGT ATGCGCGCCAGGTCACCGT ATGAGCGCCACGTCATCGT caGcgt------------- atgcgcgccangtcancgt
func (*Multi) Reverse ¶
func (m *Multi) Reverse()
Reverse reverses the order of letters in the the sequence without complementing them.
func (*Multi) Row ¶
Row returns the sequence represented at row i of the alignment. It panics is i is out of range.
func (*Multi) SetConformation ¶
func (m *Multi) SetConformation(c feat.Conformation)
SetConformation sets the sequence conformation.
func (*Multi) SetEncoding ¶
SetEncoding sets the quality encoding scheme to e.
func (*Multi) Start ¶
Start returns the start position of the sequence in coordinates relative to the sequence location.
func (*Multi) Stitch ¶
Stitch produces a subsequence of the receiver defined by fs. The result is stored in the receiver and all contributing sequences are modified.
Example ¶
f := fs{ &fe{s: -1, e: 4}, &fe{s: 30, e: 38}, } fmt.Printf("%- s\n\n%-s\n\n", n, n.Consensus(false)) if err := n.Stitch(f); err == nil { fmt.Printf("%- s\n\n%-s\n", n, n.Consensus(false)) } else { fmt.Println(err) }
Output: ACGCTGACTTGGTGCACGTACGCTGACTTGGTGCACGT ACGGTGACCTGGCGCGCATACGGTGACCTGGCGCGCAT ACGtTGACGTGGCGCTCATACGATGACGTGGCGCTCAT acgCtg--------------------------acgCtg acgctgacntggcgcncatacgntgacntggcgcgcat ACGCGTGCACGT ACGGGCGCGCAT ACGtGCGCTCAT acgC--acgCtg acgcgcgcgcat
func (*Multi) Truncate ¶
Truncate truncates the the receiver from start to end.
Example ¶
fmt.Printf("%- s\n\n%-s\n\n", m, m.Consensus(false)) m.Truncate(4, 12) fmt.Printf("%- s\n\n%-s\n", m, m.Consensus(false))
Output: ACGTGCACCAAGTCAGCGT ATGCGCGCCAGGTCACCGT ATGAGCGCCACGTCATCGT caGcgt------------- atgcgcgccangtcancgt GCACCAAG GCGCCAGG GCGCCACG gt------ gcgccang
type Set ¶
func (Set) AppendEach ¶
Append each []byte in a to the appropriate sequence in the receiver.
Example ¶
ss := [][]alphabet.Letter{ []alphabet.Letter("ACGCTGACTTGGTGCACGT"), []alphabet.Letter("ACGACTGGGACGT"), []alphabet.Letter("ACGCTGACTGGCCGT"), []alphabet.Letter("GCCTTTGCACGT"), } set = make(Set, 4) for i := range set { set[i] = linear.NewSeq(fmt.Sprintf("example DNA %d", i), ss[i], alphabet.DNA) } as := [][]alphabet.QLetter{ alphabet.QLetter{L: 'A'}.Repeat(2), alphabet.QLetter{L: 'C'}.Repeat(2), alphabet.QLetter{L: 'G'}.Repeat(2), alphabet.QLetter{L: 'T'}.Repeat(2), } set.AppendEach(as) for _, s := range set { fmt.Printf("%-s\n", s) }
Output: ACGCTGACTTGGTGCACGTAA ACGACTGGGACGTCC ACGCTGACTGGCCGTGG GCCTTTGCACGTTT
func (Set) RevComp ¶
func (s Set) RevComp()
Example ¶
set.RevComp() for _, s := range set { fmt.Println(s) }
Output: