/
spliceAI.go
127 lines (121 loc) · 2.62 KB
/
spliceAI.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package anno
import (
"errors"
"fmt"
"math"
"strconv"
"strings"
"github.com/liserjrqlxue/goUtil/simpleUtil"
)
type spliceAI struct {
spliceAI, pred, interpretation, allele, symbol string
dsAG, dsAL, dsDG, dsDL, dsMax float64
dpAG, dpAL, dpDG, dpDL int
}
//Parse parse spliceAI
func (ai *spliceAI) Parse() (err error) {
if ai.spliceAI == "" {
return errors.New("nil spliceAI")
}
var a = strings.Split(ai.spliceAI, "|")
ai.allele = a[0]
ai.symbol = a[1]
ai.dsAG, err = strconv.ParseFloat(a[2], 64)
if err != nil {
return
}
ai.dsAL, err = strconv.ParseFloat(a[3], 64)
if err != nil {
return
}
ai.dsDG, err = strconv.ParseFloat(a[4], 64)
if err != nil {
return
}
ai.dsDL, err = strconv.ParseFloat(a[5], 64)
if err != nil {
return
}
ai.dpAG, err = strconv.Atoi(a[6])
if err != nil {
return
}
ai.dpAL, err = strconv.Atoi(a[7])
if err != nil {
return
}
ai.dpDG, err = strconv.Atoi(a[8])
if err != nil {
return
}
ai.dpDL, err = strconv.Atoi(a[9])
if err != nil {
return
}
for _, s := range []float64{ai.dsAG, ai.dsAL, ai.dsDG, ai.dsDL} {
ai.dsMax = math.Max(ai.dsMax, s)
}
if ai.dsMax >= 0.2 {
ai.pred = "D"
} else {
ai.pred = "P"
}
return
}
//Interpreatation calculate value of spliceAI.interpretation
func (ai *spliceAI) Interpreatation(chromosome string, position int) (err error) {
var interpreation []string
if ai.dsAG >= 0.1 {
interpreation = append(
interpreation,
fmt.Sprintf(
"%s:%d (=%d%d) acceptor gain %f",
chromosome, position+ai.dpAG, position, ai.dpAG, ai.dsAG,
),
)
}
if ai.dsAL >= 0.1 {
interpreation = append(
interpreation,
fmt.Sprintf(
"%s:%d (=%d%d) acceptor loss %f",
chromosome, position+ai.dpAL, position, ai.dpAL, ai.dsAL,
),
)
}
if ai.dsDG >= 0.1 {
interpreation = append(
interpreation,
fmt.Sprintf(
"%s:%d (=%d%d) donor gain %f",
chromosome, position+ai.dpDG, position, ai.dpDG, ai.dsDG,
),
)
}
if ai.dsDL >= 0.1 {
interpreation = append(
interpreation,
fmt.Sprintf(
"%s:%d (=%d%d) donor loss %f",
chromosome, position+ai.dpDL, position, ai.dpDL, ai.dsDL,
),
)
}
ai.interpretation = strings.Join(interpreation, ";\n")
return
}
// ParseSpliceAI parse and anno spliceAI result
func ParseSpliceAI(item map[string]string) {
var ai = spliceAI{
spliceAI: item["SpliceAI"],
}
if ai.Parse() != nil {
return
}
var position, err = strconv.Atoi(item["Start"])
simpleUtil.CheckErr(err)
position++
simpleUtil.CheckErr(ai.Interpreatation(item["#Chr"], position))
item["SpliceAI Pred"] = ai.pred
item["SpliceAI Interpretation"] = ai.interpretation
}