marbl / MetagenomeScope

Visualization tool for (meta)genome assembly graphs
https://marbl.github.io/MetagenomeScope/
GNU General Public License v3.0
24 stars 8 forks source link

Make the app available as a desktop application #5

Closed fedarko closed 3 years ago

fedarko commented 7 years ago

From @fedarko on July 22, 2016 18:7

Using cy.json(), node.js, and node-sqlite3 would allow assembly graphs to be viewed in Cytoscape.js or (with less support for certain Cytoscape.js-specific features -- see this) the desktop version of Cytoscape.

The upside of this is that we get the best of both worlds: the ability to view the graph in a browser (and, theoretically, host it on a website) and the ability to view the graph in desktop Cytoscape (which would make viewing huge graphs faster).

Note that I have pretty much no experience with desktop Cytoscape, and we'll probably have to tweak things to get this to work. (I think compound nodes, in particular, are only somewhat supported in desktop Cytoscape -- so I'll have to look into that.)

Copied from original issue: fedarko/MetagenomeScope#12

fedarko commented 7 years ago

See https://github.com/cytoscape/cytoscape.js/issues/1018 -- this might actually be pretty well-supported, from the looks of it

fedarko commented 7 years ago

OK, here's the (a?) plan:

This should work well! By running everything headlessly we avoid browser overhead, and by using node-sqlite3 we avoid the limitations of sql.js.

Alternatively we could export from the python script directly to desktop Cytoscape (by preparing JSON output [we could even add our own data fields that we could parse via a Cytoscape plugin], or by using the existing dot-app for Cytoscape to load .gv or .dot files).

fedarko commented 7 years ago

I was previously running into an error in which cy.json() generated circular JSON which couldn't be string-ified (i.e., couldn't be exported to desktop Cytoscape). I think I identified the source of this error: just reported it at https://github.com/cytoscape/cytoscape.js/issues/1667, so hopefully that will be resolved.

UPDATE: Nope I'm dumb see commit message below

fedarko commented 7 years ago

Ok, so here's an idea. Things like Electron (https://electron.atom.io) can facilitate the creation of desktop apps from HTML/JS/etc code, right? And there's a tutorial available demonstrating that Cytoscape.js works ok with Electron.

So it should be feasible to use electron to create a desktop version of the viewer interface, but using node.js et al for certain things (e.g. node-sqlite3 in lieu of sql.js). I'm a bit fuzzy on the details here, but I'll do some more research on this soon. This could result in a fairly performant application, if done right.

fedarko commented 7 years ago

Alternatively, we could have collate.py just generate a .json file that could be loaded in desktop cytoscape. Look into that also.

fedarko commented 6 years ago

After commit https://github.com/marbl/MetagenomeScope/commit/5b890bac44ad8561fbf69440c89195738e3b05f3, it should be feasible to modify certain spots in the JS code to function differently for the viewer interface's Electron application when performing operations where Node.js has native bindings (e.g. using node-sqlite3 instead of sql.js).

fedarko commented 6 years ago

Additional way we could do things differently: accept actual assembly graph files (GFA, GML, etc) in the viewer, and invoke the graph_collator script if those are passed? This would let users avoid the command-line stuff entirely.

fedarko commented 6 years ago

Could also leverage the desktop app status of this to enhance features like FASTA exporting/copying-to-clipboard/etc that are normally difficult or at least very limited in client-side apps. See Electron's clipboard API for more info

fedarko commented 6 years ago

apparently the Electron app supports using XML HTTP Requests to get demo files. Consider hooking it up to mgsc.umiacs.io's demo files? Or not, I guess, since the app isn't really "associated" with a hosted version of mgsc per se.

fedarko commented 6 years ago

For the FASTA stuff: add a button that lets the user upload (or even just specify the location of) a FASTA file. Also, add a FASTA option to the finishing output file type radio buttons that is enabled when the user links to a FASTA file for an assembly graph. If the user selects the FASTA export type for finishing, the JS creates the file (based on the contents of the FASTA file) and lets the user save it to their system as before. (Alternatively, the writing operation could be done automatically, if there isn't a good way to hold on to the file while the user selects a location. I gotta read up on the node.js file APIs.)

fedarko commented 6 years ago

Look into using something like electron-builder to expedite the building process.

For the time being, users can build and then run the electron app by cd'ing into the electron/directory of the repository and running npm install and then npm start. But it'd be ideal to make this process easier, esp. for users who might not want to mess around with command-line stuff.

fedarko commented 3 years ago

Closing because I am probably not going to have time for this for a while, and I don't think this is high-priority