Skip to content

Commit

Permalink
rename can now take a file containing several trees as input
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed Jan 13, 2017
1 parent 3a7b5ce commit 0f2cf3d
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions cmd/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ gotree rename -m MapFile -i t.nw
}

// Read Tree
var tree *tree.Tree
tree, err = utils.ReadRefTree(renameintree)
if err != nil {
io.ExitWithMessage(err)
}
intreesChan := make(chan tree.Trees, 15)
/* Read ref tree(s) */
go func() {
if _, err = utils.ReadCompTrees(renameintree, intreesChan); err != nil {
io.ExitWithMessage(err)
}
}()

var f *os.File
if renameouttree != "stdout" {
f, err = os.Create(renameouttree)
Expand All @@ -118,12 +121,15 @@ gotree rename -m MapFile -i t.nw
io.ExitWithMessage(err)
}

err = tree.Rename(namemap)
if err != nil {
io.ExitWithMessage(err)
}
// Read ref Trees and rename them
for reftree := range intreesChan {
err = reftree.Tree.Rename(namemap)
if err != nil {
io.ExitWithMessage(err)
}

f.WriteString(tree.Newick() + "\n")
f.WriteString(reftree.Tree.Newick() + "\n")
}
f.Close()
},
}
Expand Down

0 comments on commit 0f2cf3d

Please sign in to comment.