SkillAgentSearch skills...

Gotree

Gotree is a set of command line tools and an API to manipulate phylogenetic trees. It is implemented in Go language.

Install / Use

/learn @evolbioinfo/Gotree
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Gotree (See also Goalign)

build Bioconda Version Badge Docker hub downloads DOI:10.1093/nargab/lqab075

Gotree Logo

Gotree is a set of command line tools to manipulate phylogenetic trees. It is implemented in Go language.

Gotree handles phylogenetic trees in Newick, Nexus, PhyloXML and Nextstrain/Augur v2 formats, through several basic commands. Each command may print result (a tree for example) in the standard output, and thus can be piped to the standard input of the next gotree command.

Input files may be local or remote files:

  • If file name is of the form http://<URL>, the file is download from the given URL.
  • If file name is of the form itol://<ID>, the tree having the given ID is downloaded from iTOL using the iTOL api.
  • If file name is of the form treebase://<ID>, the tree having the given ID is downloaded from TreeBase.
  • Otherwise, the file is considered local.

Gzipped input files (.gz extension) are supported.

Note:

To manipulate multiple alignments, See also Goalign.

Examples:

$ echo "(1,(2,(3,4,5,6)polytomy)internal)root;" | gotree draw text --with-node-labels -w 50
+--------------- 1                                          
|                                                           
root            +---------------- 2                         
|               |                                           
+---------------|internal        +--------------- 3         
                |                |                          
                |                |--------------- 4         
                +----------------|polytomy                  
                                 |--------------- 5         
                                 |                          
                                 +--------------- 6         

$ echo "(1,(2,(3,4,5,6)polytomy)internal)root;" | gotree labels --internal --tips
root
1
internal
2
polytomy
3
4
5
6
$ gotree generate uniformtree -l 100 -n 10 | gotree stats

|tree  |  nodes  |  tips  |  edges  |  meanbrlen   |  sumbrlen     |  meansupport  |  mediansupport  |  rooted    |
|------|---------|--------|---------|--------------|---------------|---------------|-----------------|------------|
|0     |  198    |  100   |  197    |  0.09029828  |  17.78876078  |  NaN          |  NaN            |  unrooted  |
|1     |  198    |  100   |  197    |  0.08391711  |  16.53167037  |  NaN          |  NaN            |  unrooted  |
|2     |  198    |  100   |  197    |  0.08369861  |  16.48862662  |  NaN          |  NaN            |  unrooted  |
|3     |  198    |  100   |  197    |  0.08652623  |  17.04566698  |  NaN          |  NaN            |  unrooted  |
|4     |  198    |  100   |  197    |  0.07970206  |  15.70130625  |  NaN          |  NaN            |  unrooted  |
|5     |  198    |  100   |  197    |  0.09145831  |  18.01728772  |  NaN          |  NaN            |  unrooted  |
|6     |  198    |  100   |  197    |  0.08482117  |  16.70977068  |  NaN          |  NaN            |  unrooted  |
|7     |  198    |  100   |  197    |  0.08470308  |  16.68650662  |  NaN          |  NaN            |  unrooted  |
|8     |  198    |  100   |  197    |  0.08646811  |  17.03421732  |  NaN          |  NaN            |  unrooted  |
|9     |  198    |  100   |  197    |  0.07088132  |  13.96362091  |  NaN          |  NaN            |  unrooted  |

This will generate 10 random unrooted uniform binary trees, each having 100 tips, and print statistics about them.

Reference

If you use Gotree or Goalign, please cite:

Frédéric Lemoine, Olivier Gascuel

Gotree/Goalign: toolkit and Go API to facilitate the development of phylogenetic workflows,

NAR Genomics and Bioinformatics, Volume 3, Issue 3, September 2021, lqab075, doi

Installation

Easy way: Binaries

You can download ready to run binaries for the latest release in the release section. Binaries are available for MacOS, Linux, and Windows (32 and 64 bits).

Once downloaded, you can just run the executable without any other downloads.

Docker

Gotree Docker image is accessible from docker hub. You may use it as following:

# Display gotree help
docker run -v $PWD:$PWD -w $PWD -i -t evolbioinfo/gotree:v0.5.1 -h

Singularity

Gotree Docker image is usable from singularity . You may use it as following:

# Pull image from docker hub
singularity pull docker://evolbioinfo/gotree:v0.5.1
# Display gotree help
./gotree-v0.5.1.simg -h

Conda

Gotree is also available on bioconda. Just type:

conda install -c bioconda gotree

From sources

To build gotree, you must first download and install Go on your system ($1.24.11$).

Then you just have to type :

git clone git@github.com:evolbioinfo/gotree.git
cd gotree
make && make install
# or go get . && go build .
# or go get . && go install .

The gotree executable should be located in the current folder (or the $GOPATH/bin).

To test the executable:

./test.sh

Auto completion

gotree uses cobra, and therefore proposes a command to generate auto completion scripts:

gotree completion -h

Usage

gotree implements several tree manipulation commands.

You may go to the doc for a more detailed documentation of the commands.

List of commands

  • acr: Reconstruct most parsimonious ancestral characters
  • annotate: Annotate internal nodes of a tree with given data
  • asr: Reconstruct most parsimonious ancestral sequences
  • brlen: Modify branch lengths
    • add: Add the given length to all branches
    • clear: Clear lengths from input trees
    • cut: Cut branches whose length is greater than or equal to the given length
    • round: Round branch lengths from input trees with a given precision
    • scale: Scale lengths from input trees by a given factor
    • setmin: Set a min branch length to all branches with length < cutoff
    • setrand: Assign a random length to edges of input trees
    • set: Assign a given length to edges of input trees
  • collapse: Collapse branches or clades of input trees
    • clade: Collapse a clade and replace it with a tip
    • depth: Collapse branches having a given depth
    • length: Collapse short branches of the input tree
    • name: Collapse branches having given name or ID
    • single: Collapse branches that connect single nodes
    • support: Collapse lowly supported branches of the input tree
  • comment: Modify branch/node comments
    • clear: Remove node/tip comments
    • transfer: Transfer node names to comments
  • compare: Compare full trees, edges, or tips
    • edges: Individually compare edges of the reference tree to a compared tree
    • tips: Compare the set of tips of the reference tree to a compared tree
    • trees: Compare 2 trees in terms of common and specific branches
  • compute: Computations such as consensus and supports
    • bipartitiontree: Builds one tree with only one given bipartition
    • consensus: Compute the consensus from a set of input trees
    • edgetrees: Write one output tree per branch of the input tree, with only one branch
    • mutations: Extract the list of mutations along the branches of the phylogeny
    • support: Compute bootstrap supports
  • cut: Cut the tree
    • date: Cut the input tree by keeping only parts in a date window
  • divide: Divide an input tree file into several tree files
  • download: Download trees or images from servers
    • itol: Download a tree image from iTOL, with given image options
    • ncbitax: Download the full ncbi taxonomy in newick format
  • draw: Draw tree(s) with different layouts
    • text: Display tree(s) in ASCII text format
    • png: Draw tree(s) in png format, with normal, radial/unrooted or circular layout
    • svg: Draw tree(s) in svg format, with normal, radial/unrooted or circular layout
    • cyjs: Draw tree(s) in a html file, using cytoscape js
  • generate: Generate random trees, branch lengths are simply drawn from an exponential(1) law
    • balancedtree
    • caterpillartree
    • startree
    • topologies: all possible topologies
    • uniformtree
    • yuletree
  • graft: Graft a tree on an input tree in place of a given tip
  • labels: Lists labels (names) of all tips
  • ltt: Compute lineage through time data/plot
  • matrix: Print (patristic
View on GitHub
GitHub Stars144
CategoryDevelopment
Updated3d ago
Forks16

Languages

Go

Security Score

100/100

Audited on Apr 2, 2026

No findings