markmipt / biosaur2

Apache License 2.0
10 stars 4 forks source link

Support running in Pyodide #9

Closed TheLostLambda closed 1 year ago

TheLostLambda commented 1 year ago

Hi @markmipt ! Thank you for your email! I think biosaur is exactly the solution I was looking for at the moment!

I've been playing around with it but have run into a bit of a niche problem for my use-case — it doesn't seem to run on Pyodide / WebAssembly! I'm looking to integrate biosaur now with another python tool of ours (PGFinder) in a single web interface, but it looks like some of the C code in biosaur2 is causing a problem.

Not being pure python means that you need to go through a special build process to get things working on Pyodide, but unfortunately it also looks like the C code relies on OpenMP which doesn't currently play nice with WebAssembly.

I've not dug too deep just yet, but is this OpenMP or the C code something that could be pulled out of one version of biosaur2 or maybe put behind some sort of feature flag? Being either pure python or python + C that plays nice with Emscripten would make this the perfect tool for my use case (and would mean people have a nice web interface that doesn't require any python installation to use your fantastic MS1 feature-finder!)

Let me know how deeply the dependency on OpenMP runs and if things can be made to work without it! Happy to help with implementing any changes if you point me in the right direction!

Thanks a ton for pointing me towards this excellent tool, Brooks

markmipt commented 1 year ago

Hi Brooks,

Thanks for your interest! Actually, I do not use OpenMP anymore and just forgot to remove unnecessary imports. Could you please try an updated version (v 0.2.14) and tell me it if fixes your issue? I have some troubles with building PyPi wheel files right now, but you can install it directly from the GitHub.

Regards, Mark

TheLostLambda commented 1 year ago

Thanks for the outstandingly quick reply! That looks like it solves it!

I can try to figure out how to upload things to Pyodide's packaging system too and maybe submit a PR adding that as a CI action to this repo? Building and testing it locally looks good though!

In addition to just getting it running, I might need to refactor some tiny bits and pieces of the code so that it's easier to integrate as a library (things like letting process_file work on data bytes directly instead of loading from the filesystem), but removing OpenMP makes it WebAssembly compatible!

Thanks again for such a quick fix!

P.S. If you have more time than me, I think Pyodide has their packaging instructions here: https://pyodide.org/en/stable/development/new-packages.html