Exemple #1
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
}
Exemple #2
0
		self.S = s
		self.circular = false
		self.offset = 0
	}

	return
}

// Return a string representation of the sequence. Representation is determined by the Stringify field.
func (self *QSeq) String() string { return self.Stringify(self) }

// The default Stringify function for QSeq.
var QStringify = func(s seq.Polymer) string {
	t := s.(*QSeq)
	gap := t.Alphabet().Gap()
	cs := make([]alphabet.Letter, 0, len(t.S))
	for _, ql := range t.S {
		if alphabet.Qphred(ql.Q) > t.Threshold || ql.L == gap {
			cs = append(cs, ql.L)
		} else {
			cs = append(cs, t.LowQFilter(t, ql.L))
		}
	}

	return alphabet.Letters(cs).String()
}

// The default LowQFilter function for QSeq.
var LowQFilter = func(s seq.Sequence, _ alphabet.Letter) alphabet.Letter { return s.(*QSeq).alphabet.Ambiguous() }
Exemple #3
0
// Encode the quality at position pos to a letter based on the sequence encoding setting.
func (self *QSeq) QEncode(pos seq.Position) byte {
	if pos.Ind != 0 {
		panic("packed: index out of range")
	}
	return alphabet.Qphred(self.S[pos.Pos-self.offset] >> 2).Encode(self.encoding)
}
Exemple #4
0
// Return the probability of a sequence error at position pos.
func (self *QSeq) EAt(pos seq.Position) float64 {
	if pos.Ind != 0 {
		panic("packed: index out of range")
	}
	return alphabet.Qphred(self.S[pos.Pos-self.offset] >> 2).ProbE()
}
Exemple #5
0
	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
}

// Return a string representation of the sequence. Representation is determined by the Stringify field.
func (self *QSeq) String() string { return self.Stringify(self) }

// The default Stringify function for QSeq.
var QStringify = func(s seq.Polymer) string {
	t := s.(*QSeq)
	cs := make([]alphabet.Letter, 0, len(t.S))
	for _, l := range t.S {
		if alphabet.Qphred(l>>2) > t.Threshold {
			cs = append(cs, t.alphabet.Letter(int(l&0x3)))
		} else {
			cs = append(cs, t.LowQFilter(t, t.alphabet.Letter(int(l&0x3))))
		}
	}

	return alphabet.Letters(cs).String()
}

// The default LowQFilter function for QSeq.
var LowQFilter = func(s seq.Sequence, _ alphabet.Letter) alphabet.Letter { return s.(*QSeq).alphabet.Ambiguous() }