func (s *Shard) RecordInStartPadding(r *sam.Record) bool {
	paddedStartCoord := NewCoord(s.StartRef, s.PaddedStart(), 0)
	startCoord := NewCoord(s.StartRef, s.Start, 0)
	coord := CoordFromSAMRecord(r, 0)
	return coord.GE(paddedStartCoord) && coord.LT(startCoord)
}
RecordInStartPadding returns true if r is in the start padding of s.
package bam
import (
	"context"
	"fmt"
	"math"
	"math/rand"
	"strings"
	"github.com/grailbio/base/backgroundcontext"
	"github.com/grailbio/base/file"
	"github.com/grailbio/base/log"
	"github.com/grailbio/bio/biopb"
	"github.com/grailbio/hts/bam"
	"github.com/grailbio/hts/bgzf"
	"github.com/grailbio/hts/sam"
)
var UniversalRange = biopb.CoordRange{
	Start: biopb.Coord{0, 0, 0},
	Limit: biopb.Coord{biopb.InfinityRefID, biopb.InfinityPos, 0},
}
var MappedRange = biopb.CoordRange{
	Start: biopb.Coord{0, 0, 0},
	Limit: biopb.Coord{biopb.LimitValidRefID, biopb.InfinityPos, 0},
}
type Shard struct {
	StartRef *sam.Reference
	EndRef   *sam.Reference
	Start    int
	End      int
	StartSeq int
	EndSeq   int
	Padding  int
	ShardIdx int
}
func UniversalShard(header *sam.Header) Shard {
	var startRef *sam.Reference
	if len(header.Refs()) > 0 {
		startRef = header.Refs()[0]
	}
	return Shard{
		StartRef: startRef,
		EndRef:   nil,
		Start:    0,
		End:      math.MaxInt32,
	}
}
func (s *Shard) PadStart(padding int) int {
	return max(0, s.Start-padding)
}
func (s *Shard) PaddedStart() int {
	return s.PadStart(s.Padding)
}
func (s *Shard) PadEnd(padding int) int {
	if s.End == 0 && s.EndSeq == 0 {
		return 0
	}
	if s.EndRef == nil {
		return min(math.MaxInt32, s.End+padding)
	}
	return min(s.EndRef.Len(), s.End+padding)
}
func (s *Shard) PaddedEnd() int {
	return s.PadEnd(s.Padding)
}
func (s *Shard) RecordInShard(r *sam.Record) bool {
	return s.CoordInShard(0, CoordFromSAMRecord(r, 0))
}
func (s *Shard) MateInShard(r *sam.Record) bool {
	return s.CoordInShard(0, MateCoordFromSAMRecord(r, 0))
}
func (s *Shard) RecordInPaddedShard(r *sam.Record) bool {
	return s.CoordInShard(s.Padding, CoordFromSAMRecord(r, 0))
}