code: func (r *Record) MarshalSAM(flags int) ([]byte, error) {
  	if flags < FlagDecimal || flags > FlagString {
  		return nil, errors.New("sam: flag format option out of range")
  	}
  	if r.Qual != nil && len(r.Qual) != r.Seq.Length {
  		return nil, errors.New("sam: sequence/quality length mismatch")
  	}
  	var buf bytes.Buffer
  	fmt.Fprintf(&buf, "%s\t%v\t%s\t%d\t%d\t%s\t%s\t%d\t%d\t%s\t%s",
  		r.Name,
  		formatFlags(r.Flags, flags),
  		r.Ref.Name(),
  		r.Pos+1,
  		r.MapQ,
  		r.Cigar,
  		formatMate(r.Ref, r.MateRef),
  		r.MatePos+1,
  		r.TempLen,
  		formatSeq(r.Seq),
  		formatQual(r.Qual),
  	)
  	for _, t := range r.AuxFields {
  		fmt.Fprintf(&buf, "\t%v", samAux(t))
  	}
  	return buf.Bytes(), nil
  }
docs: // MarshalSAM formats a Record as SAM using the specified flag format. Acceptable
  // formats are FlagDecimal, FlagHex and FlagString.