Debian Codegraph @

utils.go

raw symbols SCIP
1 package irelate
2
3 import (
4 "errors"
5 "fmt"
6 "strconv"
7 "strings"
8
9 "github.com/brentp/bix"
10 "github.com/brentp/irelate/interfaces"
11 )
12
13 const MaxUint32 = ^uint32(0)
14 const MaxInt32 = int(MaxUint32 >> 1)
15
16 func RegionToParts(region string) (string, int, int, error) {
17 parts := strings.Split(region, ":")
18 // e.g. just "chr"
19 if len(parts) == 1 {
20 parts = append(parts, fmt.Sprintf("1-%d", MaxInt32))
21 }
22
23 se := strings.Split(parts[1], "-")
24 if len(se) != 2 {
25 return "", 0, 0, errors.New(fmt.Sprintf("unable to parse region: %s", region))
26 }
27 s, err := strconv.Atoi(se[0])
28 if err != nil {
29 return "", 0, 0, errors.New(fmt.Sprintf("unable to parse region: %s", region))
30 }
31 e, err := strconv.Atoi(se[1])
32 if err != nil {
33 return "", 0, 0, errors.New(fmt.Sprintf("unable to parse region: %s", region))
34 }
35 return parts[0], s, e, nil
36 }
37
38 func AsQueryable(f string) (interfaces.Queryable, error) {
39 return bix.New(f, 1)
40 }