use std::{env, fs, io::Write, path::Path};
fn main() {
println!("cargo:rerun-if-changed=data/rep_thresholds.tsv");
let data = fs::read_to_string("data/rep_thresholds.tsv")
.expect("data/rep_thresholds.tsv not found");
let mut builder = phf_codegen::Map::new();
for line in data.lines() {
let mut it = line.split('\t');
match (it.next(), it.next()) {
(Some(rep), Some(thr)) if !rep.is_empty() => {
let v: f32 = thr.trim().parse().expect("bad threshold value");
builder.entry(rep, &format!("{v}f32"));
}
_ => {}
}
}
let out = Path::new(&env::var("OUT_DIR").unwrap()).join("rep_thresholds.rs");
let mut w = fs::File::create(&out).unwrap();
writeln!(
w,
"/// rep -> min pident to accept a hit to that profile (GTDB-calibrated). Absent = 0 (accept).\n\
static REP_THRESHOLDS: phf::Map<&'static str, f32> = {};",
builder.build()
)
.unwrap();
}