<commit_before>package annotation

import (
	"bufio"
	"compress/bzip2"
	"compress/gzip"
	"io"
	"log"
	"os"
	"path"
	"strconv"
	"strings"

	"github.com/dhconnelly/rtreego"
	"github.com/guigolab/bamstats/utils"
)

// RtreeMap is a map of pointers to Rtree with string keys.
type RtreeMap map[string]*rtreego.Rtree

// Feature represents an annotated element.
type Feature struct {
	location *rtreego.Rect
	chr      string
	Element  string
}

// Chr returns the chromosome of the feature
func (f *Feature) Chr() string {
	return f.chr
}

// Start returns the start position of the feature
func (f *Feature) Start() float64 {
	return f.location.PointCoord(0)
}

// End returns the end position of the feature
func (f *Feature) End() float64 {
	return f.location.LengthsCoord(0) + f.Start()
}

// Bounds returns the location of the feature. It is used within the Rtree.
func (f *Feature) Bounds() *rtreego.Rect {
	return f.location
}

// Get returns the pointer to an Rtree for the specified chromosome.
func (t RtreeMap) Get(chr string) *rtreego.Rtree {
	if _, ok := t[chr]; !ok {
		t[chr] = rtreego.NewTree(2, 25, 50)
	}
	return t[chr]
}

func getFileReader(f *os.File, fname string) *bufio.Scanner {
	var r io.Reader = f

	switch path.Ext(fname) {
	case ".gz":<commit_msg>Update documentation for RtreeMap.Get function<commit_after>package annotation

import (
	"bufio"
	"compress/bzip2"
	"compress/gzip"
	"io"
	"log"
	"os"
	"path"
	"strconv"
	"strings"

	"github.com/dhconnelly/rtreego"
	"github.com/guigolab/bamstats/utils"
)

// RtreeMap is a map of pointers to Rtree with string keys.
type RtreeMap map[string]*rtreego.Rtree

// Feature represents an annotated element.
type Feature struct {
	location *rtreego.Rect
	chr      string
	Element  string
}

// Chr returns the chromosome of the feature
func (f *Feature) Chr() string {
	return f.chr
}

// Start returns the start position of the feature
func (f *Feature) Start() float64 {
	return f.location.PointCoord(0)
}

// End returns the end position of the feature
func (f *Feature) End() float64 {
	return f.location.LengthsCoord(0) + f.Start()
}

// Bounds returns the location of the feature. It is used within the Rtree.
func (f *Feature) Bounds() *rtreego.Rect {
	return f.location
}

// Get returns the pointer to an Rtree for the specified chromosome and create a new Rtree if not present.
func (t RtreeMap) Get(chr string) *rtreego.Rtree {
	if _, ok := t[chr]; !ok {
		t[chr] = rtreego.NewTree(2, 25, 50)
	}
	return t[chr]
}

func getFileReader(f *os.File, fname string) *bufio.Scanner {
	var r io.Reader = f

	switch path.Ext(fname) {
	case ".gz":
{'fraction_non_alphanumeric': 0.11681348142474147, 'fraction_numerical': 0.009191880505553428, 'mean_word_length': 3.801470588235294, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1426054', 'n_tokens_mistral': 972, 'n_tokens_neox': 933, 'n_words': 307}