From fe4dc8cc3e8b38336a50f32963dce93af2c9522a Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 13:58:59 +0300 Subject: [PATCH 1/8] chore: Release --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- generic_a_star/Cargo.toml | 2 +- lib_tsalign/Cargo.toml | 4 ++-- lib_tsshow/Cargo.toml | 4 ++-- python_bindings/Cargo.toml | 6 +++--- seed_chain/Cargo.toml | 2 +- tsalign-tests/Cargo.toml | 2 +- tsalign/Cargo.toml | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddb533ba..6fdc6f99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -361,7 +361,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic_a_star" -version = "0.15.0" +version = "0.16.0" dependencies = [ "binary-heap-plus", "deterministic_default_hasher", @@ -463,7 +463,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib_tsalign" -version = "0.15.0" +version = "0.16.0" dependencies = [ "binary-heap-plus", "compact-genome", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "lib_tsshow" -version = "0.15.0" +version = "0.16.0" dependencies = [ "ena", "itertools", @@ -692,7 +692,7 @@ dependencies = [ [[package]] name = "py_lib_tsalign" -version = "0.1.0" +version = "0.2.0" dependencies = [ "lib_tsalign", "lib_tsshow", @@ -1201,7 +1201,7 @@ checksum = "2b939c825d0c4295ac520f7b479927c1e5b458c9107a9d6f5ba65bc867bb93a5" [[package]] name = "tsalign" -version = "0.15.0" +version = "0.16.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7a4466a5..69231cde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,4 +28,4 @@ log = "0.4.27" num-traits = "0.2.19" [profile.release] -debug = true \ No newline at end of file +debug = true diff --git a/generic_a_star/Cargo.toml b/generic_a_star/Cargo.toml index 8bb97a17..141cf122 100644 --- a/generic_a_star/Cargo.toml +++ b/generic_a_star/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "generic_a_star" description = "A generic implementation of the A* algorithm" -version = "0.15.0" +version = "0.16.0" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/lib_tsalign/Cargo.toml b/lib_tsalign/Cargo.toml index dc7ba6ab..cec2b043 100644 --- a/lib_tsalign/Cargo.toml +++ b/lib_tsalign/Cargo.toml @@ -3,7 +3,7 @@ name = "lib_tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.15.0" +version = "0.16.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -26,7 +26,7 @@ thiserror = "2.0.3" num-traits.workspace = true serde = { workspace = true, features = ["derive"], optional = true } noisy_float = { version = "0.2.0" } -generic_a_star = { version = "0.15.0", path = "../generic_a_star" } +generic_a_star = { version = "0.16.0", path = "../generic_a_star" } log.workspace = true seed_chain = { version = "0.15.0", path = "../seed_chain" } deterministic_default_hasher = "0.14.2" diff --git a/lib_tsshow/Cargo.toml b/lib_tsshow/Cargo.toml index af8a5e8f..10883291 100644 --- a/lib_tsshow/Cargo.toml +++ b/lib_tsshow/Cargo.toml @@ -3,13 +3,13 @@ name = "lib_tsshow" description = "A visualiser for template-switch alignments" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.15.0" +version = "0.16.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.15.0", path = "../lib_tsalign" } +lib_tsalign = { version = "0.16.0", path = "../lib_tsalign" } log.workspace = true svg = "0.18.0" resvg = "0.45.0" diff --git a/python_bindings/Cargo.toml b/python_bindings/Cargo.toml index d62fb41c..2bd3e8fa 100644 --- a/python_bindings/Cargo.toml +++ b/python_bindings/Cargo.toml @@ -3,7 +3,7 @@ name = "py_lib_tsalign" description = "Python Bindings for `lib_tsalign`" license.workspace = true authors = ["Sebastian Schmidt ", "Jasper Krauter "] -version = "0.1.0" +version = "0.2.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -15,8 +15,8 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.24.0" -lib_tsalign = { version = "0.15.0", path = "../lib_tsalign", features = ["serde"] } -lib_tsshow = { version = "0.15.0", path = "../lib_tsshow" } +lib_tsalign = { version = "0.16.0", path = "../lib_tsalign", features = ["serde"] } +lib_tsshow = { version = "0.16.0", path = "../lib_tsshow" } serde.workspace = true pythonize = "0.24.0" pyo3-log = "0.12.3" diff --git a/seed_chain/Cargo.toml b/seed_chain/Cargo.toml index c2258865..563ec1d5 100644 --- a/seed_chain/Cargo.toml +++ b/seed_chain/Cargo.toml @@ -12,5 +12,5 @@ repository.workspace = true [dependencies] compact-genome.workspace = true log.workspace = true -generic_a_star = { version = "0.15.0", path = "../generic_a_star" } +generic_a_star = { version = "0.16.0", path = "../generic_a_star" } num-traits.workspace = true diff --git a/tsalign-tests/Cargo.toml b/tsalign-tests/Cargo.toml index 7999614a..9cf685d3 100644 --- a/tsalign-tests/Cargo.toml +++ b/tsalign-tests/Cargo.toml @@ -9,6 +9,6 @@ repository.workspace = true publish = false [dependencies] -tsalign = { version = "0.15.0", path = "../tsalign" } +tsalign = { version = "0.16.0", path = "../tsalign" } clap = { version = "4.5.16", features = ["derive"] } anyhow = "1.0.97" diff --git a/tsalign/Cargo.toml b/tsalign/Cargo.toml index 4c36045f..e4eceffb 100644 --- a/tsalign/Cargo.toml +++ b/tsalign/Cargo.toml @@ -3,16 +3,16 @@ name = "tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.15.0" +version = "0.16.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.15.0", path = "../lib_tsalign", features = [ +lib_tsalign = { version = "0.16.0", path = "../lib_tsalign", features = [ "serde", ] } -lib_tsshow = { version = "0.15.0", path = "../lib_tsshow" } +lib_tsshow = { version = "0.16.0", path = "../lib_tsshow" } clap = { version = "4.5.16", features = ["derive"] } compact-genome = { workspace = true, features = ["io"] } traitsequence.workspace = true From f9d8f9931b0ce67bbdc4ee6d0b325cb6c90edfe1 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:00:18 +0300 Subject: [PATCH 2/8] chore: Release --- Cargo.lock | 14 +++++++------- generic_a_star/Cargo.toml | 2 +- lib_tsalign/Cargo.toml | 6 +++--- lib_tsshow/Cargo.toml | 4 ++-- python_bindings/Cargo.toml | 6 +++--- seed_chain/Cargo.toml | 4 ++-- tsalign-tests/Cargo.toml | 4 ++-- tsalign/Cargo.toml | 6 +++--- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fdc6f99..84ae17c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -361,7 +361,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic_a_star" -version = "0.16.0" +version = "0.17.0" dependencies = [ "binary-heap-plus", "deterministic_default_hasher", @@ -463,7 +463,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib_tsalign" -version = "0.16.0" +version = "0.17.0" dependencies = [ "binary-heap-plus", "compact-genome", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "lib_tsshow" -version = "0.16.0" +version = "0.17.0" dependencies = [ "ena", "itertools", @@ -692,7 +692,7 @@ dependencies = [ [[package]] name = "py_lib_tsalign" -version = "0.2.0" +version = "0.3.0" dependencies = [ "lib_tsalign", "lib_tsshow", @@ -885,7 +885,7 @@ dependencies = [ [[package]] name = "seed_chain" -version = "0.15.0" +version = "0.16.0" dependencies = [ "compact-genome", "generic_a_star", @@ -1201,7 +1201,7 @@ checksum = "2b939c825d0c4295ac520f7b479927c1e5b458c9107a9d6f5ba65bc867bb93a5" [[package]] name = "tsalign" -version = "0.16.0" +version = "0.17.0" dependencies = [ "anyhow", "clap", @@ -1217,7 +1217,7 @@ dependencies = [ [[package]] name = "tsalign-tests" -version = "0.2.0" +version = "0.3.0" dependencies = [ "anyhow", "clap", diff --git a/generic_a_star/Cargo.toml b/generic_a_star/Cargo.toml index 141cf122..34881c5a 100644 --- a/generic_a_star/Cargo.toml +++ b/generic_a_star/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "generic_a_star" description = "A generic implementation of the A* algorithm" -version = "0.16.0" +version = "0.17.0" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/lib_tsalign/Cargo.toml b/lib_tsalign/Cargo.toml index cec2b043..b13eab0e 100644 --- a/lib_tsalign/Cargo.toml +++ b/lib_tsalign/Cargo.toml @@ -3,7 +3,7 @@ name = "lib_tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.16.0" +version = "0.17.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -26,8 +26,8 @@ thiserror = "2.0.3" num-traits.workspace = true serde = { workspace = true, features = ["derive"], optional = true } noisy_float = { version = "0.2.0" } -generic_a_star = { version = "0.16.0", path = "../generic_a_star" } +generic_a_star = { version = "0.17.0", path = "../generic_a_star" } log.workspace = true -seed_chain = { version = "0.15.0", path = "../seed_chain" } +seed_chain = { version = "0.16.0", path = "../seed_chain" } deterministic_default_hasher = "0.14.2" extend_map = "0.14.3" diff --git a/lib_tsshow/Cargo.toml b/lib_tsshow/Cargo.toml index 10883291..592fe4cb 100644 --- a/lib_tsshow/Cargo.toml +++ b/lib_tsshow/Cargo.toml @@ -3,13 +3,13 @@ name = "lib_tsshow" description = "A visualiser for template-switch alignments" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.16.0" +version = "0.17.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.16.0", path = "../lib_tsalign" } +lib_tsalign = { version = "0.17.0", path = "../lib_tsalign" } log.workspace = true svg = "0.18.0" resvg = "0.45.0" diff --git a/python_bindings/Cargo.toml b/python_bindings/Cargo.toml index 2bd3e8fa..f6131363 100644 --- a/python_bindings/Cargo.toml +++ b/python_bindings/Cargo.toml @@ -3,7 +3,7 @@ name = "py_lib_tsalign" description = "Python Bindings for `lib_tsalign`" license.workspace = true authors = ["Sebastian Schmidt ", "Jasper Krauter "] -version = "0.2.0" +version = "0.3.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -15,8 +15,8 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.24.0" -lib_tsalign = { version = "0.16.0", path = "../lib_tsalign", features = ["serde"] } -lib_tsshow = { version = "0.16.0", path = "../lib_tsshow" } +lib_tsalign = { version = "0.17.0", path = "../lib_tsalign", features = ["serde"] } +lib_tsshow = { version = "0.17.0", path = "../lib_tsshow" } serde.workspace = true pythonize = "0.24.0" pyo3-log = "0.12.3" diff --git a/seed_chain/Cargo.toml b/seed_chain/Cargo.toml index 563ec1d5..e43c22e3 100644 --- a/seed_chain/Cargo.toml +++ b/seed_chain/Cargo.toml @@ -3,7 +3,7 @@ name = "seed_chain" description = "A seeding and generic chaining mechanism for sequence-to-sequence alignment" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.15.0" +version = "0.16.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -12,5 +12,5 @@ repository.workspace = true [dependencies] compact-genome.workspace = true log.workspace = true -generic_a_star = { version = "0.16.0", path = "../generic_a_star" } +generic_a_star = { version = "0.17.0", path = "../generic_a_star" } num-traits.workspace = true diff --git a/tsalign-tests/Cargo.toml b/tsalign-tests/Cargo.toml index 9cf685d3..8fc6b665 100644 --- a/tsalign-tests/Cargo.toml +++ b/tsalign-tests/Cargo.toml @@ -2,13 +2,13 @@ name = "tsalign-tests" license.workspace = true authors = ["Sebastian Schmidt ", "Jasper Krauter "] -version = "0.2.0" +version = "0.3.0" edition.workspace = true rust-version.workspace = true repository.workspace = true publish = false [dependencies] -tsalign = { version = "0.16.0", path = "../tsalign" } +tsalign = { version = "0.17.0", path = "../tsalign" } clap = { version = "4.5.16", features = ["derive"] } anyhow = "1.0.97" diff --git a/tsalign/Cargo.toml b/tsalign/Cargo.toml index e4eceffb..38d8f01b 100644 --- a/tsalign/Cargo.toml +++ b/tsalign/Cargo.toml @@ -3,16 +3,16 @@ name = "tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.16.0" +version = "0.17.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.16.0", path = "../lib_tsalign", features = [ +lib_tsalign = { version = "0.17.0", path = "../lib_tsalign", features = [ "serde", ] } -lib_tsshow = { version = "0.16.0", path = "../lib_tsshow" } +lib_tsshow = { version = "0.17.0", path = "../lib_tsshow" } clap = { version = "4.5.16", features = ["derive"] } compact-genome = { workspace = true, features = ["io"] } traitsequence.workspace = true From ae86ef70397df44a3569429e10a1640d92fec40c Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:02:12 +0300 Subject: [PATCH 3/8] Use default features in check in CI. --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49b7b620..ae1a8761 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,23 @@ jobs: - name: cargo format uses: actions-rust-lang/rustfmt@v1 + rust_check_default_features: + name: Rust check with default features + runs-on: ubuntu-latest + needs: ["rust_check", "rust_format"] + + strategy: + fail-fast: true + + steps: + - uses: actions/checkout@v3 + + - name: Install toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: cargo check + run: cargo check --bins --tests + rust_lint: name: Rust lint runs-on: ubuntu-latest From 1f8e233532142817ca0c3058de828bce1db87b4f Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:04:47 +0300 Subject: [PATCH 4/8] Fix. --- .../src/a_star_aligner/configurable_a_star_align.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs b/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs index ec199db6..aed59fe4 100644 --- a/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs +++ b/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs @@ -99,7 +99,7 @@ impl Default for Config { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum InputAlphabet { Dna, DnaN, @@ -110,21 +110,21 @@ pub enum InputAlphabet { } #[derive(Debug, Deserialize)] -#[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum NodeOrdStrategySelector { CostOnly, AntiDiagonal, } #[derive(Debug, Deserialize)] -#[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum MinLengthStrategySelector { None, Lookahead, } #[derive(Debug, Deserialize)] -#[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum ChainingStrategySelector { None, PrecomputeOnly, From 53f813d6ca53f67d241d30317e91466f6756c077 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:08:11 +0300 Subject: [PATCH 5/8] Upgrade versions. --- Cargo.lock | 10 +++++----- generic_a_star/Cargo.toml | 2 +- lib_tsalign/Cargo.toml | 6 +++--- lib_tsshow/Cargo.toml | 4 ++-- python_bindings/Cargo.toml | 4 ++-- seed_chain/Cargo.toml | 4 ++-- tsalign-tests/Cargo.toml | 2 +- tsalign/Cargo.toml | 6 +++--- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84ae17c6..c1e8b9af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -361,7 +361,7 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic_a_star" -version = "0.17.0" +version = "0.18.0" dependencies = [ "binary-heap-plus", "deterministic_default_hasher", @@ -463,7 +463,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "lib_tsalign" -version = "0.17.0" +version = "0.18.0" dependencies = [ "binary-heap-plus", "compact-genome", @@ -483,7 +483,7 @@ dependencies = [ [[package]] name = "lib_tsshow" -version = "0.17.0" +version = "0.18.0" dependencies = [ "ena", "itertools", @@ -885,7 +885,7 @@ dependencies = [ [[package]] name = "seed_chain" -version = "0.16.0" +version = "0.18.0" dependencies = [ "compact-genome", "generic_a_star", @@ -1201,7 +1201,7 @@ checksum = "2b939c825d0c4295ac520f7b479927c1e5b458c9107a9d6f5ba65bc867bb93a5" [[package]] name = "tsalign" -version = "0.17.0" +version = "0.18.0" dependencies = [ "anyhow", "clap", diff --git a/generic_a_star/Cargo.toml b/generic_a_star/Cargo.toml index 34881c5a..6cdd44d4 100644 --- a/generic_a_star/Cargo.toml +++ b/generic_a_star/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "generic_a_star" description = "A generic implementation of the A* algorithm" -version = "0.17.0" +version = "0.18.0" edition.workspace = true rust-version.workspace = true license.workspace = true diff --git a/lib_tsalign/Cargo.toml b/lib_tsalign/Cargo.toml index b13eab0e..d99b9c2d 100644 --- a/lib_tsalign/Cargo.toml +++ b/lib_tsalign/Cargo.toml @@ -3,7 +3,7 @@ name = "lib_tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.17.0" +version = "0.18.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -26,8 +26,8 @@ thiserror = "2.0.3" num-traits.workspace = true serde = { workspace = true, features = ["derive"], optional = true } noisy_float = { version = "0.2.0" } -generic_a_star = { version = "0.17.0", path = "../generic_a_star" } +generic_a_star = { version = "0.18.0", path = "../generic_a_star" } log.workspace = true -seed_chain = { version = "0.16.0", path = "../seed_chain" } +seed_chain = { version = "0.18.0", path = "../seed_chain" } deterministic_default_hasher = "0.14.2" extend_map = "0.14.3" diff --git a/lib_tsshow/Cargo.toml b/lib_tsshow/Cargo.toml index 592fe4cb..8c4fe0c6 100644 --- a/lib_tsshow/Cargo.toml +++ b/lib_tsshow/Cargo.toml @@ -3,13 +3,13 @@ name = "lib_tsshow" description = "A visualiser for template-switch alignments" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.17.0" +version = "0.18.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.17.0", path = "../lib_tsalign" } +lib_tsalign = { version = "0.18.0", path = "../lib_tsalign" } log.workspace = true svg = "0.18.0" resvg = "0.45.0" diff --git a/python_bindings/Cargo.toml b/python_bindings/Cargo.toml index f6131363..92f59077 100644 --- a/python_bindings/Cargo.toml +++ b/python_bindings/Cargo.toml @@ -15,8 +15,8 @@ crate-type = ["cdylib"] [dependencies] pyo3 = "0.24.0" -lib_tsalign = { version = "0.17.0", path = "../lib_tsalign", features = ["serde"] } -lib_tsshow = { version = "0.17.0", path = "../lib_tsshow" } +lib_tsalign = { version = "0.18.0", path = "../lib_tsalign", features = ["serde"] } +lib_tsshow = { version = "0.18.0", path = "../lib_tsshow" } serde.workspace = true pythonize = "0.24.0" pyo3-log = "0.12.3" diff --git a/seed_chain/Cargo.toml b/seed_chain/Cargo.toml index e43c22e3..060b0f28 100644 --- a/seed_chain/Cargo.toml +++ b/seed_chain/Cargo.toml @@ -3,7 +3,7 @@ name = "seed_chain" description = "A seeding and generic chaining mechanism for sequence-to-sequence alignment" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.16.0" +version = "0.18.0" edition.workspace = true rust-version.workspace = true repository.workspace = true @@ -12,5 +12,5 @@ repository.workspace = true [dependencies] compact-genome.workspace = true log.workspace = true -generic_a_star = { version = "0.17.0", path = "../generic_a_star" } +generic_a_star = { version = "0.18.0", path = "../generic_a_star" } num-traits.workspace = true diff --git a/tsalign-tests/Cargo.toml b/tsalign-tests/Cargo.toml index 8fc6b665..4c0003aa 100644 --- a/tsalign-tests/Cargo.toml +++ b/tsalign-tests/Cargo.toml @@ -9,6 +9,6 @@ repository.workspace = true publish = false [dependencies] -tsalign = { version = "0.17.0", path = "../tsalign" } +tsalign = { version = "0.18.0", path = "../tsalign" } clap = { version = "4.5.16", features = ["derive"] } anyhow = "1.0.97" diff --git a/tsalign/Cargo.toml b/tsalign/Cargo.toml index 38d8f01b..99d6020b 100644 --- a/tsalign/Cargo.toml +++ b/tsalign/Cargo.toml @@ -3,16 +3,16 @@ name = "tsalign" description = "A sequence-to-sequence aligner that accounts for template switches" license.workspace = true authors = ["Sebastian Schmidt "] -version = "0.17.0" +version = "0.18.0" edition.workspace = true rust-version.workspace = true repository.workspace = true [dependencies] -lib_tsalign = { version = "0.17.0", path = "../lib_tsalign", features = [ +lib_tsalign = { version = "0.18.0", path = "../lib_tsalign", features = [ "serde", ] } -lib_tsshow = { version = "0.17.0", path = "../lib_tsshow" } +lib_tsshow = { version = "0.18.0", path = "../lib_tsshow" } clap = { version = "4.5.16", features = ["derive"] } compact-genome = { workspace = true, features = ["io"] } traitsequence.workspace = true From 865dd69fb82d2b71bd7c59cf7aef55934f75ceca Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:47:10 +0300 Subject: [PATCH 6/8] Fix. --- .../src/a_star_aligner/alignment_geometry.rs | 12 +-- .../configurable_a_star_align.rs | 25 +++--- lib_tsalign/src/config.rs | 82 +++++++++++++++++++ lib_tsalign/src/config/io.rs | 58 +++++++++++++ lib_tsalign/src/costs/cost_function/io.rs | 15 +++- lib_tsalign/src/costs/gap_affine.rs | 30 ++++++- lib_tsalign/src/costs/gap_affine/io.rs | 12 ++- 7 files changed, 211 insertions(+), 23 deletions(-) diff --git a/lib_tsalign/src/a_star_aligner/alignment_geometry.rs b/lib_tsalign/src/a_star_aligner/alignment_geometry.rs index b55b5026..a37a82cb 100644 --- a/lib_tsalign/src/a_star_aligner/alignment_geometry.rs +++ b/lib_tsalign/src/a_star_aligner/alignment_geometry.rs @@ -1,16 +1,16 @@ use std::{fmt::Display, ops::Range}; -use serde::Deserialize; - -#[derive(Debug, Clone, Eq, PartialEq, Deserialize)] -#[serde(rename_all = "snake_case")] +#[derive(Debug, Clone, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub struct AlignmentRange { offset: AlignmentCoordinates, limit: AlignmentCoordinates, } -#[derive(Debug, Clone, Copy, Eq, PartialEq, Deserialize)] -#[serde(rename_all = "snake_case")] +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub struct AlignmentCoordinates { reference: usize, query: usize, diff --git a/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs b/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs index aed59fe4..c523422e 100644 --- a/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs +++ b/lib_tsalign/src/a_star_aligner/configurable_a_star_align.rs @@ -16,7 +16,6 @@ use compact_genome::{ }, }; use generic_a_star::cost::U64Cost; -use serde::Deserialize; use crate::{ a_star_aligner::{ @@ -53,13 +52,9 @@ use super::{ }, }; -// TODO to be discussed -// TODO more ergonomic way to only adjust some cost values ... -/// Default costs for a star alignment, given in the custom `.tsa` format -const DEFAULT_COSTS: &str = include_str!("../../../sample_tsa_config/config.tsa"); - -#[derive(Debug, Deserialize)] -#[serde(rename_all = "snake_case", default)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub struct Config { pub alphabet: InputAlphabet, pub reference_name: String, @@ -86,7 +81,7 @@ impl Default for Config { alphabet: InputAlphabet::DnaN, reference_name: "reference".to_owned(), query_name: "query".to_owned(), - costs: DEFAULT_COSTS.to_owned(), + costs: TemplateSwitchConfig::::default().to_string(), node_ord_strategy: NodeOrdStrategySelector::AntiDiagonal, min_length_strategy: MinLengthStrategySelector::Lookahead, chaining_strategy: ChainingStrategySelector::None, @@ -98,7 +93,8 @@ impl Default for Config { } } -#[derive(Debug, Deserialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum InputAlphabet { Dna, @@ -109,21 +105,24 @@ pub enum InputAlphabet { RnaIupac, } -#[derive(Debug, Deserialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum NodeOrdStrategySelector { CostOnly, AntiDiagonal, } -#[derive(Debug, Deserialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum MinLengthStrategySelector { None, Lookahead, } -#[derive(Debug, Deserialize)] +#[derive(Debug)] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))] pub enum ChainingStrategySelector { None, diff --git a/lib_tsalign/src/config.rs b/lib_tsalign/src/config.rs index 865b4232..92db95fa 100644 --- a/lib_tsalign/src/config.rs +++ b/lib_tsalign/src/config.rs @@ -1,4 +1,5 @@ use compact_genome::interface::alphabet::Alphabet; +use generic_a_star::cost::AStarCost; use num_traits::{Bounded, bounds::UpperBounded}; use crate::{ @@ -178,3 +179,84 @@ impl Clone for TemplateSwitchConfig Default for TemplateSwitchConfig { + fn default() -> Self { + Self { + left_flank_length: 0, + right_flank_length: 0, + min_length: 5, + base_cost: BaseCost { + rrf: 4.into(), + rqf: 4.into(), + qrf: 4.into(), + qqf: 4.into(), + rrr: 3.into(), + rqr: 2.into(), + qrr: 2.into(), + qqr: 3.into(), + }, + primary_edit_costs: GapAffineAlignmentCostTable::new_base_agnostic( + "Primary Edit Costs", + 0.into(), + 2.into(), + 3.into(), + 1.into(), + ), + secondary_forward_edit_costs: GapAffineAlignmentCostTable::new_base_agnostic( + "Secondary Forward Edit Costs", + 0.into(), + 2.into(), + 3.into(), + 1.into(), + ), + secondary_reverse_edit_costs: GapAffineAlignmentCostTable::new_base_agnostic( + "Secondary Reverse Edit Costs", + 0.into(), + 2.into(), + 3.into(), + 1.into(), + ), + left_flank_edit_costs: GapAffineAlignmentCostTable::new_base_agnostic( + "Left Flank Edit Costs", + 0.into(), + 2.into(), + 3.into(), + 1.into(), + ), + right_flank_edit_costs: GapAffineAlignmentCostTable::new_base_agnostic( + "Right Flank Edit Costs", + 0.into(), + 2.into(), + 3.into(), + 1.into(), + ), + offset_costs: CostFunction::try_from(vec![ + (isize::MIN, Cost::max_value()), + (-100, 0.into()), + (101, Cost::max_value()), + ]) + .unwrap(), + length_costs: CostFunction::try_from(vec![(0, Cost::max_value()), (5, 0.into())]) + .unwrap(), + length_difference_costs: CostFunction::try_from(vec![ + (isize::MIN, Cost::max_value()), + (-100, 0.into()), + (101, Cost::max_value()), + ]) + .unwrap(), + forward_anti_primary_gap_costs: CostFunction::try_from(vec![ + (isize::MIN, Cost::max_value()), + (-100, 0.into()), + (101, Cost::max_value()), + ]) + .unwrap(), + reverse_anti_primary_gap_costs: CostFunction::try_from(vec![ + (isize::MIN, Cost::max_value()), + (-100, 0.into()), + (101, Cost::max_value()), + ]) + .unwrap(), + } + } +} diff --git a/lib_tsalign/src/config/io.rs b/lib_tsalign/src/config/io.rs index 154b1ebd..2c0becd4 100644 --- a/lib_tsalign/src/config/io.rs +++ b/lib_tsalign/src/config/io.rs @@ -215,3 +215,61 @@ pub fn parse_inf_value(input: &str) -> IResult<&str, Ok((&input[length..], result)) } } + +impl std::fmt::Display + for TemplateSwitchConfig +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "# Limits")?; + writeln!(f, "left_flank_length = {}", self.left_flank_length)?; + writeln!(f, "right_flank_length = {}", self.right_flank_length)?; + + writeln!(f, "# Base Cost")?; + writeln!(f, "rrf_cost = {}", self.base_cost.rrf)?; + writeln!(f, "rqf_cost = {}", self.base_cost.rqf)?; + writeln!(f, "qrf_cost = {}", self.base_cost.qrf)?; + writeln!(f, "qqf_cost = {}", self.base_cost.qqf)?; + writeln!(f, "rrr_cost = {}", self.base_cost.rrr)?; + writeln!(f, "rqr_cost = {}", self.base_cost.rqr)?; + writeln!(f, "qrr_cost = {}", self.base_cost.qrr)?; + writeln!(f, "qqr_cost = {}", self.base_cost.qqr)?; + + writeln!(f, "# Jump Costs")?; + writeln!(f, "Offset")?; + writeln!(f, "{}", self.offset_costs)?; + writeln!(f, "Length")?; + writeln!(f, "{}", self.length_costs)?; + writeln!(f, "LengthDifference")?; + writeln!(f, "{}", self.length_difference_costs)?; + writeln!(f, "ForwardAntiPrimaryGap")?; + writeln!(f, "{}", self.forward_anti_primary_gap_costs)?; + writeln!(f, "ReverseAntiPrimaryGap")?; + writeln!(f, "{}", self.reverse_anti_primary_gap_costs)?; + + self.primary_edit_costs.fmt(f)?; + self.secondary_forward_edit_costs.fmt(f)?; + self.secondary_reverse_edit_costs.fmt(f)?; + self.left_flank_edit_costs.fmt(f)?; + self.right_flank_edit_costs.fmt(f)?; + + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use compact_genome::implementation::alphabets::dna_alphabet_or_n::DnaAlphabetOrN; + use generic_a_star::cost::U64Cost; + + use crate::config::TemplateSwitchConfig; + + #[test] + fn display() { + let config = TemplateSwitchConfig::::default(); + let string = config.to_string(); + assert_eq!( + config, + TemplateSwitchConfig::read_plain(string.as_bytes()).unwrap() + ); + } +} diff --git a/lib_tsalign/src/costs/cost_function/io.rs b/lib_tsalign/src/costs/cost_function/io.rs index 7b2cd55e..56998cd8 100644 --- a/lib_tsalign/src/costs/cost_function/io.rs +++ b/lib_tsalign/src/costs/cost_function/io.rs @@ -19,7 +19,7 @@ impl CostFunction CostFunction CostFunction std::fmt::Display + for CostFunction +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut output = Vec::new(); + self.write_plain(&mut output).unwrap(); + let string = String::from_utf8(output).unwrap(); + write!(f, "{string}") + } +} + #[cfg(test)] mod tests { use generic_a_star::cost::U64Cost; diff --git a/lib_tsalign/src/costs/gap_affine.rs b/lib_tsalign/src/costs/gap_affine.rs index dc63119b..c28f88a5 100644 --- a/lib_tsalign/src/costs/gap_affine.rs +++ b/lib_tsalign/src/costs/gap_affine.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use std::{iter, marker::PhantomData}; use compact_genome::interface::alphabet::{Alphabet, AlphabetCharacter}; use generic_a_star::cost::AStarCost; @@ -30,6 +30,34 @@ impl GapAffineAlignmentCostTable, + match_cost: Cost, + substitution_cost: Cost, + gap_open_cost: Cost, + gap_extend_cost: Cost, + ) -> Self { + Self { + name: name.into(), + substitution_cost_table: (0..AlphabetType::SIZE) + .flat_map(|a| { + (0..AlphabetType::SIZE).map(move |b| { + if a == b { + match_cost + } else { + substitution_cost + } + }) + }) + .collect(), + gap_open_cost_vector: iter::repeat_n(gap_open_cost, AlphabetType::SIZE.into()) + .collect(), + gap_extend_cost_vector: iter::repeat_n(gap_extend_cost, AlphabetType::SIZE.into()) + .collect(), + phantom_data: PhantomData, + } + } + pub fn new_zero() -> Self { let alphabet_size: usize = AlphabetType::SIZE.into(); diff --git a/lib_tsalign/src/costs/gap_affine/io.rs b/lib_tsalign/src/costs/gap_affine/io.rs index 7ec47cac..c8a7ca4e 100644 --- a/lib_tsalign/src/costs/gap_affine/io.rs +++ b/lib_tsalign/src/costs/gap_affine/io.rs @@ -71,7 +71,6 @@ impl GapAffineAlignmentCostTable( })?; Ok((input, character)) } + +impl std::fmt::Display + for GapAffineAlignmentCostTable +{ + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut output = Vec::new(); + self.write_plain(&mut output).unwrap(); + let string = String::from_utf8(output).unwrap(); + write!(f, "{string}") + } +} From a663e2b08bc41b6b566340a823399a7536b41a48 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:48:27 +0300 Subject: [PATCH 7/8] Fix. --- lib_tsalign/src/config/io.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_tsalign/src/config/io.rs b/lib_tsalign/src/config/io.rs index 2c0becd4..33d4bd92 100644 --- a/lib_tsalign/src/config/io.rs +++ b/lib_tsalign/src/config/io.rs @@ -246,11 +246,11 @@ impl std::fmt::Display writeln!(f, "ReverseAntiPrimaryGap")?; writeln!(f, "{}", self.reverse_anti_primary_gap_costs)?; - self.primary_edit_costs.fmt(f)?; - self.secondary_forward_edit_costs.fmt(f)?; - self.secondary_reverse_edit_costs.fmt(f)?; - self.left_flank_edit_costs.fmt(f)?; - self.right_flank_edit_costs.fmt(f)?; + writeln!(f, "{}", self.primary_edit_costs)?; + writeln!(f, "{}", self.secondary_forward_edit_costs)?; + writeln!(f, "{}", self.secondary_reverse_edit_costs)?; + writeln!(f, "{}", self.left_flank_edit_costs)?; + writeln!(f, "{}", self.right_flank_edit_costs)?; Ok(()) } From b511f7525bc8300c2448d289006d993889652026 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Tue, 20 May 2025 14:51:32 +0300 Subject: [PATCH 8/8] Change workspace member order. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 69231cde..2369dd06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,8 @@ members = [ "generic_a_star", "seed_chain", "lib_tsalign", - "tsalign", "lib_tsshow", + "tsalign", # Bindings "python_bindings",