-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
100 lines (87 loc) · 1.64 KB
/
main.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
// Copyright (c) 2015, J. Salvador Arias <jsalarias@csnat.unt.edu.ar>
// All rights reserved.
// Distributed under BSD2 license that can be found in the LICENSE file.
package main
import (
"math/rand"
"os"
"runtime"
"time"
"github.com/js-arias/evs/biogeo"
"github.com/js-arias/evs/cmdapp"
"github.com/js-arias/evs/tree"
)
func init() {
rand.Seed(time.Now().Unix())
}
// general flags
var (
inFile string // -i/--input
outFile string // -o|--output
verbose bool // -v|--verbose
)
// raster flags
var (
numCols int // -c|--columns
numFill int // -f|--fill
)
func setRasterFlags(c *cmdapp.Command) {
c.Flag.IntVar(&numCols, "columns", 360, "")
c.Flag.IntVar(&numCols, "c", 360, "")
c.Flag.IntVar(&numFill, "fill", 2, "")
c.Flag.IntVar(&numFill, "f", 2, "")
}
func main() {
cmdapp.Short = "Evs is a tool for phylogenetic biogeography."
cmdapp.Commands = []*cmdapp.Command{
evEval,
evFlip,
evMap,
evTree,
rBay,
txLs,
trIn,
trLs,
// help topics,
about,
recordsHelp,
treesHelp,
}
runtime.GOMAXPROCS(runtime.NumCPU() * 2)
cmdapp.Run()
}
const (
treeFileName = "trees.tab"
dataFileName = "records.tab"
)
func loadData() (*biogeo.DataSet, error) {
f, err := os.Open(dataFileName)
if err != nil {
return nil, err
}
defer f.Close()
d, err := biogeo.Read(f)
if err != nil {
return nil, err
}
return d, nil
}
func loadTrees() ([]*tree.Tree, error) {
f, err := os.Open(treeFileName)
if err != nil {
return nil, err
}
defer f.Close()
ts, err := tree.Read(f)
if err != nil {
return nil, err
}
return ts, nil
}
func shuffle(v []int) {
for i, x := range v {
j := rand.Intn(len(v))
v[i] = v[j]
v[j] = x
}
}