From d9c29479386da1a7dddd8a762c99714074326350 Mon Sep 17 00:00:00 2001 From: Frederic Lemoine Date: Thu, 8 Dec 2016 09:36:15 +0100 Subject: [PATCH] Modified shuffletips command to take several trees as input --- cmd/shuffletips.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cmd/shuffletips.go b/cmd/shuffletips.go index a24aece..4e7eaf8 100644 --- a/cmd/shuffletips.go +++ b/cmd/shuffletips.go @@ -37,12 +37,17 @@ gotree shuffletips -i t.nw rand.Seed(shuffletipsSeed) - var t *tree.Tree var err error - t, err = utils.ReadRefTree(shuffleTipsInputTree) - if err != nil { - io.ExitWithMessage(err) - } + var nbtrees int + + compareChannel := make(chan tree.Trees, 15) + + go func() { + if nbtrees, err = utils.ReadCompTrees(shuffleTipsInputTree, compareChannel); err != nil { + io.ExitWithMessage(err) + } + }() + var f *os.File if shuffleTipsOutputTree != "stdout" { f, err = os.Create(shuffleTipsOutputTree) @@ -53,13 +58,11 @@ gotree shuffletips -i t.nw io.ExitWithMessage(err) } - t.ShuffleTips() + for t2 := range compareChannel { - if err != nil { - io.ExitWithMessage(err) + t2.Tree.ShuffleTips() + f.WriteString(t2.Tree.Newick() + "\n") } - - f.WriteString(t.Newick() + "\n") f.Close() }, }