Exemplo n.º 1
0
func init() {
	var err error
	m, err = NewMulti("example multi",
		[]nucleic.Sequence{
			nucleic.NewSeq("example DNA 1", []alphabet.Letter("ACGCTGACTTGGTGCACGT"), alphabet.DNA),
			nucleic.NewSeq("example DNA 2", []alphabet.Letter("ACGGTGACCTGGCGCGCAT"), alphabet.DNA),
			nucleic.NewSeq("example DNA 3", []alphabet.Letter("ACGATGACGTGGCGCTCAT"), alphabet.DNA),
		},
		nucleic.Consensify)

	if err != nil {
		panic(err)
	}
}
Exemplo n.º 2
0
// Return an unpacked sequence.
func (self *Seq) Unpack() (n *nucleic.Seq) {
	n = nucleic.NewSeq(self.ID, alphabet.BytesToLetters([]byte(self.String())), self.alphabet)
	n.Circular(self.circular)
	n.Offset(self.offset)

	return
}
Exemplo n.º 3
0
func ExampleSet_AppendEach() {
	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] = nucleic.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.Println(s)
	}
	// Output:
	// ACGCTGACTTGGTGCACGTAA
	// ACGACTGGGACGTCC
	// ACGCTGACTGGCCGTGG
	// GCCTTTGCACGTTT
}
Exemplo n.º 4
0
func (self *Seq) Extract(i int) nucleic.Sequence {
	s := make([]alphabet.Letter, 0, self.Len())
	for _, c := range self.S {
		s = append(s, c[i])
	}

	return nucleic.NewSeq(self.SubIDs[i], s, self.alphabet)
}
Exemplo n.º 5
0
func ExampleNewMulti() {
	m, err := NewMulti("example multi",
		[]nucleic.Sequence{
			nucleic.NewSeq("example DNA 1", []alphabet.Letter("ACGCTGACTTGGTGCACGT"), alphabet.DNA),
			nucleic.NewSeq("example DNA 2", []alphabet.Letter("ACGGTGACCTGGCGCGCAT"), alphabet.DNA),
			nucleic.NewSeq("example DNA 3", []alphabet.Letter("ACGATGACGTGGCGCTCAT"), alphabet.DNA),
		},
		nucleic.Consensify)

	if err != nil {
		return
	}

	aligned(m)
	// Output:
	// ACGCTGACTTGGTGCACGT
	// ACGGTGACCTGGCGCGCAT
	// ACGATGACGTGGCGCTCAT
	//
	// acgntgacntggcgcncat
}
Exemplo n.º 6
0
// Return an unpacked sequence and quality.
func (self *QSeq) Unpack() (n *nucleic.Seq, q *quality.Phred) {
	n = nucleic.NewSeq(self.ID, alphabet.BytesToLetters([]byte(self.String())), self.alphabet)
	n.Circular(self.circular)
	n.Offset(self.offset)
	qb := make([]alphabet.Qphred, self.Len())
	for i, v := range self.S {
		qb[i] = alphabet.Qphred(v >> 2)
	}
	q = quality.NewPhred(self.ID, qb, self.encoding)
	q.Circular(self.circular)
	q.Offset(self.offset)

	return
}