From 024bb103399d29690e004b1fbd12ea17cb5f1cfd Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Mon, 11 Nov 2024 13:37:43 +0100 Subject: [PATCH] refactor: versions infos consistent with mehari --- .github/dependabot.yml | 4 + .github/workflows/rust.yml | 35 ++ Cargo.lock | 504 ++---------------- Cargo.toml | 6 +- build.rs | 3 - openapi.schema.yaml | 176 ++++++ protos/annonars/common/versions.proto | 37 -- src/common/cli.rs | 4 +- src/genes/cli/data.rs | 5 +- src/genes/cli/import.rs | 2 +- src/gnomad_nuclear/cli/import.rs | 2 +- src/pbs/common.rs | 10 - src/pbs/mod.rs | 1 - src/server/run/error.rs | 8 +- src/server/run/mod.rs | 42 +- ..._yaml@alphamissense-grch37-1+0.33.0-2.snap | 4 +- ..._yaml@alphamissense-grch38-1+0.33.0-2.snap | 4 +- ...nctional-grch37-105.20201022+0.33.0-2.snap | 4 +- ...c_yaml@functional-grch38-110+0.33.0-2.snap | 4 +- ...0+4.5+20230606+10.1+20240105+0.33.0-2.snap | 4 +- ...yaml@gnomad-mtdna-grch37-3.1+0.33.0-2.snap | 4 +- ...yaml@gnomad-mtdna-grch38-3.1+0.33.0-2.snap | 4 +- ...ml@helixmtdb-grch37-20200327+0.33.0-2.snap | 4 +- ...ml@helixmtdb-grch38-20200327+0.33.0-2.snap | 4 +- src/server/run/versions.rs | 104 ++-- 25 files changed, 379 insertions(+), 600 deletions(-) create mode 100644 openapi.schema.yaml delete mode 100644 protos/annonars/common/versions.proto delete mode 100644 src/pbs/common.rs diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fa603d52..baff46b3 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -24,6 +24,10 @@ updates: - "hgvs" - "seqrepo" - "noodles-*" + utoipa: + patterns: + - "utoipa" + - "utoipa-*" prost: patterns: - "pbjson" diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 83d38553..3ce4b5e2 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -105,3 +105,38 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} files: lcov.info + + Schema: + needs: Formatting + runs-on: ubuntu-24.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y librocksdb-dev libsnappy-dev libsqlite3-dev + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Setup protoc + uses: arduino/setup-protoc@v3.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Write schema + run: cargo run -- server schema --output-file /tmp/openapi.schema.yaml-gen + + - name: Copy repo schema and strip versions + run: | + cp openapi.schema.yaml /tmp/openapi.schema.yaml-repo + perl -p -i -e 's/^ version: .*/ version: 0.0.0/' /tmp/*.yaml-* + + - name: Compare YAML in git to the one just generated + run: diff /tmp/openapi.schema.yaml-repo /tmp/openapi.schema.yaml-gen diff --git a/Cargo.lock b/Cargo.lock index 13d269d6..7ad517ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,7 +40,7 @@ dependencies = [ "flate2", "futures-core", "h2", - "http 0.2.12", + "http", "httparse", "httpdate", "itoa", @@ -76,7 +76,7 @@ checksum = "13d324164c51f63867b57e73ba5936ea151b8a41a1d23d1031eeb9f70d0236f8" dependencies = [ "bytestring", "cfg-if", - "http 0.2.12", + "http", "regex", "regex-lite", "serde", @@ -976,9 +976,9 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", @@ -1273,7 +1273,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 0.2.12", + "http", "indexmap", "slab", "tokio", @@ -1316,40 +1316,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http 1.1.0", -] - -[[package]] -name = "http-body-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" -dependencies = [ - "bytes", - "futures-util", - "http 1.1.0", - "http-body", - "pin-project-lite", -] - [[package]] name = "httparse" version = "1.9.3" @@ -1368,63 +1334,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper", - "hyper-util", - "rustls", - "rustls-pki-types", - "tokio", - "tokio-rustls", - "tower-service", - "webpki-roots", -] - -[[package]] -name = "hyper-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.1.0", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower", - "tower-service", - "tracing", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1637,12 +1546,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - [[package]] name = "is_terminal_polyfill" version = "1.70.0" @@ -1812,6 +1715,12 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lockfree-object-pool" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" + [[package]] name = "log" version = "0.4.22" @@ -2129,27 +2038,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_enum" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "number_prefix" version = "0.4.0" @@ -2268,26 +2156,6 @@ dependencies = [ "indexmap", ] -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "pin-project-lite" version = "0.2.14" @@ -2353,30 +2221,6 @@ dependencies = [ "toml_edit", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.86" @@ -2439,53 +2283,6 @@ dependencies = [ "prost", ] -[[package]] -name = "quinn" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash 1.1.0", - "rustls", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" -dependencies = [ - "bytes", - "rand", - "ring", - "rustc-hash 1.1.0", - "rustls", - "slab", - "thiserror", - "tinyvec", - "tracing", -] - -[[package]] -name = "quinn-udp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" -dependencies = [ - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.52.0", -] - [[package]] name = "quote" version = "1.0.37" @@ -2626,64 +2423,6 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" -[[package]] -name = "reqwest" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http 1.1.0", - "http-body", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls", - "rustls-pemfile", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "tokio", - "tokio-rustls", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "winreg", -] - -[[package]] -name = "ring" -version = "0.17.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" -dependencies = [ - "cc", - "cfg-if", - "getrandom", - "libc", - "spin", - "untrusted", - "windows-sys 0.52.0", -] - [[package]] name = "rocksdb" version = "0.22.0" @@ -2818,47 +2557,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "rustls" -version = "0.23.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" -dependencies = [ - "once_cell", - "ring", - "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", -] - -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64 0.22.1", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" - -[[package]] -name = "rustls-webpki" -version = "0.102.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.17" @@ -3053,6 +2751,12 @@ dependencies = [ "wide", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "similar" version = "2.5.0" @@ -3084,12 +2788,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3150,12 +2848,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "1.0.109" @@ -3178,12 +2870,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" - [[package]] name = "synstructure" version = "0.13.1" @@ -3306,21 +2992,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "tinyvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.38.0" @@ -3338,17 +3009,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" -dependencies = [ - "rustls", - "rustls-pki-types", - "tokio", -] - [[package]] name = "tokio-util" version = "0.7.11" @@ -3379,33 +3039,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - [[package]] name = "tracing" version = "0.1.40" @@ -3495,12 +3128,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22048bc95dfb2ffd05b1ff9a756290a009224b60b2f0e7525faeee7603851e63" -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typeid" version = "1.0.0" @@ -3540,12 +3167,6 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - [[package]] name = "url" version = "2.5.1" @@ -3577,9 +3198,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utoipa" -version = "4.2.3" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5afb1a60e207dca502682537fefcfd9921e71d0b83e9576060f09abc6efab23" +checksum = "514a48569e4e21c86d0b84b5612b5e73c0b2cf09db63260134ba426d4e8ea714" dependencies = [ "indexmap", "serde", @@ -3590,11 +3211,10 @@ dependencies = [ [[package]] name = "utoipa-gen" -version = "4.3.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bf0e16c02bc4bf5322ab65f10ab1149bdbcaa782cba66dc7057370a3f8190be" +checksum = "5629efe65599d0ccd5d493688cbf6e03aa7c1da07fe59ff97cf5977ed0637f66" dependencies = [ - "proc-macro-error", "proc-macro2", "quote", "regex", @@ -3603,14 +3223,13 @@ dependencies = [ [[package]] name = "utoipa-swagger-ui" -version = "7.1.0" +version = "8.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943e0ff606c6d57d410fd5663a4d7c074ab2c5f14ab903b9514565e59fa1189e" +checksum = "a5c80b4dd79ea382e8374d67dcce22b5c6663fa13a82ad3886441d1bbede5e35" dependencies = [ "actix-web", "mime_guess", "regex", - "reqwest", "rust-embed", "serde", "serde_json", @@ -3656,15 +3275,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3696,18 +3306,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.92" @@ -3737,25 +3335,6 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" -[[package]] -name = "web-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki-roots" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "wide" version = "0.7.24" @@ -3954,16 +3533,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "write16" version = "1.0.0" @@ -4047,12 +3616,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zeroize" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" - [[package]] name = "zerovec" version = "0.10.2" @@ -4077,9 +3640,9 @@ dependencies = [ [[package]] name = "zip" -version = "1.1.4" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cc23c04387f4da0374be4533ad1208cbb091d5c11d070dfef13676ad6497164" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ "arbitrary", "crc32fast", @@ -4087,8 +3650,23 @@ dependencies = [ "displaydoc", "flate2", "indexmap", - "num_enum", + "memchr", "thiserror", + "zopfli", +] + +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9bf4b761..e2a5f232 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "annonars" version = "0.41.3" edition = "2021" authors = ["Manuel Holtgrewe "] -description = "Rust template repository" +description = "Genome annotation based on Rust and RocksDB" license = "Apache-2.0" repository = "https://github.com/varfish-org/annonars" readme = "README.md" @@ -53,8 +53,8 @@ strum = { version = "0.26", features = ["strum_macros", "derive"] } thiserror = "1.0" tracing = "0.1" tracing-subscriber = "0.3" -utoipa-swagger-ui = { version = "7.1.0", features = ["actix-web"] } -utoipa = { version = "4.2", features = ["actix_extras", "chrono", "indexmap", "preserve_order", "yaml"] } +utoipa-swagger-ui = { version = "8.0", features = ["actix-web"] } +utoipa = { version = "5.2", features = ["actix_extras", "chrono", "indexmap", "preserve_order", "yaml"] } [dependencies.noodles] version = "0.77.0" diff --git a/build.rs b/build.rs index af2345bd..20dc8a16 100644 --- a/build.rs +++ b/build.rs @@ -14,7 +14,6 @@ fn main() -> Result<(), anyhow::Error> { "annonars/clinvar/minimal.proto", "annonars/clinvar/per_gene.proto", "annonars/clinvar/sv.proto", - "annonars/common/versions.proto", "annonars/cons/base.proto", "annonars/dbsnp/base.proto", "annonars/functional/refseq.proto", @@ -51,8 +50,6 @@ fn main() -> Result<(), anyhow::Error> { // Override prost-types with pbjson-types .compile_well_known_types() .extern_path(".google.protobuf", "::pbjson_types") - // Derive the types for utoipa. - .message_attribute(".", "#[derive(utoipa::ToSchema)]") // Define the protobuf files to compile. .compile_protos(&proto_files, &[root])?; diff --git a/openapi.schema.yaml b/openapi.schema.yaml new file mode 100644 index 00000000..9cebe5d1 --- /dev/null +++ b/openapi.schema.yaml @@ -0,0 +1,176 @@ +openapi: 3.1.0 +info: + title: annonars + description: Genome annotation based on Rust and RocksDB + contact: + name: Manuel Holtgrewe + email: manuel.holtgrewe@bih-charite.de + license: + name: Apache-2.0 + version: 0.41.3 +paths: + /api/v1/versionsInfo: + get: + tags: + - versions + summary: Query for annotations for one variant. + operationId: versionsInfo + parameters: [] + responses: + '200': + description: Version information. + content: + application/json: + schema: + $ref: '#/components/schemas/VersionsInfoResponse' + '500': + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/CustomError' +components: + schemas: + AnnoDb: + type: string + description: Encode annotation database. + enum: + - other + - cadd + - dbsnp + - dbnsfp + - dbscsnv + - gnomad_mtdna + - gnomad_exomes + - gnomad_genomes + - helixmtdb + - ucsc_conservation + - clinvar + CustomError: + type: object + description: Custom error type for the Actix server. + required: + - err + properties: + err: + type: string + GenomeRelease: + type: string + description: Local genome release for command line arguments. + enum: + - grch37 + - grch38 + VersionsAnnotationInfo: + type: object + description: Version information for one database. + required: + - database + properties: + database: + $ref: '#/components/schemas/AnnoDb' + description: Database name. + version_spec: + oneOf: + - type: 'null' + - $ref: '#/components/schemas/VersionsVersionSpec' + description: Version information of the database. + VersionsCreatedFrom: + type: object + description: Source name and version. + required: + - name + - version + properties: + name: + type: string + description: The name of the data source. + version: + type: string + description: The version of the data source. + VersionsInfoQuery: + type: object + description: Query parameters for `handle()`. + VersionsInfoResponse: + type: object + description: Response for `handle()`. + properties: + genes: + oneOf: + - type: 'null' + - $ref: '#/components/schemas/VersionsVersionSpec' + description: Version information of the genes. + seqvars: + type: array + items: + $ref: '#/components/schemas/VersionsPerRelease' + description: Version information of annotation databases per release. + VersionsPerRelease: + type: object + description: Version information for databases in a given release. + required: + - release + properties: + release: + $ref: '#/components/schemas/GenomeRelease' + description: The genome release. + version_infos: + type: array + items: + $ref: '#/components/schemas/VersionsAnnotationInfo' + description: Version information of annotation databases. + VersionsVersionSpec: + type: object + description: Version specification. + required: + - identifier + - title + - creator + - contributor + - format + - date + - version + - description + - source + - created_from + properties: + identifier: + type: string + description: Identifier of the data. + title: + type: string + description: Title of the data. + creator: + type: string + description: Creator of the data. + contributor: + type: array + items: + type: string + description: Contributors of the data. + format: + type: string + description: Format of the data. + date: + type: string + description: Date of the data. + version: + type: string + description: Version of the data. + genome_release: + type: + - string + - 'null' + description: Optional genome release. + description: + type: string + description: Data description. + source: + type: array + items: + type: string + description: Data source. + created_from: + type: array + items: + $ref: '#/components/schemas/VersionsCreatedFrom' + description: Created from information. diff --git a/protos/annonars/common/versions.proto b/protos/annonars/common/versions.proto deleted file mode 100644 index 0060bcb3..00000000 --- a/protos/annonars/common/versions.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package annonars.common.versions; - -// Source that data was created from. -message CreatedFrom { - // The name of the data source. - string name = 1; - // The version of the data source. - string version = 2; -} - -// Version specification. -message VersionSpec { - // Identifier of the data. - string identifier = 1; - // Title of the data. - string title = 2; - // Creator of the data. - string creator = 3; - // Contributors of the data. - repeated string contributor = 4; - // Format of the data. - string format = 5; - // Date of the data. - string date = 6; - // Version of the data. - string version = 7; - // Optional genome release. - optional string genome_release = 8; - // Data description. - string description = 9; - // Data source. - repeated string source = 10; - // Created from information. - repeated CreatedFrom created_from = 11; -} diff --git a/src/common/cli.rs b/src/common/cli.rs index 738b90fb..8cbcf713 100644 --- a/src/common/cli.rs +++ b/src/common/cli.rs @@ -34,16 +34,16 @@ pub enum OutputFormat { strum::EnumString, enum_map::Enum, serde::Serialize, + serde::Deserialize, utoipa::ToSchema, )] #[strum(serialize_all = "lowercase")] +#[serde(rename_all = "lowercase")] pub enum GenomeRelease { /// GRCh37 genome release. - #[strum(serialize = "grch37")] #[default] Grch37, /// GRCh38 genome release. - #[strum(serialize = "grch38")] Grch38, } diff --git a/src/genes/cli/data.rs b/src/genes/cli/data.rs index 5d38df07..8d085375 100644 --- a/src/genes/cli/data.rs +++ b/src/genes/cli/data.rs @@ -2796,9 +2796,8 @@ mod tests { .lines() .map(|s| { serde_json::from_str::(s) - .map_err(|e| { - println!("{}", &s); - e + .inspect_err(|e| { + println!("{} -- {:?}", &s, e); }) .unwrap() }) diff --git a/src/genes/cli/import.rs b/src/genes/cli/import.rs index c59c32e1..0d90e033 100644 --- a/src/genes/cli/import.rs +++ b/src/genes/cli/import.rs @@ -1156,7 +1156,7 @@ fn write_rocksdb( conditions: conditions_by_hgnc_id.get(&hgnc_id).cloned(), }); tracing::debug!("writing {:?} -> {:?}", &hgnc, &record); - db.put_cf(&cf_genes, hgnc_id, &record.encode_to_vec())?; + db.put_cf(&cf_genes, hgnc_id, record.encode_to_vec())?; } // Finally, compact manually. diff --git a/src/gnomad_nuclear/cli/import.rs b/src/gnomad_nuclear/cli/import.rs index 9ec980b4..c4385a08 100644 --- a/src/gnomad_nuclear/cli/import.rs +++ b/src/gnomad_nuclear/cli/import.rs @@ -418,7 +418,7 @@ pub fn run(common: &common::cli::Args, args: &Args) -> Result<(), anyhow::Error> for (header_field, val) in more_header_values { db.put_cf( &cf_meta, - &format!("gnomad-{}", header_field.replace('_', "-")), + format!("gnomad-{}", header_field.replace('_', "-")), &val, )?; } diff --git a/src/pbs/common.rs b/src/pbs/common.rs deleted file mode 100644 index 09ebb5fb..00000000 --- a/src/pbs/common.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! Code generate for protobufs by `prost-build`. - -/// Information about versions. -pub mod versions { - include!(concat!(env!("OUT_DIR"), "/annonars.common.versions.rs")); - include!(concat!( - env!("OUT_DIR"), - "/annonars.common.versions.serde.rs" - )); -} diff --git a/src/pbs/mod.rs b/src/pbs/mod.rs index 2ff4b6e8..6d5177cd 100644 --- a/src/pbs/mod.rs +++ b/src/pbs/mod.rs @@ -2,7 +2,6 @@ pub mod clinvar; pub mod clinvar_data; -pub mod common; pub mod cons; pub mod dbsnp; pub mod functional; diff --git a/src/server/run/error.rs b/src/server/run/error.rs index 7ffd3c9c..f329d027 100644 --- a/src/server/run/error.rs +++ b/src/server/run/error.rs @@ -3,9 +3,9 @@ use actix_web::ResponseError; /// Custom error type for the Actix server. -#[derive(Debug)] +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] pub struct CustomError { - err: anyhow::Error, + err: String, } impl std::fmt::Display for CustomError { @@ -17,7 +17,9 @@ impl std::fmt::Display for CustomError { impl CustomError { /// Create from `anyhow::Error`. pub fn new(err: anyhow::Error) -> Self { - CustomError { err } + CustomError { + err: err.to_string(), + } } } diff --git a/src/server/run/mod.rs b/src/server/run/mod.rs index 959dff50..72f41186 100644 --- a/src/server/run/mod.rs +++ b/src/server/run/mod.rs @@ -28,7 +28,7 @@ use utoipa::OpenApi as _; use crate::{ clinvar_sv::cli::query::{self as clinvarsv_query, IntervalTrees as ClinvarsvIntervalTrees}, common::{self, cli::GenomeRelease}, - pbs::{self, genes}, + pbs::genes, }; use actix_web::{middleware::Logger, web::Data, App, HttpServer}; @@ -37,27 +37,27 @@ use actix_web::{middleware::Logger, web::Data, App, HttpServer}; pub mod openapi { use crate::{ common::cli::GenomeRelease, - pbs::common::versions::{CreatedFrom, VersionSpec}, - server::run::{ - versions::{AnnoVersionInfo, ReleaseVersionInfos}, - AnnoDb, + server::run::versions::{ + self, VersionsAnnotationInfo, VersionsCreatedFrom, VersionsInfoQuery, + VersionsInfoResponse, VersionsPerRelease, VersionsVersionSpec, }, + server::run::{error::CustomError, AnnoDb}, }; - use super::versions::{self, VersionInfoResponse}; - /// Utoipa-based `OpenAPI` generation helper. #[derive(utoipa::OpenApi)] #[openapi( paths(versions::handle), components(schemas( - AnnoVersionInfo, - ReleaseVersionInfos, - VersionInfoResponse, - CreatedFrom, - VersionSpec, + VersionsInfoQuery, + VersionsInfoResponse, + VersionsVersionSpec, + VersionsPerRelease, + VersionsAnnotationInfo, + VersionsCreatedFrom, GenomeRelease, AnnoDb, + CustomError, )) )] pub struct ApiDoc; @@ -264,7 +264,7 @@ pub struct WithVersionSpec { /// The actual data. pub data: T, /// Version specification. - pub version_spec: Option, + pub version_spec: Option, } impl WithVersionSpec @@ -276,11 +276,10 @@ where where P: AsRef, { - let version_spec: Option = path + let version_spec: Option = path .as_ref() .map(versions::schema::VersionSpec::from_path) - .transpose()? - .map(|version_spec| version_spec.into()); + .transpose()?; Ok(Self { data, version_spec }) } } @@ -422,14 +421,9 @@ pub fn run(args_common: &common::cli::Args, args: &Args) -> Result<(), anyhow::E tracing::info!("args_common = {:?}", &args_common); tracing::info!("args = {:?}", &args); - if let Some(level) = args_common.verbose.log_level() { - match level { - log::Level::Trace | log::Level::Debug => { - std::env::set_var("RUST_LOG", "debug"); - env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); - } - _ => (), - } + if let Some(log::Level::Trace | log::Level::Debug) = args_common.verbose.log_level() { + std::env::set_var("RUST_LOG", "debug"); + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); } tracing::info!("Opening databases..."); diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch37-1+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch37-1+0.33.0-2.snap index dad6968c..6c95a576 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch37-1+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch37-1+0.33.0-2.snap @@ -10,11 +10,11 @@ contributor: format: application/x-rocksdb date: "20240105" version: 1+0.33.0 -genomeRelease: grch37 +genome_release: grch37 description: "RocksDB with the information from the AlphaMissense_hgGENOME.tsv.gz\nfiles for the canonical transcripts.\n" source: - "PMID:37733863" - "https://storage.googleapis.com/dm_alphamissense/README.pdf" -createdFrom: +created_from: - name: AlphaMissense version: "1" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch38-1+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch38-1+0.33.0-2.snap index 13c0ac54..05fc8e5c 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch38-1+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@alphamissense-grch38-1+0.33.0-2.snap @@ -10,11 +10,11 @@ contributor: format: application/x-rocksdb date: "20240105" version: 1+0.33.0 -genomeRelease: grch38 +genome_release: grch38 description: "RocksDB with the information from the AlphaMissense_hgGENOME.tsv.gz\nfiles for the canonical transcripts.\n" source: - "PMID:37733863" - "https://storage.googleapis.com/dm_alphamissense/README.pdf" -createdFrom: +created_from: - name: AlphaMissense version: "1" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch37-105.20201022+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch37-105.20201022+0.33.0-2.snap index 1ab8cf80..62ff1412 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch37-105.20201022+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch37-105.20201022+0.33.0-2.snap @@ -5,13 +5,15 @@ expression: "&proto_spec" identifier: "annonars/functional:105.20201022+0.33.0-" title: annonars functional elements RocksDB creator: VarFish Developer Teams +contributor: [] format: application/x-rocksdb date: "20240105" version: 105.20201022+0.33.0 +genome_release: ~ description: "RocksDB built from RefSeq Functional Elements (and other sources in\nthe future).\n" source: - "PMID:34876495" - "https://www.ncbi.nlm.nih.gov/refseq/" -createdFrom: +created_from: - name: RefSeq Functional Elements version: "105.20201022" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch38-110+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch38-110+0.33.0-2.snap index 9db8eff2..c89fe348 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch38-110+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@functional-grch38-110+0.33.0-2.snap @@ -5,13 +5,15 @@ expression: "&proto_spec" identifier: "annonars/functional:110+0.33.0-" title: annonars functional elements RocksDB creator: VarFish Developer Teams +contributor: [] format: application/x-rocksdb date: "20240105" version: 110+0.33.0 +genome_release: ~ description: "RocksDB built from RefSeq Functional Elements (and other sources in\nthe future).\n" source: - "PMID:34876495" - "https://www.ncbi.nlm.nih.gov/refseq/" -createdFrom: +created_from: - name: RefSeq Functional Elements version: "110" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@genes-3.1+4.0+4.5+20230606+10.1+20240105+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@genes-3.1+4.0+4.5+20230606+10.1+20240105+0.33.0-2.snap index 35a3abe1..1bf410be 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@genes-3.1+4.0+4.5+20230606+10.1+20240105+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@genes-3.1+4.0+4.5+20230606+10.1+20240105+0.33.0-2.snap @@ -5,9 +5,11 @@ expression: "&proto_spec" identifier: "annonars/genes:3.1+4.0+4.5+20240105+0.33.0" title: annonars genes database creator: VarFish Development Team +contributor: [] format: application/x-rocksdb date: "20240105" version: 3.1+4.0+4.5+20240105+0.33.0 +genome_release: ~ description: "Gene information from the following databases, aggregated using annonars\nv0.33.0 in varfish-downloader v0.3.1.dev42+g3a332a0.d20240105:\n\n- ACMG Supplementary Findings Gene List 3.1\n- gnomAD constraints v4.0\n- dbNSFP v4.5\n- NCBI gene database downloaded at 20240105\n- HGNC database downloaded at 20240105\n- ClinGen Gene Dosage pathogenicity 20240105\n- DOMINO data v2019-02-19\n" source: - "PMID:35802134" @@ -16,7 +18,7 @@ source: - "PMID:28985496" - "https://www.ncbi.nlm.nih.gov/gene/" - "https://www.genenames.org/" -createdFrom: +created_from: - name: ACMG SF Gene List version: "3.1" - name: ClinGen Gene Dosage pathog diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch37-3.1+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch37-3.1+0.33.0-2.snap index bfdf475f..6fb05f3c 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch37-3.1+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch37-3.1+0.33.0-2.snap @@ -10,11 +10,11 @@ contributor: format: application/x-rocksdb date: "20240105" version: 3.1+0.33.0 -genomeRelease: grch37 +genome_release: grch37 description: "RocksDB with the information from gnomAD mtDNA v3.1 converted with\nannonars v0.33.0 in varfish-downloader v0.3.1.dev42+g3a332a0.d20240105.\n" source: - "PMID:32461654" - "https://gnomad.broadinstitute.org/" -createdFrom: +created_from: - name: gnomAD-mtDNA version: "3.1" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch38-3.1+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch38-3.1+0.33.0-2.snap index c82a4bc0..050ac249 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch38-3.1+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@gnomad-mtdna-grch38-3.1+0.33.0-2.snap @@ -10,11 +10,11 @@ contributor: format: application/x-rocksdb date: "20240105" version: 3.1+0.33.0 -genomeRelease: grch38 +genome_release: grch38 description: "RocksDB with the information from gnomAD mtDNA v3.1 converted with\nannonars v0.33.0 in varfish-downloader v0.3.1.dev42+g3a332a0.d20240105.\n" source: - "PMID:32461654" - "https://gnomad.broadinstitute.org/" -createdFrom: +created_from: - name: gnomAD-mtDNA version: "3.1" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch37-20200327+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch37-20200327+0.33.0-2.snap index 2deca7b0..b63c6cd6 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch37-20200327+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch37-20200327+0.33.0-2.snap @@ -10,10 +10,10 @@ contributor: format: application/x-rocksdb date: "20240105" version: 20200327+0.33.0 -genomeRelease: grch37 +genome_release: grch37 description: "RocksDB with the information from HelixMtDb v20200327 imported using\nthe annonars package v0.33.0 in varfish-downloader\nv0.3.1.dev42+g3a332a0.d20240105.\n" source: - "https://www.helix.com/pages/mitochondrial-variant-database" -createdFrom: +created_from: - name: HelixMtdB version: "20200327" diff --git a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch38-20200327+0.33.0-2.snap b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch38-20200327+0.33.0-2.snap index 5157c4c9..e3a3f9c6 100644 --- a/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch38-20200327+0.33.0-2.snap +++ b/src/server/run/snapshots/annonars__server__run__versions__test__deserialize_spec_yaml@helixmtdb-grch38-20200327+0.33.0-2.snap @@ -10,10 +10,10 @@ contributor: format: application/x-rocksdb date: "20240105" version: 20200327+0.33.0 -genomeRelease: grch38 +genome_release: grch38 description: "RocksDB with the information from HelixMtDb v20200327 imported using\nthe annonars package v0.33.0 in varfish-downloader\nv0.3.1.dev42+g3a332a0.d20240105.\n" source: - "https://www.helix.com/pages/mitochondrial-variant-database" -createdFrom: +created_from: - name: HelixMtdB version: "20200327" diff --git a/src/server/run/versions.rs b/src/server/run/versions.rs index 751f336b..efc718d2 100644 --- a/src/server/run/versions.rs +++ b/src/server/run/versions.rs @@ -6,7 +6,7 @@ use actix_web::{ Responder, }; -use crate::{common::cli::GenomeRelease, pbs::common::versions::VersionSpec}; +use crate::common::cli::GenomeRelease; use super::{error::CustomError, AnnoDb, WebServerData}; @@ -14,8 +14,6 @@ use super::{error::CustomError, AnnoDb, WebServerData}; pub mod schema { use std::path::Path; - use crate::pbs; - /// Information about input data. #[derive(serde::Deserialize, serde::Serialize, Debug, Clone)] pub struct CreatedFrom { @@ -25,10 +23,10 @@ pub mod schema { pub version: String, } - impl From for pbs::common::versions::CreatedFrom { + impl From for super::VersionsCreatedFrom { fn from(val: CreatedFrom) -> Self { let CreatedFrom { name, version } = val; - pbs::common::versions::CreatedFrom { name, version } + super::VersionsCreatedFrom { name, version } } } @@ -88,7 +86,7 @@ pub mod schema { } } - impl From for pbs::common::versions::VersionSpec { + impl From for super::VersionsVersionSpec { fn from(val: VersionSpec) -> Self { let VersionSpec { identifier, @@ -103,7 +101,7 @@ pub mod schema { source, created_from, } = val; - pbs::common::versions::VersionSpec { + super::VersionsVersionSpec { identifier, title, creator, @@ -121,80 +119,118 @@ pub mod schema { } /// Query parameters for `handle()`. -#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] -pub struct VersionInfoQuery {} +#[derive( + Debug, Clone, serde::Serialize, serde::Deserialize, utoipa::IntoParams, utoipa::ToSchema, +)] +pub struct VersionsInfoQuery {} + +/// Source name and version. +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] +pub struct VersionsCreatedFrom { + /// The name of the data source. + pub name: String, + /// The version of the data source. + pub version: String, +} + +/// Version specification. +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] +pub struct VersionsVersionSpec { + /// Identifier of the data. + pub identifier: String, + /// Title of the data. + pub title: String, + /// Creator of the data. + pub creator: String, + /// Contributors of the data. + pub contributor: Vec, + /// Format of the data. + pub format: String, + /// Date of the data. + pub date: String, + /// Version of the data. + pub version: String, + /// Optional genome release. + pub genome_release: Option, + /// Data description. + pub description: String, + /// Data source. + pub source: Vec, + /// Created from information. + pub created_from: Vec, +} /// Version information for one database. -#[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)] -#[serde(rename_all = "camelCase")] -pub struct AnnoVersionInfo { +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] +#[serde(rename_all = "snake_case")] +pub struct VersionsAnnotationInfo { /// Database name. pub database: AnnoDb, /// Version information of the database. - pub version_spec: Option, + pub version_spec: Option, } /// Version information for databases in a given release. -#[derive(Debug, Default, Clone, serde::Serialize, utoipa::ToSchema)] -#[serde(rename_all = "camelCase")] -pub struct ReleaseVersionInfos { +#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] +pub struct VersionsPerRelease { /// The genome release. pub release: GenomeRelease, /// Version information of annotation databases. #[serde(skip_serializing_if = "Vec::is_empty")] - pub version_infos: Vec, + pub version_infos: Vec, } /// Response for `handle()`. -#[derive(Debug, Default, Clone, serde::Serialize, utoipa::ToSchema)] -pub struct VersionInfoResponse { +#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, utoipa::ToSchema)] +pub struct VersionsInfoResponse { /// Version information of the genes. #[serde(skip_serializing_if = "Option::is_none")] - pub genes: Option, + pub genes: Option, /// Version information of annotation databases per release. #[serde(skip_serializing_if = "Vec::is_empty")] - pub annos: Vec, + pub seqvars: Vec, } /// Query for annotations for one variant. #[utoipa::path( get, - operation_id = "versionInfos", - params(VersionInfoQuery), + operation_id = "versionsInfo", + params(VersionsInfoQuery), responses( - (status = 200, description = "Version information.", body = VersionInfoResponse), + (status = 200, description = "Version information.", body = VersionsInfoResponse), + (status = 500, description = "Internal server error.", body = CustomError) ) )] -#[get("/v1/versions")] +#[get("/api/v1/versionsInfo")] async fn handle( data: Data, _path: Path<()>, - _query: web::Query, + _query: web::Query, ) -> actix_web::Result { - let mut annos = Vec::new(); + let mut seqvars = Vec::new(); for (release, anno_dbs) in data.as_ref().annos.iter() { let mut version_infos = Vec::new(); for (anno_db, with_version) in anno_dbs { if let Some(with_version) = with_version.as_ref() { - version_infos.push(AnnoVersionInfo { + version_infos.push(VersionsAnnotationInfo { database: anno_db, - version_spec: with_version.version_spec.clone(), + version_spec: with_version.version_spec.clone().map(Into::into), }); } } - annos.push(ReleaseVersionInfos { + seqvars.push(VersionsPerRelease { release, version_infos, }); } - let response = VersionInfoResponse { + let response = VersionsInfoResponse { genes: data .as_ref() .genes .as_ref() - .and_then(|genes| genes.version_spec.clone()), - annos, + .and_then(|genes| genes.version_spec.clone().map(Into::into)), + seqvars, }; Ok(Json(response)) @@ -219,7 +255,7 @@ pub mod test { let spec = super::schema::VersionSpec::from_path(full_path)?; insta::assert_yaml_snapshot!(&spec); - let proto_spec: crate::pbs::common::versions::VersionSpec = spec.into(); + let proto_spec: super::VersionsVersionSpec = spec.into(); insta::assert_yaml_snapshot!(&proto_spec); Ok(())