func (r *Reference) Len() int {
	if r == nil {
		return -1
	}
	return int(r.lRef)
}
Len returns the length of the reference sequence.
package sam
import (
	"bytes"
	"encoding/hex"
	"errors"
	"fmt"
	"net/url"
	"sort"
	"strconv"
)
type Reference struct {
	owner     *Header
	id        int32
	name      string
	lRef      int32
	md5       string
	assemID   string
	species   string
	uri       *url.URL
	otherTags []tagPair
}
func NewReference(name, assemID, species string, length int, md5 []byte, uri *url.URL) (*Reference, error) {
	if !validLen(length) {
		return nil, errors.New("sam: length out of range")
	}
	if name == "" {
		return nil, errors.New("sam: no name provided")
	}
	var h string
	if md5 != nil {
		if len(md5) != 16 {
			return nil, errors.New("sam: invalid md5 sum length")
		}
		h = string(md5[:])
	}
	return &Reference{
		id:      -1,  
		name:    name,
		lRef:    int32(length),
		md5:     h,
		assemID: assemID,
		species: species,
		uri:     uri,
	}, nil
}
func (r *Reference) ID() int {
	if r == nil {
		return -1
	}
	return int(r.id)
}
func (r *Reference) Name() string {
	if r == nil {
		return "*"
	}
	return r.name
}
func (r *Reference) SetName(n string) error {
	if r.owner != nil {
		id, exists := r.owner.seenRefs[n]
		if exists {
			if id != r.id {
				return errors.New("sam: name exists")
			}
			return nil
		}
		delete(r.owner.seenRefs, r.name)
		r.owner.seenRefs[n] = r.id
	}
	r.name = n
	return nil
}
func (r *Reference) AssemblyID() string {
	if r == nil {
		return ""
	}
	return r.assemID
}
func (r *Reference) Species() string {
	if r == nil {
		return ""
	}
	return r.species
}
func (r *Reference) MD5() []byte {
	if r == nil || r.md5 == "" {
		return nil
	}
	return []byte(r.md5)
}
func (r *Reference) URI() string {
	if r == nil {
		return ""
	}
	return fmt.Sprintf("%s", r.uri)
}