theosanderson / taxonium

A tool for exploring very large trees in the browser
http://taxonium.org
GNU General Public License v3.0
97 stars 17 forks source link

Load from Newick string? #530

Closed niemasd closed 10 months ago

niemasd commented 10 months ago

I've been using Taxonium for all of my tree visualization needs (great work!), and I was wondering if it would be feasible to have some way to load a tree from a Newick string (e.g. textbox input and/or some other mechanism). My use case is that I have a student building a web app that, as part of it, runs FastTree (in the browser) to infer a phylogeny:

https://niema-lab.github.io/ViralWasm-Epi

And I was hoping to have some clean way of creating a simple "Visualize in Taxonium" button where I send the Newick tree data to Taxonium to have it autoload (similar to what you currently support for other things via URL arguments). The tool runs client-side in the web browser, so there isn't a globally public URL that can be sent to Taxonium (at least that I'm aware of, since it's a file in a client-side virtual filesystem)

So I guess this is more of a two-part question/request:

  1. A way for Taxonium to load data from a Newick string (which is broadly useful, e.g. if I want to copy-paste a Newick string and play with it)
  2. A way for 3rd party tools to query Taxonium in some way to send it tree data (not a URL) to visualize
corneliusroemer commented 10 months ago

I think in theory you could use the Window: postMessage() API to communicate across browser windows that don't share a domain.

theosanderson commented 10 months ago

Thanks for this:

  1. I agree this would be nice, I find that useful on other sites. Just need to fit it into the UI nicely. Will try to get to that.
  2. This definitely sounds interesting and worth exploring. I guess I could just accept the data as a POST payload, hadn't really thought about that. Cornelius's suggestion is also interesting.

But.. for your use case maybe the best thing would be the Taxonium React Component There's a lot of cleanup I could do to that, I don't think it really needs any of the dependencies it asks for, so if they're what are holding you back let me know.

niemasd commented 10 months ago

Awesome, thank you! I'll share the Taxonium React Component with my student!

theosanderson commented 10 months ago

Great - I think they would be one the first users so tell them to be vocal about raising any issues they encounter if they decide to try it out.

niemasd commented 10 months ago

Will do!

niemasd commented 10 months ago

Wow, that was fast! Thank you!!