func (self *Writer) writeHeader(prefix byte, s seqio.Sequence) (n int, err error) { var ln int n, err = self.w.Write([]byte{prefix}) if err != nil { return } ln, err = io.WriteString(self.w, *s.Name()) if n += ln; err != nil { return } if desc := *s.Description(); len(desc) != 0 { ln, err = self.w.Write([]byte{' '}) if n += ln; err != nil { return } ln, err = io.WriteString(self.w, desc) if n += ln; err != nil { return } } ln, err = self.w.Write([]byte("\n")) n += ln return }
// Write a single sequence and return the number of bytes written and any error. func (self *Writer) Write(s seqio.Sequence) (n int, err error) { var ( ln, c int prefix = append([]byte{'\n'}, self.SeqPrefix...) ) id, desc := *s.Name(), *s.Description() header := make([]byte, 0, len(self.IDPrefix)+len(id)+len(desc)+1) header = append(header, self.IDPrefix...) header = append(header, id...) if len(desc) > 0 { header = append(header, ' ') header = append(header, desc...) } n, err = self.w.Write(header) if err == nil { for i := 0; i < s.Len(); i++ { if i%self.Width == 0 { ln, err = self.w.Write(prefix) if n += ln; err != nil { return } } ln, err = self.w.Write([]byte{byte(s.At(seq.Position{Pos: i, Ind: c}).L)}) if n += ln; err != nil { return } } ln, err = self.w.Write([]byte{'\n'}) if n += ln; err != nil { return } } return }