package utils

import (
	"math/rand"
	"strconv"
	"time"
)

func RandString(len int) string {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	bytes := make([]byte, len)
	for i := 0; i < len; i++ {
		b := r.Intn(26) + 65
		bytes[i] = byte(b)
	}
	return string(bytes)
}

func GetSampleAlleleNum(sampleId int) string {
	sampleIdString := strconv.Itoa(sampleId)
	var num string
	if len(sampleIdString) > 2 {
		num = sampleIdString[len(sampleIdString)-2:]
	} else {
		num = sampleIdString
	}
	if num[0:1] == "0" && len(num) == 2 {
		num = num[1:]
	}

	return num
}
