func (p *Program) String() string {
	var buf bytes.Buffer
	fmt.Fprintf(&buf, "@PG\tID:%s", p.uid)
	if p.name != "" {
		fmt.Fprintf(&buf, "\tPN:%s", p.name)
	}
	if p.command != "" {
		fmt.Fprintf(&buf, "\tCL:%s", p.command)
	}
	if p.previous != "" {
		fmt.Fprintf(&buf, "\tPP:%s", p.previous)
	}
	if p.version != "" {
		fmt.Fprintf(&buf, "\tVN:%s", p.version)
	}
	for _, tp := range p.otherTags {
		fmt.Fprintf(&buf, "\t%s:%s", tp.tag, tp.value)
	}
	return buf.String()
}
String returns a string representation of the program according to the
SAM specification section 1.3,
package sam
import (
	"bytes"
	"errors"
	"fmt"
)
type Program struct {
	owner     *Header
	id        int32
	uid       string
	previous  string
	name      string
	command   string
	version   string
	otherTags []tagPair
}
func NewProgram(uid, name, command, prev, v string) *Program {
	return &Program{
		id:       -1,
		uid:      uid,
		previous: prev,
		name:     name,
		command:  command,
		version:  v,
	}
}
func (p *Program) ID() int {
	if p == nil {
		return -1
	}
	return int(p.id)
}
func (p *Program) UID() string {
	if p == nil {
		return ""
	}
	return p.uid
}
func (r *Program) SetUID(uid string) error {
	if r.owner != nil {
		id, exists := r.owner.seenProgs[uid]
		if exists {
			if id != r.id {
				return errors.New("sam: uid exists")
			}
			return nil
		}
		delete(r.owner.seenProgs, r.uid)
		r.owner.seenProgs[uid] = r.id
	}
	r.uid = uid
	return nil
}
func (p *Program) Name() string {
	if p == nil {
		return ""
	}
	return p.name
}
func (p *Program) Command() string {
	if p == nil {
		return ""
	}
	return p.command
}
func (p *Program) Previous() string {
	if p == nil {
		return ""
	}
	return p.previous
}
func (p *Program) Version() string {
	if p == nil {
		return ""
	}
	return p.version
}
func (p *Program) Clone() *Program {
	if p == nil {
		return nil
	}
	cp := *p
	if len(cp.otherTags) != 0 {
		cp.otherTags = make([]tagPair, len(cp.otherTags))
	}
	copy(cp.otherTags, p.otherTags)
	cp.id = -1
	cp.owner = nil
	return &cp
}
func (p *Program) Tags(fn func(t Tag, value string)) {
	if fn == nil {
		return
	}
	fn(idTag, p.UID())
	if p.name != "" {
		fn(programNameTag, p.name)
	}
	if p.command != "" {
		fn(commandLineTag, p.command)
	}
	if p.previous != "" {
		fn(previousProgTag, p.previous)
	}
	if p.version != "" {
		fn(versionTag, p.version)
	}
	for _, tp := range p.otherTags {
		fn(tp.tag, tp.value)
	}
}
func (p *Program) Get(t Tag) string {
	switch t {
	case idTag:
		return p.UID()
	case programNameTag:
		return p.Name()
	case commandLineTag:
		return p.Command()
	case previousProgTag:
		return p.Previous()
	case versionTag:
		return p.Version()
	}
	for _, tp := range p.otherTags {
		if t == tp.tag {
			return tp.value
		}
	}
	return ""
}
func (p *Program) Set(t Tag, value string) error {
	switch t {
	case idTag:
		if value == "" {
			return errDupProgram
		}
	case programNameTag:
		p.name = value
	case commandLineTag:
		p.command = value
	case previousProgTag:
		p.previous = value
	case versionTag:
		p.version = value
	default:
		if value == "" {
			for i, tp := range p.otherTags {
				if t == tp.tag {
					copy(p.otherTags[i:], p.otherTags[i+1:])
					p.otherTags = p.otherTags[:len(p.otherTags)-1]
					return nil
				}
			}
		} else {
			for i, tp := range p.otherTags {
				if t == tp.tag {
					p.otherTags[i].value = value
					return nil
				}
			}
			p.otherTags = append(p.otherTags, tagPair{tag: t, value: value})
		}
	}
	return nil
}