From 9216c7b59efcaea45f9fc84f04810298e8930312 Mon Sep 17 00:00:00 2001 From: Frederic Lemoine Date: Mon, 13 Nov 2023 11:39:58 +0100 Subject: [PATCH] Updated gotree collapse name doc --- cmd/collapsebrname.go | 3 ++ docs/commands/collapse.md | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/cmd/collapsebrname.go b/cmd/collapsebrname.go index d963cff..f3fb8ee 100644 --- a/cmd/collapsebrname.go +++ b/cmd/collapsebrname.go @@ -22,6 +22,9 @@ var collapsebrnameCmd = &cobra.Command{ Names (or ID) are defined in an input file (-b) If an external branch name/id is given, then does not do anything. + + Branch identifiers are defined by preorder traversal of the tree, sorted as described in the input newick file. + If the tree or its newick representation is modified, identifiers will be different. `, RunE: func(cmd *cobra.Command, args []string) (err error) { var f *os.File diff --git a/docs/commands/collapse.md b/docs/commands/collapse.md index 2325a77..8d55d0e 100644 --- a/docs/commands/collapse.md +++ b/docs/commands/collapse.md @@ -6,6 +6,7 @@ This command removes branches from a set of input trees. They apply only to internal branches, and not to branches connected to the root (for rooted trees). Three subcommands : * `gotree collapse clade` will remove a clade from the tree. The clade is defined by all the descendants of the least common ancestor of the set of given tips. The command outputs the tree with the collapsed clade (`-o`) replaced by a tip whose name is given on the command line, and the tree consisting of the collapsed clade only (`-c`); * `gotree collapse length` will remove branches whose length is less than or equal to the specified length; +* `gotree collapse name` will remove branches having given name or ID; * `gotree collapse support` will remove branches whose support is less than the specified support; * `gotree collapse depth` will remove branches whose depth is between (or equal to) given min and max depths. Here, depth is defined as the number of taxa on the lightest side of the branch. * `gotree collapse single` will remove internal nodes and branches that form linear internal paths. For example: @@ -70,6 +71,21 @@ Global Flags: -o, --output string Collapsed tree output file (default "stdout") ``` +name sub-command +``` +Usage: + gotree collapse name [flags] + +Flags: + -b, --brfile string File with one branch name/id per line (default "none") + --id Input file contains branch ids (otherwise, branch names) + +Global Flags: + --format string Input tree format (newick, nexus, phyloxml, or nextstrain) (default "newick") + -i, --input string Input tree (default "stdin") + -o, --output string Collapsed tree output file (default "stdout") +``` + support sub-command ``` Usage: @@ -207,3 +223,46 @@ $ gotree collapse clade -i tree.nw -n new -c clade.nw l4 l6 $ cat clade.nw (l4:0.1,((l5:0.2,l7:0.3):0.3,l6:0.3):0.1); ``` + +5. Collapsing branches given their ids + +``` +$ echo "((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));" | gotree stats edges +``` + + +|tree|brid|length|support|terminal|depth|topodepth|rootdepth|rightname|comments|leftname|rightcomment|leftcomment| +|----|----|------|-------|--------|-----|---------|---------|---------|--------|--------|------------|-----------| +|0|0|N/A|N/A|false|1|3|-1||[]||[]|[]| +|0|1|N/A|N/A|true|0|1|-1|Tip4|[]||[]|[]| +|0|2|N/A|N/A|true|0|1|-1|Tip7|[]||[]|[]| +|0|3|N/A|N/A|true|0|1|-1|Tip2|[]||[]|[]| +|0|4|N/A|N/A|true|0|1|-1|Tip0|[]||[]|[]| +|0|5|N/A|N/A|false|1|4|-1||[]||[]|[]| +|0|6|N/A|N/A|false|1|3|-1||[]||[]|[]| +|0|7|N/A|N/A|true|0|1|-1|Tip8|[]||[]|[]| +|0|8|N/A|N/A|true|0|1|-1|Tip9|[]||[]|[]| +|0|9|N/A|N/A|true|0|1|-1|Tip3|[]||[]|[]| +|0|10|N/A|N/A|false|1|3|-1||[]||[]|[]| +|0|11|N/A|N/A|true|0|1|-1|Tip1|[]||[]|[]| +|0|12|N/A|N/A|true|0|1|-1|Tip6|[]||[]|[]| +|0|13|N/A|N/A|true|0|1|-1|Tip5|[]||[]|[]| + + +``` +$ echo "((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));" | ./gotree collapse name --id -b <(echo -e "0\n5\n6" ) |gotree stats edges +``` + +|tree|brid|length|support|terminal|depth|topodepth|rootdepth|rightname|comments|leftname|rightcomment|leftcomment| +|----|----|------|-------|--------|-----|---------|---------|---------|--------|--------|------------|-----------| +|0|0|N/A|N/A|true|0|1|-1|Tip0|[]||[]|[]| +|0|1|N/A|N/A|true|0|1|-1|Tip4|[]||[]|[]| +|0|2|N/A|N/A|true|0|1|-1|Tip7|[]||[]|[]| +|0|3|N/A|N/A|true|0|1|-1|Tip2|[]||[]|[]| +|0|4|N/A|N/A|false|1|3|-1||[]||[]|[]| +|0|5|N/A|N/A|true|0|1|-1|Tip1|[]||[]|[]| +|0|6|N/A|N/A|true|0|1|-1|Tip6|[]||[]|[]| +|0|7|N/A|N/A|true|0|1|-1|Tip5|[]||[]|[]| +|0|8|N/A|N/A|true|0|1|-1|Tip8|[]||[]|[]| +|0|9|N/A|N/A|true|0|1|-1|Tip9|[]||[]|[]| +|0|10|N/A|N/A|true|0|1|-1|Tip3|[]||[]|[]|