From cda92134c89bd5ac99aaca97de66839d1cffd00d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 12:33:05 +0000 Subject: [PATCH 1/3] Initial plan From c16fc05255ee267ced154bb482d62a272bed3c35 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 12:36:00 +0000 Subject: [PATCH 2/3] docs: add --diversity option to gotree prune documentation Co-authored-by: fredericlemoine <16349382+fredericlemoine@users.noreply.github.com> --- docs/commands/prune.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/commands/prune.md b/docs/commands/prune.md index 5c224b9..2aadfc5 100644 --- a/docs/commands/prune.md +++ b/docs/commands/prune.md @@ -6,7 +6,7 @@ This command removes (or retain with `-r`) a given set of tips from input trees. Several possibilities, in order of priorities : 1. Giving a tip file (`-f`): This file contains one tip name per line. In this case, it will remove (or retain with `-r`) only tips given in the file; 2. Giving a compared tree (`-c`): In this case, tips that are specific to the input tree are removed (or retained if `-r`) from the input tree; -3. Giving a number of random tips (`--random`), tips that are sampled are removed (or retained if `-r`) from the input tree or +3. Giving a number of random tips (`--random`), tips that are sampled are removed (or retained if `-r`) from the input tree. When combined with `--diversity`, the set of tips to keep is chosen to maximize diversity: iteratively, the closest pair of tips is found and one of the two is randomly removed, until the desired number of remaining tips is reached. `--random` specifies the number of tips to remove (or, with `-r`, the number of tips to keep); or 4. Giving tip names on the commandline: In this case, it will remove (or retain with `-r`) only the tips given on the command line. If 2 branches need to be merged after a tip removal, length of these branches are added, and the bootstrap support of the new branch is the maximum of the bootstrap supports of the two branches. @@ -19,6 +19,7 @@ Usage: Flags: -c, --comp string Input compared tree (default "none") + --diversity If the random pruning takes into account diversity (only with --random) -o, --output string Output tree (default "stdout") --random int Number of tips to randomly sample -i, --ref string Input reference tree (default "stdin") @@ -67,3 +68,15 @@ gotree draw svg -w 200 -H 200 -i pruned.nw -o commands/prune_7.svg Random Tree | Pruned Tree ------------------------------|------------------------------ ![Random Tree](prune_6.svg) | ![Pruned Tree](prune_7.svg) + +* Keeping 4 tips by maximizing diversity: +``` +gotree generate yuletree --seed 10 -l 20 -o outtree1.nw +gotree prune -i outtree1.nw --random 4 --diversity --seed 10 -r -o pruned.nw +gotree draw svg -w 200 -H 200 -i outtree1.nw -o commands/prune_8.svg +gotree draw svg -w 200 -H 200 -i pruned.nw -o commands/prune_9.svg +``` + +Random Tree | Pruned Tree (diversity) +------------------------------|------------------------------ +![Random Tree](prune_8.svg) | ![Pruned Tree](prune_9.svg) From f2ee59d52e976a9e49d84f272d29f68e79a41db0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 12:44:34 +0000 Subject: [PATCH 3/3] docs: generate prune_8.svg and prune_9.svg for diversity example Co-authored-by: fredericlemoine <16349382+fredericlemoine@users.noreply.github.com> --- docs/commands/prune_8.svg | 162 ++++++++++++++++++++++++++++++++++++++ docs/commands/prune_9.svg | 34 ++++++++ 2 files changed, 196 insertions(+) create mode 100644 docs/commands/prune_8.svg create mode 100644 docs/commands/prune_9.svg diff --git a/docs/commands/prune_8.svg b/docs/commands/prune_8.svg new file mode 100644 index 0000000..9e5d552 --- /dev/null +++ b/docs/commands/prune_8.svg @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Tip16 + + + + +Tip18 + + + + +Tip12 + + + + +Tip11 + + + + +Tip0 + + + + +Tip4 + + + + +Tip7 + + + + +Tip17 + + + + +Tip15 + + + + +Tip2 + + + + +Tip8 + + + + +Tip9 + + + + +Tip3 + + + + +Tip19 + + + + +Tip10 + + + + +Tip6 + + + + +Tip14 + + + + +Tip5 + + + + +Tip13 + + + + +Tip1 + + + diff --git a/docs/commands/prune_9.svg b/docs/commands/prune_9.svg new file mode 100644 index 0000000..1276621 --- /dev/null +++ b/docs/commands/prune_9.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + +Tip9 + + + + +Tip5 + + + + +Tip18 + + + + +Tip2 + + +