基本完成
This commit is contained in:
parent
20c23128ee
commit
c449b57a80
3 changed files with 39 additions and 19 deletions
|
@ -6,5 +6,5 @@ sequence combination tool written in Golang
|
||||||
```
|
```
|
||||||
parser xxx.fas
|
parser xxx.fas
|
||||||
parser xxx.fas yyy.fas
|
parser xxx.fas yyy.fas
|
||||||
parser -o 123 xxx.fas // todo
|
parser -o export.nex xxx.fas yyy.fas
|
||||||
```
|
```
|
||||||
|
|
42
parser.go
42
parser.go
|
@ -36,13 +36,13 @@ func main() {
|
||||||
file_names := flag.Args() // []string{"foo", "bar"}
|
file_names := flag.Args() // []string{"foo", "bar"}
|
||||||
fmt.Println("[ export here ]", *file_export)
|
fmt.Println("[ export here ]", *file_export)
|
||||||
|
|
||||||
// 遍历文件
|
// 遍历文件得到基本数据
|
||||||
sum_nex := make([]dna, 0, 5)
|
sum_nex := make([]dna, 0, 5)
|
||||||
for k, v := range file_names {
|
for k, v := range file_names {
|
||||||
i, j := fas_parser.Fas_parser(v)
|
i, j := fas_parser.Fas_parser(v)
|
||||||
new_nex := dna{v, i, j}
|
new_nex := dna{v, i, j}
|
||||||
sum_nex = append(sum_nex, new_nex)
|
sum_nex = append(sum_nex, new_nex)
|
||||||
fmt.Println("[ working ]", k+1, v)
|
fmt.Println("[ working A ]", k+1, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整合若干文件的统计
|
// 整合若干文件的统计
|
||||||
|
@ -54,29 +54,45 @@ func main() {
|
||||||
f = sum_charset[k-1].To
|
f = sum_charset[k-1].To
|
||||||
}
|
}
|
||||||
t := f + v.count
|
t := f + v.count
|
||||||
|
fmt.Println("[ working B ]", n, f, t)
|
||||||
new_charset := charset{n, f, t}
|
new_charset := charset{n, f, t}
|
||||||
sum_charset = append(sum_charset, new_charset)
|
sum_charset = append(sum_charset, new_charset)
|
||||||
}
|
}
|
||||||
fmt.Println(sum_charset)
|
// fmt.Println(sum_charset)
|
||||||
|
|
||||||
// dna 的整合
|
// dna 的整合
|
||||||
seq := sum_nex[0].min_dna
|
ntax := 0
|
||||||
ntax := 0 // 待修补
|
|
||||||
nchar := sum_charset[len(sum_charset)-1].To
|
nchar := sum_charset[len(sum_charset)-1].To
|
||||||
|
sum_dna := make(map[string][]string)
|
||||||
for k, v := range sum_nex {
|
for k, v := range sum_nex {
|
||||||
if k == 0 {
|
for k1 := range v.min_dna {
|
||||||
continue
|
_, has := sum_dna[k1]
|
||||||
|
if !has {
|
||||||
|
sum_dna[k1] = make([]string, len(sum_charset))
|
||||||
}
|
}
|
||||||
last_count := sum_nex[k-1].count
|
}
|
||||||
for k1, v1 := range v.min_dna {
|
ntax = k
|
||||||
if _, ok := seq[k1]; ok {
|
}
|
||||||
seq[k1] = seq[k1] + v1
|
for k, v := range sum_nex {
|
||||||
|
for _, v1 := range v.min_dna {
|
||||||
|
for k2 := range sum_dna {
|
||||||
|
if _, ok := v.min_dna[k2]; ok {
|
||||||
|
sum_dna[k2][k] = v1
|
||||||
} else {
|
} else {
|
||||||
seq[k1] = seq[k1] + strings.Repeat("?", last_count)
|
sum_dna[k2][k] = strings.Repeat("?", v.count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_data := tmpl_data{ntax, nchar, seq, sum_charset}
|
}
|
||||||
|
// fmt.Println(sum_dna)
|
||||||
|
|
||||||
|
matrix := make(map[string]string, ntax)
|
||||||
|
for k := range sum_dna {
|
||||||
|
matrix[k] = strings.Join(sum_dna[k], "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 准备发射到模板的数据
|
||||||
|
last_data := tmpl_data{ntax, nchar, matrix, sum_charset}
|
||||||
// fmt.Println(last_data)
|
// fmt.Println(last_data)
|
||||||
|
|
||||||
// 读取模板
|
// 读取模板
|
||||||
|
|
|
@ -4,13 +4,17 @@ const Nex_tmpl = `#NEXUS
|
||||||
BEGIN DATA;
|
BEGIN DATA;
|
||||||
DIMENSIONS NTAX={{ .Ntax }} NCHAR={{ .Nchar }};
|
DIMENSIONS NTAX={{ .Ntax }} NCHAR={{ .Nchar }};
|
||||||
FORMAT DATATYPE=DNA GAP=- MISSING=? ; #DATATYPE={}
|
FORMAT DATATYPE=DNA GAP=- MISSING=? ; #DATATYPE={}
|
||||||
MATRIX{{ range $k, $v := .Matrix }}
|
MATRIX
|
||||||
|
{{- range $k, $v := .Matrix }}
|
||||||
'{{ $k }}' {{ $v }}{{ end }}
|
'{{ $k }}' {{ $v }}{{ end }}
|
||||||
;
|
;
|
||||||
END;
|
END;
|
||||||
BEGIN SETS;{{ range $_, $i := .Charset }}
|
BEGIN SETS;
|
||||||
CHARSET {{ .Name }} = {{ .From }}-{{ .To }};{{ end }}
|
{{- range $_, $i := .Charset }}
|
||||||
|
CHARSET {{ $i.Name }} = {{ $i.From }}-{{ $i.To }};
|
||||||
|
{{- end }}
|
||||||
END;
|
END;
|
||||||
`
|
`
|
||||||
|
|
||||||
// 最后那个 $i 好像有问题
|
// 最后那个 $i 好像有问题
|
||||||
|
// {{/* $k| printf "%-40s" */}}
|
Loading…
Reference in a new issue