diff --git a/.gitignore b/.gitignore index 38a7bcb..a799775 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ a.nex -test.go \ No newline at end of file +test.go +SeqCombGo \ No newline at end of file diff --git a/README.md b/README.md index 4c103a7..3c3c6e7 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,7 @@ SeqCombGo -o export.nex import1.fas import2.fas url = {https://github.com/MalacoLab/SeqCombGo}, } ``` + +# Detail + +tobedo \ No newline at end of file diff --git a/count.go b/count.go index 978f40d..fd84e32 100644 --- a/count.go +++ b/count.go @@ -47,5 +47,6 @@ func fas_name(old_name string) string { matchArr := compileRegex.FindStringSubmatch(old_name) //needed to use the string get from the old string new_name := matchArr[len(matchArr)-1] + // 这里有 bug return new_name } diff --git a/flag.go b/flag.go index adc5b9d..a9eaa53 100644 --- a/flag.go +++ b/flag.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "os" ) var ( @@ -10,11 +11,44 @@ var ( file_input []string ) +// http://www.network-science.de/ascii/ +// is there any better way to print logo? plz contact us +func print_logo() { + fmt.Print("__ ___ _ ___ \n" + + "/ _\\ ___ __ _ / __\\___ _ __ ___ | |__ / _ \\___ \n" + + "\\ \\ / _ \\/ _` |/ / / _ \\| '_ ` _ \\| '_ \\ / /_\\/ _ \\ \n" + + "_\\ \\ __/ (_| / /__| (_) | | | | | | |_) / /_\\ (_) |\n" + + "\\__/\\___|\\__, \\____/\\___/|_| |_| |_|_.__/\\____/\\___/ \n" + + " |_| \n") + fmt.Println(" Sequence Combination tool written in Golang") + fmt.Println("Version 0.0.1 Authors:An,G;Zhang,G License:GPL-3.0") +} + +// __ ___ _ ___ +// / _\ ___ __ _ / __\___ _ __ ___ | |__ / _ \___ +// \ \ / _ \/ _` |/ / / _ \| '_ ` _ \| '_ \ / /_\/ _ \ +// _\ \ __/ (_| / /__| (_) | | | | | | |_) / /_\\ (_) | +// \__/\___|\__, \____/\___/|_| |_| |_|_.__/\____/\___/ +// |_| + func dna_flag() { flag.StringVar(&file_output, "o", "a.nex", "output file") + flag.Usage = usage flag.Parse() file_input = flag.Args() // []string{"foo", "bar"} - fmt.Println("==============") + // 这里应该加个判断,如果输入不符合,后面的正则会报错 + print_logo() + fmt.Println() fmt.Println("[input file:]", file_input) fmt.Println("[output file:]", file_output) } + +func usage() { + print_logo() + fmt.Fprintf(os.Stderr, ` +Example: + SeqCombGo -o export.nex import1.fas import2.fas ... +Options: +`) + flag.PrintDefaults() +} diff --git a/nex.tmpl b/nex.tmpl deleted file mode 100644 index 807700c..0000000 --- a/nex.tmpl +++ /dev/null @@ -1,15 +0,0 @@ -#NEXUS -BEGIN DATA; - DIMENSIONS NTAX={{ .Ntax }} NCHAR={{ .Nchar }}; - FORMAT DATATYPE=DNA GAP=- MISSING=?; -MATRIX -{{- range $k, $v := .Matrix }} -'{{ $k }}' {{ $v }} -{{- end }} -; -END; -BEGIN SETS; -{{- range $_, $i := .Charset }} - CHARSET {{ $i.Name }} = {{ $i.From }}-{{ $i.To }}; -{{- end }} -END; \ No newline at end of file diff --git a/gocomb.go b/seqcomb.go similarity index 100% rename from gocomb.go rename to seqcomb.go diff --git a/tmpl.go b/template.go similarity index 61% rename from tmpl.go rename to template.go index 9f1185e..c1ca517 100644 --- a/tmpl.go +++ b/template.go @@ -2,22 +2,30 @@ package main import ( "fmt" - "io/ioutil" "os" "text/template" ) +const f string = `#NEXUS +BEGIN DATA; + DIMENSIONS NTAX={{ .Ntax }} NCHAR={{ .Nchar }}; + FORMAT DATATYPE=DNA GAP=- MISSING=?; +MATRIX +{{- range $k, $v := .Matrix }} +'{{ $k }}' {{ $v }} +{{- end }} +; +END; +BEGIN SETS; +{{- range $_, $i := .Charset }} + CHARSET {{ $i.Name }} = {{ $i.From }}-{{ $i.To }}; +{{- end }} +END;` + func do_impl(last_data tmpl_data) { - - f, err := ioutil.ReadFile("nex.tmpl") - if err != nil { - fmt.Println(err) - return - } - // 读取模板 - // read the template - nex_tmpl, err := template.New("nex").Parse(string(f)) + // read the template + nex_tmpl, err := template.New("nex").Parse(f) if err != nil { fmt.Println("[ tmpl err ]", err) return