-
Notifications
You must be signed in to change notification settings - Fork 16
/
multiplybrsupport.go
50 lines (43 loc) · 1.16 KB
/
multiplybrsupport.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
package cmd
import (
goio "io"
"os"
"github.com/evolbioinfo/gotree/io"
"github.com/evolbioinfo/gotree/tree"
"github.com/spf13/cobra"
)
var scalesupportfactor float64
// clearsupportCmd represents the support scale command
var scalesupportCmd = &cobra.Command{
Use: "scale",
Short: "Scale branch supports from input trees by a given factor",
Long: `Scale branch supports from input trees by a given factor.`,
RunE: func(cmd *cobra.Command, args []string) (err error) {
var f *os.File
var treefile goio.Closer
var treechan <-chan tree.Trees
if f, err = openWriteFile(outtreefile); err != nil {
io.LogError(err)
return
}
defer closeWriteFile(f, outtreefile)
if treefile, treechan, err = readTrees(intreefile); err != nil {
io.LogError(err)
return
}
defer treefile.Close()
for tr := range treechan {
if tr.Err != nil {
io.LogError(tr.Err)
return tr.Err
}
tr.Tree.ScaleSupports(scalesupportfactor)
f.WriteString(tr.Tree.Newick() + "\n")
}
return
},
}
func init() {
supportCmd.AddCommand(scalesupportCmd)
scalesupportCmd.Flags().Float64VarP(&scalesupportfactor, "factor", "f", 1.0, "Branch support scaling factor")
}