veg / hyphy

HyPhy: Hypothesis testing using Phylogenies
http://www.hyphy.org
Other
209 stars 69 forks source link

Working with trees in HBL #572

Closed halabikeren closed 7 years ago

halabikeren commented 7 years ago

Hi,

Is there a way to work with trees (add node, get node, ect.) in HBL?

Thanks! Keren

spond commented 7 years ago

Dear @halabikeren,

Yes, there are many accessor functions, and some modification functions. Take a look at

  1. Get information about nodes and paths in the tree

  2. You can access addition information on tree nodes via http://hyphy.org/w/index.php/GetInformation

  3. In order to modify a tree object you can use + / - operations, like in the example below

Topology T = ((a:0.1,b:0.2)ab:0.05, (c:0.01,d:0.02)cd:0.03, ef:0.07);

fprintf (stdout, Format (T,1,1), "\n");

T + {"NAME": "e", "WHERE" : "ef", "LENGTH" : 0.125};
T + {"NAME": "f", "WHERE" : "ef", "LENGTH" : 0.15};

fprintf (stdout, Format (T,1,1), "\n");

T - "c";

fprintf (stdout, Format (T,1,1), "\n");

There are other ways to access and manipulate trees, let me know if you have a specific use case in mind.

Best, Sergei

halabikeren commented 7 years ago

Great, Thank you!