func splitter(chromosomalPRS map[string][]prsparser.PRS, chunkSize int) []PRSSitesOnChrom {
	out := make([]PRSSitesOnChrom, 0)

	var subChunk PRSSitesOnChrom

	// For each chromosome
	for chrom, prsSites := range chromosomalPRS {
		if subChunk.Chrom == "" {
			// We are initializing from scratch
			subChunk.Chrom = chrom
			subChunk.PRSSites = make([]prsparser.PRS, 0, chunkSize)
		}

		if subChunk.Chrom != chrom {
			// We have moved to a new chromosome
			out = append(out, subChunk)
			subChunk = PRSSitesOnChrom{
				Chrom:    chrom,
				PRSSites: make([]prsparser.PRS, 0, chunkSize),
			}
		}

		// Within this chromosome, add sites into different chunks
		for k, prsSite := range prsSites {
			subChunk.PRSSites = append(subChunk.PRSSites, prsSite)

			// But if we have iterated to our chunk size, then create a new
			// chunk
			if k > 0 && k%chunkSize == 0 {
				out = append(out, subChunk)
				subChunk = PRSSitesOnChrom{
					Chrom:    chrom,
					PRSSites: make([]prsparser.PRS, 0, chunkSize),
				}
			}
		}
	}

	// Clean up at the end
	if subChunk.Chrom != "" {
		out = append(out, subChunk)
	}

	return out
}
// splitter parallelizes the computation. Each separate goroutine will process a
// set of sites. Each goroutine will have its own BGEN and BGI filehandles.
splitter parallelizes the computation. Each separate goroutine will process a
set of sites. Each goroutine will have its own BGEN and BGI filehandles.
// splitter parallelizes the computation . Each separate goroutine will process a // set of sites . Each goroutine will have its own BGEN and BGI filehandles .
func splitter(chromosomalPRS map[string][]prsparser.PRS, chunkSize int) []PRSSitesOnChrom {
	out := make([]PRSSitesOnChrom, 0)
	var subChunk PRSSitesOnChrom
	for chrom, prsSites := range chromosomalPRS {
		if subChunk.Chrom == "" {
			subChunk.Chrom = chrom
			subChunk.PRSSites = make([]prsparser.PRS, 0, chunkSize)
		}
		if subChunk.Chrom != chrom {
			out = append(out, subChunk)
			subChunk = PRSSitesOnChrom{
				Chrom:    chrom,
				PRSSites: make([]prsparser.PRS, 0, chunkSize),
			}
		}
		for k, prsSite := range prsSites {
			subChunk.PRSSites = append(subChunk.PRSSites, prsSite)
			if k > 0 && k%chunkSize == 0 {
				out = append(out, subChunk)
				subChunk = PRSSitesOnChrom{
					Chrom:    chrom,
					PRSSites: make([]prsparser.PRS, 0, chunkSize),
				}
			}
		}
	}
	if subChunk.Chrom != "" {
		out = append(out, subChunk)
	}
	return out
}
func splitter ( chromosomalPRS map [ string ] [ ] prsparser . PRS , chunkSize int ) [ ] PRSSitesOnChrom { out := make ( [ ] PRSSitesOnChrom , 0 ) var subChunk PRSSitesOnChrom for chrom , prsSites := range chromosomalPRS { if subChunk . Chrom == " " { subChunk . Chrom = chrom subChunk . PRSSites = make ( [ ] prsparser . PRS , 0 , chunkSize ) } if subChunk . Chrom != chrom { out = append ( out , subChunk ) subChunk = PRSSitesOnChrom { Chrom : chrom , PRSSites : make ( [ ] prsparser . PRS , 0 , chunkSize ) , } } for k , prsSite := range prsSites { subChunk . PRSSites = append ( subChunk . PRSSites , prsSite ) if k > 0 && k % chunkSize == 0 { out = append ( out , subChunk ) subChunk = PRSSitesOnChrom { Chrom : chrom , PRSSites : make ( [ ] prsparser . PRS , 0 , chunkSize ) , } } } } if subChunk . Chrom != " " { out = append ( out , subChunk ) } return out }
splitter parallelizes the computation.
splitter parallelizes the computation .
// For each chromosome // We are initializing from scratch // We have moved to a new chromosome // Within this chromosome, add sites into different chunks // But if we have iterated to our chunk size, then create a new // chunk // Clean up at the end