extracting JSON and the Newick format

385 views
Skip to first unread message

kaustubh.patil

unread,
Sep 10, 2009, 10:30:14 AM9/10/09
to JavaScript Information Visualization Toolkit
Hi,

Thanks a lot for the toolkit. I am new to the JIT and have two
questions;

1. Extracting JSON

Lets say I load some JSON data into the toolkit and visualize it.
Afterwards the tree is modified by adding/deleting nodes. Is it
possible to get the modified JSON structure?

2. Newick file format

Does anyone have a Newick<->JSON parser?

cheers,
kaustubh

Nico Garcia Belmonte

unread,
Sep 11, 2009, 1:44:49 PM9/11/09
to javascript-information...@googlegroups.com
Hi,

1. Extracting JSON

There isn't any built-in method for doing this but it's doable and not so difficult to achieve. I can help you with that part when needed.
Actually the main idea is to traverse the resulting graph structure (either sequentially or like with a BFS traversal algo) and recreate the JSON structure.

For more information about how to traverse the graph you can read the Graph.Util object documentation:

http://thejit.org/docs/files/Graph-js.html#Graph.Util

the eachNode and eachBFS methods might be of help.


2. Newick file format

Does anyone have a Newick<->JSON parser?

I don't know any Newick to JSON parser, sorry.
What type Newick format do you want to convert? (from the wikipedia):

http://en.wikipedia.org/wiki/Newick_format

(,,(,));                               no nodes are named
(A,B,(C,D)); leaf nodes are named
(A,B,(C,D)E)F; all nodes are named
(:0.1,:0.2,(:0.3,:0.4):0.5); all but root node have a distance to parent
(:0.1,:0.2,(:0.3,:0.4):0.5):0.0; all have a distance to parent
(A:0.1,B:0.2,(C:0.3,D:0.4):0.5); distances and leaf names (popular)
(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F; distances and all names
((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A; a tree rooted on a leaf node (rare)


kaustubh.patil

unread,
Sep 11, 2009, 2:55:04 PM9/11/09
to JavaScript Information Visualization Toolkit
Hi Nico,

Thanks for reply. For the JSON structure I will have a look at the
methods you suggested. My design pipe-line is something like this,

get newick from user -> allow user to modify the tree -> convert the
tree back to newick

Thats why I need JSON<-> Newick parser.

My newick trees have all nodes named. Currently there is no distance
to the parent but will be quite useful in the future. I have a Newick
parser (string<->Newick) in C but as I have minimal experience with
Java and the JIT its quite a task for me. But I think having both
these functionalities built inside the JIT will be very useful; i.e.
directly inputing some popular tree formats and retrieving the tree
structure back in these formats.

Best,
Kaustubh
Reply all
Reply to author
Forward
0 new messages