-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature(smithereens): Mass Builder for PGFinder 2.0 #285
Conversation
First forays into HTML/CSS/JavaScript/Typescript! Adding content to allow users to select and upload Fragments Library and Muropeptides Library. The smithereens WebAssembly will be added separately once the WebUI is in place.
Default reference masses and target structures along with the necessary Python components to load them or the user provided alternatives.
First forays into HTML/CSS/JavaScript/Typescript! Adding content to allow users to select and upload Fragments Library and Muropeptides Library. The smithereens WebAssembly will be added separately once the WebUI is in place.
+ Add reference masses to data dictionary + Add target structures to data dictionary + Attempting to document how to add features to the WebUI covering svelte/typescript/pgfinder (no smithereens yet)
Not quite there, don't get the tool tips showing correctly but progress!
Add radio buttons for selecting building bloc and muropeptides Also attempts to setup logic for running Smithereens once the Fragments and Muropeptides libraries have been selected, but not working (yet!).
Need to... + Split loading of mass library from fragments and muropeptides and make buttons reactive separately + Work out how to get the WASM imported correctly
Smithereens now takes the muropeptides list and calculates the masses. + All available species are duplicates (they just have different species/file names). + The building block components are not used, these come directly from smithereens I believe. + Defaults to `muropeptides_masses.csv` as output filename. + Lots of `console.log()` still in place. + Lints some files but doesn't address all errors. Also did some minor cleaning + Update ruff and eslint pre-commit hooks + Update pyproject.toml in light of ruff config changes + Lint test_internal.py + Adds basic eslint.config.mjs and removes options from .pre-commit-configy.yaml ToDo... There is no doubt more than the following to do but here is a summary, TODO denotes it needs addressing as this work, FUTURE for subsequent issues/tidying... + FUTURE As we are now loading the building blocks and muropeptide lists directly from the web-server/host it would perhaps make sense to do the same for the mass databases too as it is considerably faster than waiting for the Python packages to install and make these available (this should be something for a separate issue and be addressed in the future). + FUTURE Address the linting errors, currently a number of files are ignored via the `--no-warn-ignored` flag in `.pre-commit-config.yaml` but this should be removed and all errors addressed
I'm stuck on how to address the failures in the GUIs tests as my understanding of TypeScript is close to non-existant and the IDE isn't much help. Similarly the failing end-to-end tests fail as its suggesting the Any thoughts/insights/suggestions welcome. |
End-to-end tests fail as `/_app/immutable/workers/assets/smithereens_bg.wasm` can not be found so using `tree -fhD` to list the current directory structure to see where the files are. Locally they are in two locations (likely only one is being used!) ``` (pgfinder2024) ❱ fd smithereens_bg.wasm web/smithereens/pkg/smithereens_bg.wasm web/smithereens/pkg/smithereens_bg.wasm.d.ts web/src/lib/pkg/smithereens_bg.wasm web/src/lib/pkg/smithereens_bg.wasm.d.ts ```
5225143
to
1b470ef
Compare
I spent a little time looking at this and the I've been having a tinker to see if I can apply I'll try and find a little time to look at this over the coming weeks and am also mindful that we should probably add to the |
With the introduction of new elements in the WebUI the existing `web/tests/search_custom_database_test.ts` was failing as the wrong elements were selected (the new added ones rather than the existing ones). This has been corrected by adding `data-testid` fields to the Svelte pages <div> sections that define the specific areas to give them unique identifiers and updating the tests to use `page.getByTestID()` targets to align with these.
I've fixed the end-to-end tests which now pass by adding labels to each relevant section via The GUI tests fail for a few reasons (see full log here)...
I also have some Still to do would be to write tests that check smithereens runs correctly, but if you have any ideas or can suggest how to fix these please @TheLostLambda I would be very grateful. |
Attempting to exclude `web/src/pkg/smithereens*.js` from linting with `pnpm check` as it throws a lot of errors. The files themselves were auto-generated when building Smithereens with WebAssembly so not something we need to be concerned about.
Hi @ns-rse ! Sorry for the delay! I've been on holiday for the past week and remain a little crunched for time, but I'll help how I can now! I'll push a couple of commits and write anything else here! |
The last commit wasn't quite working for me, and it seems like that was because the `"exclude"` section was nested in `"compilerOptions"` when it's actually a top-level setting! This seems to work for me now
For @smesnage , the For @ns-rse , if you have a moment, it would be great if you could test that the installation / Rust building -> WebUI steps I added in the |
Had a go at working through the instructions. Building the PackageThis fails for native compilation on both the git submodule update --init --recursive
cd smithereens
cargo build
Updating crates.io index
Updating git repository `https://github.com/TheLostLambda/miette`
Updating git repository `https://github.com/TheLostLambda/knuffel.git`
Downloaded addr2line v0.22.0
Downloaded convert_case v0.6.0
Downloaded bitflags v2.6.0
Downloaded cfg_aliases v0.2.1
Downloaded autocfg v1.3.0
Downloaded heck v0.5.0
Downloaded thiserror-impl v1.0.63
Downloaded errno v0.3.9
Downloaded toml_datetime v0.6.6
Downloaded utf8parse v0.2.2
Downloaded unicode-xid v0.2.4
Downloaded thiserror v1.0.63
Downloaded either v1.13.0
Downloaded bytes v1.6.1
Downloaded borsh-derive v1.5.1
Downloaded getrandom v0.2.15
Downloaded quote v1.0.36
Downloaded itoa v1.0.11
Downloaded rustc-demangle v0.1.24
Downloaded serde_derive v1.0.204
Downloaded tinyvec v1.8.0
Downloaded uuid v1.10.0
Downloaded derive_more v1.0.0-beta.6
Downloaded indexmap v2.2.6
Downloaded derive_more-impl v1.0.0-beta.6
Downloaded backtrace v0.3.73
Downloaded allocator-api2 v0.2.18
Downloaded serde v1.0.204
Downloaded cc v1.1.6
Downloaded base64 v0.22.1
Downloaded borsh v1.5.1
Downloaded ryu v1.0.18
Downloaded proc-macro2 v1.0.86
Downloaded num-traits v0.2.19
Downloaded memchr v2.7.4
Downloaded miniz_oxide v0.7.4
Downloaded log v0.4.22
Downloaded hashbrown v0.14.5
Downloaded serde_json v1.0.120
Downloaded zerocopy v0.7.35
Downloaded itertools v0.13.0
Downloaded syn v2.0.72
Downloaded gimli v0.29.0
Downloaded object v0.36.1
Downloaded unicode-width v0.1.13
Downloaded libc v0.2.155
Downloaded linux-raw-sys v0.4.14
Downloaded 47 crates (6.1 MB) in 0.73s (largest was `linux-raw-sys` at 1.8 MB)
Compiling proc-macro2 v1.0.86
Compiling unicode-ident v1.0.12
Compiling version_check v0.9.4
Compiling libc v0.2.155
Compiling cfg-if v1.0.0
Compiling memchr v2.7.4
Compiling rustix v0.38.34
Compiling bitflags v2.6.0
Compiling cc v1.1.6
Compiling linux-raw-sys v0.4.14
Compiling gimli v0.29.0
Compiling adler v1.0.2
Compiling unicode-width v0.1.13
Compiling once_cell v1.19.0
Compiling thiserror v1.0.63
Compiling rustc-demangle v0.1.24
Compiling syn v1.0.109
Compiling miniz_oxide v0.7.4
Compiling zerocopy v0.7.35
Compiling autocfg v1.3.0
Compiling is_ci v1.2.0
Compiling smawk v0.3.2
Compiling unicode-linebreak v0.1.5
Compiling unicode-segmentation v1.11.0
Compiling ahash v0.8.11
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling supports-color v3.0.0
Compiling supports-hyperlinks v3.0.0
Compiling object v0.36.1
Compiling num-traits v0.2.19
Compiling textwrap v0.16.1
Compiling supports-unicode v3.0.0
Compiling serde v1.0.204
Compiling owo-colors v4.0.0
Compiling allocator-api2 v0.2.18
Compiling heck v0.5.0
Compiling convert_case v0.6.0
Compiling minimal-lexical v0.2.1
Compiling unicode-xid v0.2.4
Compiling quote v1.0.36
Compiling rust_decimal v1.35.0
Compiling arrayvec v0.7.4
Compiling nom v7.1.3
Compiling syn v2.0.72
Compiling base64 v0.22.1
Compiling cfg_aliases v0.1.1
Compiling either v1.13.0
Compiling nix v0.28.0
Compiling static_assertions v1.1.0
Compiling smallvec v1.13.2
Compiling itertools v0.13.0
Compiling nibble_vec v0.1.0
Compiling endian-type v0.1.2
Compiling log v0.4.22
Compiling home v0.5.9
Compiling radix_trie v0.2.1
Compiling utf8parse v0.2.2
Compiling getrandom v0.2.15
Compiling backtrace v0.3.73
Compiling hashbrown v0.14.5
Compiling addr2line v0.22.0
Compiling chumsky v0.9.3
Compiling terminal_size v0.3.0
Compiling fd-lock v4.0.2
Compiling rustyline v14.0.0
Compiling thiserror-impl v1.0.63
Compiling miette-derive v7.2.0 (https://github.com/TheLostLambda/miette#5b3eeba9)
Compiling serde_derive v1.0.204
Compiling derive_more-impl v1.0.0-beta.6
Compiling backtrace-ext v0.2.1
Compiling knuffel-derive v3.2.0 (https://github.com/TheLostLambda/knuffel.git#744bf56c)
Compiling miette v7.2.0 (https://github.com/TheLostLambda/miette#5b3eeba9)
Compiling nom-miette v0.1.0 (/home/neil/work/git/hub/Mesnage-Org/pgfinder/smithereens/crates/nom-miette)
Compiling knuffel v3.2.0 (https://github.com/TheLostLambda/knuffel.git#744bf56c)
Compiling derive_more v1.0.0-beta.6
Compiling polychem v0.1.0 (/home/neil/work/git/hub/Mesnage-Org/pgfinder/smithereens/crates/polychem)
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/atomic_database.rs:2:11
|
2 | use std::{num::NonZero, ops::Deref, str::FromStr};
| ^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/count.rs:3:5
|
3 | num::NonZero,
| ^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/mass_number.rs:1:5
|
1 | use std::num::NonZero;
| ^^^^^^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/lib.rs:10:5
|
10 | use std::num::NonZero;
| ^^^^^^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/atoms/errors.rs:74:56
|
74 | pub(crate) fn display_vec(items: impl IntoIterator<Item: Display>) -> String {
| ^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/errors.rs:220:44
|
220 | pub fn comma_list(items: impl IntoIterator<Item: Display>, final_sep: &str) -> String {
| ^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:146:37
|
146 | residues: impl IntoIterator<Item: AsRef<str>>,
| ^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:199:37
|
199 | residues: impl IntoIterator<Item: Borrow<ResidueId>>,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:346:35
|
346 | groups: impl IntoIterator<Item: Borrow<FunctionalGroup<'p>>> + Copy,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymerizer_state.rs:118:35
|
118 | groups: impl IntoIterator<Item: Borrow<FunctionalGroup<'p>>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
Some errors have detailed explanations: E0432, E0658.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `polychem` (lib) due to 10 previous errors Building the Package for Web AssemblyI found the following...
...didn't work as on a fresh clone of the sub-module there is no such crate (
Unfortunately that failed to build for me... ❱ wasm-pack build --out-name smithereens --target web
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling proc-macro2 v1.0.86
Compiling unicode-ident v1.0.12
Compiling wasm-bindgen-shared v0.2.92
Compiling version_check v0.9.4
Compiling log v0.4.22
Compiling once_cell v1.19.0
Compiling bumpalo v3.16.0
Compiling wasm-bindgen v0.2.92
Compiling cfg-if v1.0.0
Compiling zerocopy v0.7.35
Compiling thiserror v1.0.63
Compiling syn v1.0.109
Compiling autocfg v1.3.0
Compiling allocator-api2 v0.2.18
Compiling unicode-segmentation v1.11.0
Compiling unicode-width v0.1.13
Compiling serde v1.0.204
Compiling unicode-xid v0.2.4
Compiling minimal-lexical v0.2.1
Compiling memchr v2.7.4
Compiling rust_decimal v1.35.0
Compiling heck v0.5.0
Compiling base64 v0.22.1
Compiling either v1.13.0
Compiling ahash v0.8.11
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling arrayvec v0.7.4
Compiling convert_case v0.6.0
Compiling num-traits v0.2.19
Compiling static_assertions v1.1.0
Compiling itertools v0.13.0
Compiling nom v7.1.3
Compiling quote v1.0.36
Compiling syn v2.0.72
Compiling wasm-bindgen-backend v0.2.92
Compiling knuffel-derive v3.2.0 (https://github.com/TheLostLambda/knuffel.git#744bf56c)
Compiling thiserror-impl v1.0.63
Compiling miette-derive v7.2.0 (https://github.com/TheLostLambda/miette#5b3eeba9)
Compiling serde_derive v1.0.204
Compiling derive_more-impl v1.0.0-beta.6
Compiling wasm-bindgen-macro-support v0.2.92
Compiling wasm-bindgen-macro v0.2.92
Compiling miette v7.2.0 (https://github.com/TheLostLambda/miette#5b3eeba9)
Compiling js-sys v0.3.69
Compiling console_error_panic_hook v0.1.7
Compiling derive_more v1.0.0-beta.6
Compiling getrandom v0.2.15
Compiling hashbrown v0.14.5
Compiling nom-miette v0.1.0 (/home/neil/work/git/hub/Mesnage-Org/pgfinder/smithereens/crates/nom-miette)
Compiling chumsky v0.9.3
Compiling knuffel v3.2.0 (https://github.com/TheLostLambda/knuffel.git#744bf56c)
Compiling polychem v0.1.0 (/home/neil/work/git/hub/Mesnage-Org/pgfinder/smithereens/crates/polychem)
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/atomic_database.rs:2:11
|
2 | use std::{num::NonZero, ops::Deref, str::FromStr};
| ^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/count.rs:3:5
|
3 | num::NonZero,
| ^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/atoms/mass_number.rs:1:5
|
1 | use std::num::NonZero;
| ^^^^^^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0432]: unresolved import `std::num::NonZero`
--> crates/polychem/src/lib.rs:10:5
|
10 | use std::num::NonZero;
| ^^^^^^^^^^-------
| | |
| | help: a similar name exists in the module: `NonZeroI8`
| no `NonZero` in `num`
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/atoms/errors.rs:74:56
|
74 | pub(crate) fn display_vec(items: impl IntoIterator<Item: Display>) -> String {
| ^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/errors.rs:220:44
|
220 | pub fn comma_list(items: impl IntoIterator<Item: Display>, final_sep: &str) -> String {
| ^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:146:37
|
146 | residues: impl IntoIterator<Item: AsRef<str>>,
| ^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:199:37
|
199 | residues: impl IntoIterator<Item: Borrow<ResidueId>>,
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymer.rs:346:35
|
346 | groups: impl IntoIterator<Item: Borrow<FunctionalGroup<'p>>> + Copy,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
error[E0658]: associated type bounds are unstable
--> crates/polychem/src/polymers/polymerizer_state.rs:118:35
|
118 | groups: impl IntoIterator<Item: Borrow<FunctionalGroup<'p>>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
Some errors have detailed explanations: E0432, E0658.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `polychem` (lib) due to 10 previous errors
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
full command: cd "/home/neil/work/git/hub/Mesnage-Org/pgfinder/smithereens/crates/wasm-shim" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown" |
Hi @ns-rse ! The submodule should be initialised to the correct branch, but both of those issues look like a Rust version one! Can you try with the latest stable release? That's a new std library feature from the last release (or maybe one before) that I've used! |
Hmm, seems I have a Submodule definitely didn't initialise to the correct branch. |
Eek! I'll investigate... |
Testing a fresh clone, after initializing the submodule, I've ended up with: Once we merge this PR, then I think cloning with |
527ce15
to
b7d0872
Compare
Updated Updated documentation to reflect this minimum version. WebUI throws a hissy fit though...
I can see |
Nice! Yeah, it's a new dependency, so needing the install makes sense! Do you mean usage docs or developer docs for the Svelte stuff? |
The later, developer docs for Svelte. It would be useful to help people new to the framework to get up and running. |
@ns-rse Fixed that CI-failing-one-Windows issue: mesonbuild/meson-python#559 All of the other lints and checks should be passing now too! Missing things to do before merging:
And to convert to issues:
|
@ns-rse Might need your help in understanding some of how the documentation is generated here? I'm utterly baffled by these image links — where to get the URLs and how to upload new images: ![Initial screenshot of PGFinder GUI](https://github.com/Mesnage-Org/pgfinder/assets/70374280/9537c200-5b48-4d50-ac72-1c8b62d83909) |
Going to merge things just so that we can make sure the documentation and everything is set up, public, and working for publishing the paper! I hate to rush this bit through, but I think I've added issues for dealing with any loose-ends left behind! Some bigger issues (but bike-sheddy ones) that we need to think about involve the versioning and naming (and changelog tracking) for essentially three separate bits of software: the CLI PGfinder, the WebUI, and the new Smithereens stuff. |
Much head scratching, reading, learning, trying to document how things hang together and assistance from @TheLostLambda has led to a new component that uses static Rust copmiled to WebAassembly from Smithereens which takes a list of muropeptides and calculates the masses. The building blocks (currently only E. coli) are not actually used, as the masses of the components are internal to Smithereens.
muropeptides_masses.csv
as output filename.console.log()
still in place.Also did some minor cleaning
ToDo
There is no doubt more than the following to do but here are a few things that can be done in the future.
--no-warn-ignored
flag in.pre-commit-config.yaml
but this should be removed and all errors addressed