-
Notifications
You must be signed in to change notification settings - Fork 2
/
cfg.go
112 lines (94 loc) · 3.04 KB
/
cfg.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
package main
import (
"log"
"path/filepath"
"strings"
"github.com/go-redis/redis"
"github.com/liserjrqlxue/goUtil/fmtUtil"
"github.com/liserjrqlxue/goUtil/jsonUtil"
"github.com/liserjrqlxue/goUtil/osUtil"
"github.com/liserjrqlxue/goUtil/simpleUtil"
"github.com/liserjrqlxue/goUtil/textUtil"
"github.com/pelletier/go-toml"
"github.com/liserjrqlxue/anno2xlsx/v2/anno"
)
func parseCfg() {
// parser etc/config.json
defaultConfig = jsonUtil.JsonFile2Interface(*config).(map[string]interface{})
initAcmg2015()
if *specVarList == "" {
*specVarList = anno.GetPath("specVarList", dbPath, defaultConfig)
}
if *transInfo == "" {
*transInfo = anno.GetPath("transInfo", dbPath, defaultConfig)
}
if *wgs {
for _, key := range defaultConfig["qualityColumnWGS"].([]interface{}) {
qualityColumn = append(qualityColumn, key.(string))
}
} else {
for _, key := range defaultConfig["qualityColumn"].([]interface{}) {
qualityColumn = append(qualityColumn, key.(string))
}
}
initIM()
if *wgs {
MTTitle = textUtil.File2Array(filepath.Join(etcPath, "MT.title.txt"))
qualityKeyMap = simpleUtil.HandleError(
textUtil.File2Map(filepath.Join(etcPath, "wgs.qc.txt"), "\t", false),
).(map[string]string)
} else {
qualityKeyMap = simpleUtil.HandleError(
textUtil.File2Map(filepath.Join(etcPath, "coverage.report.txt"), "\t", false),
).(map[string]string)
}
}
func parseToml() {
TomlTree = simpleUtil.HandleError(toml.LoadFile(*cfg)).(*toml.Tree)
acmgDb = filepath.Join(etcPath, TomlTree.Get("acmg.list").(string))
openRedis()
var tier3 = TomlTree.Get("tier3")
if tier3 != nil {
outputTier3 = tier3.(bool)
}
var homRatio = TomlTree.Get("homFixRatioThreshold")
if homRatio != nil {
homFixRatioThreshold = homRatio.(float64)
}
}
func openRedis() {
if *ifRedis {
if *redisAddr == "" {
*redisAddr = TomlTree.Get("redis.addr").(string)
}
redisDb = redis.NewClient(
&redis.Options{
Addr: *redisAddr,
Password: TomlTree.Get("redis.pass").(string),
},
)
log.Printf("Connect [%s]:%s\n", redisDb.String(), simpleUtil.HandleError(redisDb.Ping().Result()).(string))
}
}
func initIM() {
if *wesim {
acmg59GeneList := textUtil.File2Array(anno.GuessPath(TomlTree.Get("acmg.59gene").(string), etcPath))
for _, gene := range acmg59GeneList {
acmg59Gene[gene] = true
}
resultColumn = TomlTree.GetArray("wesim.resultColumn").([]string)
if *trio {
resultColumn = append(resultColumn, "Genotype of Family Member 1", "Genotype of Family Member 2")
}
resultFile = osUtil.Create(*prefix + ".result.tsv")
fmtUtil.Fprintln(resultFile, strings.Join(resultColumn, "\t"))
qcColumn = TomlTree.GetArray("wesim.qcColumn").([]string)
qcFile = osUtil.Create(*prefix + ".qc.tsv")
fmtUtil.Fprintln(qcFile, strings.Join(qcColumn, "\t"))
cnvColumn = TomlTree.GetArray("wesim.cnvColumn").([]string)
exonFile = osUtil.Create(*prefix + ".exonCNV.tsv")
fmtUtil.Fprintln(exonFile, strings.Join(cnvColumn, "\t"))
largeFile = osUtil.Create(*prefix + ".largeCNV.tsv")
fmtUtil.Fprintln(largeFile, strings.Join(cnvColumn, "\t"))
}
}