Exemple #1
0
func SeqToBioseq(s seq.Sequence) string {
	ret := ""

	for i := s.Start(); i < s.End(); i++ {
		ret += string(s.At(i).L)
	}

	return ret
}
Exemple #2
0
// Write a single sequence and return the number of bytes written and any error.
func (w *Writer) Write(s seq.Sequence) (n int, err error) {
	var (
		_n     int
		prefix = append([]byte{'\n'}, w.SeqPrefix...)
	)
	id, desc := s.Name(), s.Description()
	header := make([]byte, 0, len(w.IDPrefix)+len(id)+len(desc)+1)
	header = append(header, w.IDPrefix...)
	header = append(header, id...)
	if len(desc) > 0 {
		header = append(header, ' ')
		header = append(header, desc...)
	}

	n, err = w.w.Write(header)
	if err != nil {
		return n, err
	}
	for i := 0; i < s.Len(); i++ {
		if i%w.Width == 0 {
			_n, err = w.w.Write(prefix)
			if n += _n; err != nil {
				return n, err
			}
		}
		_n, err = w.w.Write([]byte{byte(s.At(i).L)})
		if n += _n; err != nil {
			return n, err
		}
	}
	_n, err = w.w.Write([]byte{'\n'})
	if n += _n; err != nil {
		return n, err
	}

	return n, nil
}