@@ -16,6 +16,7 @@ mod structs;
1616
1717use crate :: shared:: * ;
1818
19+ use bincode:: config:: Configuration ;
1920use itertools:: Itertools ;
2021use 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)]\n use std::sync::OnceLock ;\n use super::shared::{{Germlines, Species}};"
64+ "// @generated\n #![allow(non_snake_case,non_upper_case_globals)]\n use std::sync::LazyLock; \n use bincode::config::Configuration ;\n use 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 }
0 commit comments