51 lines
1 KiB
Go
51 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
type charset struct {
|
|
Name string
|
|
From int
|
|
To int
|
|
}
|
|
|
|
// 遍历文件得到基本数据
|
|
// get basic data
|
|
func fas_sum() []dna {
|
|
sum := []dna{}
|
|
for i, f := range file_input {
|
|
sum = append(sum, fas_parser(f)) // sum files
|
|
fmt.Println("[ Reading ]", i+1, f)
|
|
}
|
|
return sum
|
|
}
|
|
|
|
// 整合若干文件的统计
|
|
// combine the data from different files
|
|
func fas_count(sum_nex []dna) []charset {
|
|
fas_charset := []charset{}
|
|
for k, v := range sum_nex {
|
|
n := fas_name(v.name)
|
|
f := 1
|
|
if k != 0 {
|
|
f = fas_charset[k-1].To + 1
|
|
}
|
|
t := f + v.count - 1
|
|
fmt.Println("[ Combining ]", n, f, t)
|
|
new_charset := charset{n, f, t}
|
|
fas_charset = append(fas_charset, new_charset)
|
|
}
|
|
fmt.Println(fas_charset)
|
|
return fas_charset
|
|
}
|
|
|
|
func fas_name(old_name string) string {
|
|
//needed to import string
|
|
compileRegex := regexp.MustCompile(`(\w+)\.\w+`)
|
|
matchArr := compileRegex.FindStringSubmatch(old_name)
|
|
//needed to use the string get from the old string
|
|
new_name := matchArr[len(matchArr)-1]
|
|
return new_name
|
|
}
|