Skip to content

Commit a46afae

Browse files
committed
Updated dependecies and changed code to work for bincode 2.0
1 parent 9d2df43 commit a46afae

File tree

89 files changed

+434
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+434
-785
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ codegen-units = 1
2828
[workspace.dependencies]
2929
afl = "0.15"
3030
base64 = "0.22"
31-
bincode = "1.3"
31+
bincode = { version = "2.0", features = ["serde"] }
3232
clap = { version = "4.5", features = ["derive", "cargo"] }
3333
directories = "6.0"
3434
flate2 = "1.0"
3535
iai-callgrind = "0.14"
3636
itertools = "0.14"
37-
mzdata = {version="0.49", default-features = false, features = ["miniz_oxide"]}
37+
mzdata = {version="0.52", default-features = false, features = ["miniz_oxide"]}
3838
ndarray = "0.16"
39-
ordered-float = { version = "4.6", features = ["serde"] }
39+
ordered-float = { version = "5.0", features = ["serde"] }
4040
png = "0.17"
4141
probability = "0.20"
42-
pyo3 = "0.23"
42+
pyo3 = "0.24"
4343
rand = "0.9"
4444
rayon = "1.10"
4545
regex = "1.11"

rustyms-generate-databases/src/atomic_masses.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{io::Write, path::Path};
22

3+
use bincode::config::Configuration;
4+
35
use crate::{system::f64::da, Element, ElementalData};
46

57
use super::csv::parse_csv;
@@ -156,8 +158,14 @@ pub fn build_atomic_masses(out_dir: &Path) {
156158
)
157159
})
158160
.collect();
159-
file.write_all(&bincode::serialize::<ElementalData>(&elements).unwrap())
160-
.unwrap();
161+
file.write_all(
162+
&bincode::serde::encode_to_vec::<ElementalData, Configuration>(
163+
elements,
164+
Configuration::default(),
165+
)
166+
.unwrap(),
167+
)
168+
.unwrap();
161169
}
162170

163171
fn get_ciaaw_number(text: &str) -> Result<f64, String> {

rustyms-generate-databases/src/gnome.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use super::{
77
GnoSubsumption, ModificationId, SimpleModificationInner,
88
};
99

10+
use bincode::config::Configuration;
1011
use thin_vec::ThinVec;
1112

1213
pub fn build_gnome_ontology(out_dir: &Path) {
@@ -57,8 +58,14 @@ pub fn build_gnome_ontology(out_dir: &Path) {
5758
.map(|m| (None, m.id.name.clone(), m.into_mod()))
5859
.collect::<OntologyModificationList>();
5960
println!("Found {} GNOme modifications", final_mods.len());
60-
file.write_all(&bincode::serialize::<OntologyModificationList>(&final_mods).unwrap())
61-
.unwrap();
61+
file.write_all(
62+
&bincode::serde::encode_to_vec::<OntologyModificationList, Configuration>(
63+
final_mods,
64+
Configuration::default(),
65+
)
66+
.unwrap(),
67+
)
68+
.unwrap();
6269
}
6370

6471
fn find_mass(mods: &HashMap<String, GNOmeModification>, mut name: String) -> Option<f64> {

rustyms-generate-databases/src/psi_mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::{io::Write, path::Path};
22

3+
use bincode::config::Configuration;
4+
35
use crate::formula::MolecularFormula;
46

57
use super::{
@@ -17,8 +19,14 @@ pub fn build_psi_mod_ontology(out_dir: &Path) {
1719
let mut file = std::fs::File::create(dest_path).unwrap();
1820
let final_mods = mods.into_iter().map(|m| m.into_mod()).collect::<Vec<_>>();
1921
println!("Found {} PSI-MOD modifications", final_mods.len());
20-
file.write_all(&bincode::serialize::<OntologyModificationList>(&final_mods).unwrap())
21-
.unwrap();
22+
file.write_all(
23+
&bincode::serde::encode_to_vec::<OntologyModificationList, Configuration>(
24+
final_mods,
25+
Configuration::default(),
26+
)
27+
.unwrap(),
28+
)
29+
.unwrap();
2230
}
2331

2432
fn parse_psi_mod() -> Vec<OntologyModification> {

rustyms-generate-databases/src/resid.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use super::{
1010
};
1111
use crate::{formula::MultiChemical, MolecularFormula};
1212

13+
use bincode::config::Configuration;
1314
use roxmltree::*;
1415

1516
pub fn build_resid_ontology(out_dir: &Path) {
@@ -19,8 +20,14 @@ pub fn build_resid_ontology(out_dir: &Path) {
1920
let mut file = std::fs::File::create(dest_path).unwrap();
2021
let final_mods = mods.into_iter().map(|m| m.into_mod()).collect::<Vec<_>>();
2122
println!("Found {} RESID modifications", final_mods.len());
22-
file.write_all(&bincode::serialize::<OntologyModificationList>(&final_mods).unwrap())
23-
.unwrap();
23+
file.write_all(
24+
&bincode::serde::encode_to_vec::<OntologyModificationList, Configuration>(
25+
final_mods,
26+
Configuration::default(),
27+
)
28+
.unwrap(),
29+
)
30+
.unwrap();
2431
}
2532

2633
fn parse_resid() -> Vec<OntologyModification> {

rustyms-generate-databases/src/unimod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{io::Write, iter, path::Path, sync::LazyLock};
22

3+
use bincode::config::Configuration;
34
use regex::Regex;
45

56
use crate::{formula::MolecularFormula, NeutralLoss};
@@ -17,8 +18,14 @@ pub fn build_unimod_ontology(out_dir: &Path) {
1718
let mut file = std::fs::File::create(dest_path).unwrap();
1819
let final_mods = mods.into_iter().map(|m| m.into_mod()).collect::<Vec<_>>();
1920
println!("Found {} Unimod modifications", final_mods.len());
20-
file.write_all(&bincode::serialize::<OntologyModificationList>(&final_mods).unwrap())
21-
.unwrap();
21+
file.write_all(
22+
&bincode::serde::encode_to_vec::<OntologyModificationList, Configuration>(
23+
final_mods,
24+
Configuration::default(),
25+
)
26+
.unwrap(),
27+
)
28+
.unwrap();
2229
}
2330

2431
static REGEX_POSITION: LazyLock<Regex> =

rustyms-generate-databases/src/xlmod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{io::Write, path::Path};
22

3+
use bincode::config::Configuration;
34
use itertools::Itertools;
45
use thin_vec::ThinVec;
56

@@ -24,7 +25,13 @@ pub fn build_xlmod_ontology(out_dir: &Path) {
2425
.collect::<Vec<_>>();
2526
println!("Found {} XLMOD modifications", final_mods.len());
2627
mods_file
27-
.write_all(&bincode::serialize::<OntologyModificationList>(&final_mods).unwrap())
28+
.write_all(
29+
&bincode::serde::encode_to_vec::<OntologyModificationList, Configuration>(
30+
final_mods,
31+
Configuration::default(),
32+
)
33+
.unwrap(),
34+
)
2835
.unwrap();
2936
}
3037

rustyms-generate-imgt/src/main.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod structs;
1616

1717
use crate::shared::*;
1818

19+
use bincode::config::Configuration;
1920
use itertools::Itertools;
2021
use rustyms::{
2122
peptidoform::{Annotation, Region},
@@ -60,7 +61,7 @@ fn main() {
6061

6162
writeln!(
6263
output,
63-
"// @generated\n#![allow(non_snake_case,non_upper_case_globals)]\nuse std::sync::OnceLock;\nuse super::shared::{{Germlines, Species}};"
64+
"// @generated\n#![allow(non_snake_case,non_upper_case_globals)]\nuse std::sync::LazyLock;\nuse bincode::config::Configuration;\nuse super::shared::{{Germlines, Species}};"
6465
)
6566
.unwrap();
6667
writeln!(output, "/// Get the germlines for any of the available species. See the main documentation for which species have which data available.").unwrap();
@@ -93,8 +94,14 @@ _Number of genes / number of alleles_
9394

9495
let mut file =
9596
std::fs::File::create(format!("rustyms/src/imgt/germlines/{species}.bin")).unwrap();
96-
file.write_all(&bincode::serialize::<Germlines>(&germlines).unwrap())
97-
.unwrap();
97+
file.write_all(
98+
&bincode::serde::encode_to_vec::<Germlines, Configuration>(
99+
germlines,
100+
Configuration::default(),
101+
)
102+
.unwrap(),
103+
)
104+
.unwrap();
98105
}
99106
// germlines
100107
writeln!(
@@ -104,7 +111,13 @@ _Number of genes / number of alleles_
104111
.unwrap();
105112

106113
for species in &found_species {
107-
writeln!(output, "Species::{0} => Some(lock_{0}()),", species.ident()).unwrap();
114+
writeln!(
115+
output,
116+
"Species::{} => Some(&{}),",
117+
species.ident(),
118+
species.ident().to_ascii_uppercase()
119+
)
120+
.unwrap();
108121
}
109122
writeln!(output, "_=>None}}}}").unwrap();
110123
// all_germlines
@@ -116,7 +129,7 @@ pub fn all_germlines() -> impl std::iter::Iterator<Item = &'static Germlines> {{
116129
.unwrap();
117130
writeln!(output, "[").unwrap();
118131
for species in &found_species {
119-
writeln!(output, "lock_{}(),", species.ident()).unwrap();
132+
writeln!(output, "&*{},", species.ident().to_ascii_uppercase()).unwrap();
120133
}
121134
writeln!(output, "].into_iter()\n}}").unwrap();
122135
// par_germlines
@@ -131,16 +144,15 @@ pub fn par_germlines() -> impl rayon::prelude::ParallelIterator<Item = &'static
131144
.unwrap();
132145
writeln!(output, "[").unwrap();
133146
for species in &found_species {
134-
writeln!(output, "lock_{}(),", species.ident()).unwrap();
147+
writeln!(output, "&*{},", species.ident().to_ascii_uppercase()).unwrap();
135148
}
136149
writeln!(output, "].into_par_iter()\n}}").unwrap();
137150

138151
for species in &found_species {
139152
writeln!(
140153
output,
141-
"static LOCK_{0}: OnceLock<Germlines> = OnceLock::new();
142-
fn lock_{0}()->&'static Germlines{{LOCK_{0}.get_or_init(|| {{bincode::deserialize(include_bytes!(\"{species}.bin\")).unwrap()}})}}",
143-
species.ident(),
154+
"static {0}: LazyLock<Germlines> = LazyLock::new(|| {{bincode::serde::decode_from_slice::<Germlines, Configuration>(include_bytes!(\"{species}.bin\"),Configuration::default(),).unwrap().0}});",
155+
species.ident().to_ascii_uppercase(),
144156
)
145157
.unwrap();
146158
}

rustyms/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repository = "https://github.com/snijderlab/rustyms"
1313
readme = "README.md"
1414
include = [
1515
"src/**/*",
16+
"images/**/*",
1617
"README.md",
1718
"build.rs",
1819
"benches/**/*",

rustyms/src/databases/elements.dat

-3.78 KB
Binary file not shown.

0 commit comments

Comments
 (0)