feature: Volume management for CSV import
Gitea Scan/plate-tool/pipeline/head This commit looks good
Details
Gitea Scan/plate-tool/pipeline/head This commit looks good
Details
Also more likely to be correct elsewhere
This commit is contained in:
parent
7771ce1786
commit
e88fdb0cdd
|
@ -26,6 +26,21 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
|
||||
|
||||
[[package]]
|
||||
name = "android_system_properties"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anymap"
|
||||
version = "1.0.0-beta.2"
|
||||
|
@ -76,6 +91,12 @@ dependencies = [
|
|||
"rustc-demangle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
|
@ -118,6 +139,19 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
"num-traits",
|
||||
"serde",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.7"
|
||||
|
@ -128,6 +162,12 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "core-foundation-sys"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
|
||||
|
||||
[[package]]
|
||||
name = "csv"
|
||||
version = "1.3.0"
|
||||
|
@ -184,6 +224,22 @@ dependencies = [
|
|||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deranged"
|
||||
version = "0.3.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
|
||||
dependencies = [
|
||||
"powerfmt",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
|
@ -467,12 +523,24 @@ version = "0.12.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.11"
|
||||
|
@ -484,6 +552,29 @@ dependencies = [
|
|||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
|
@ -496,7 +587,7 @@ version = "0.3.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfd6201e7c30ccb24773cac7efa6fec1e06189d414b7439ce756a481c8bfbf53"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"indexmap 1.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -506,7 +597,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
"hashbrown 0.12.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.5",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -557,6 +660,21 @@ dependencies = [
|
|||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-conv"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
|
@ -643,6 +761,7 @@ dependencies = [
|
|||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
@ -669,6 +788,12 @@ dependencies = [
|
|||
"yewdux",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "powerfmt"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.17"
|
||||
|
@ -881,6 +1006,36 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_with"
|
||||
version = "3.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"chrono",
|
||||
"hex",
|
||||
"indexmap 1.9.3",
|
||||
"indexmap 2.3.0",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"serde_with_macros",
|
||||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "3.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350"
|
||||
dependencies = [
|
||||
"darling",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.9"
|
||||
|
@ -938,6 +1093,37 @@ dependencies = [
|
|||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885"
|
||||
dependencies = [
|
||||
"deranged",
|
||||
"itoa",
|
||||
"num-conv",
|
||||
"powerfmt",
|
||||
"serde",
|
||||
"time-core",
|
||||
"time-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time-core"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
|
||||
|
||||
[[package]]
|
||||
name = "time-macros"
|
||||
version = "0.2.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf"
|
||||
dependencies = [
|
||||
"num-conv",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.36.0"
|
||||
|
@ -1145,6 +1331,79 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "yew"
|
||||
version = "0.20.0"
|
||||
|
@ -1155,7 +1414,7 @@ dependencies = [
|
|||
"futures",
|
||||
"gloo",
|
||||
"implicit-clone",
|
||||
"indexmap",
|
||||
"indexmap 1.9.3",
|
||||
"js-sys",
|
||||
"prokio",
|
||||
"rustversion",
|
||||
|
|
|
@ -15,3 +15,4 @@ csv = "1.2"
|
|||
getrandom = { version = "0.2", features = ["js"] }
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
lazy_static = "1.4"
|
||||
serde_with = { version = "3.9.0", features = ["json"] }
|
||||
|
|
|
@ -7,10 +7,11 @@ use super::{string_well_to_pt, TransferRecord, read_csv};
|
|||
use crate::plate::{PlateFormat, PlateType};
|
||||
use crate::plate_instances::PlateInstance;
|
||||
use crate::transfer::Transfer;
|
||||
use crate::transfer_volume::{TransferVolume, VolumeMaps};
|
||||
use crate::Well;
|
||||
use crate::transfer_region::{CustomRegion, Region, TransferRegion};
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::collections::{HashSet, HashMap};
|
||||
|
||||
pub struct AutoOutput {
|
||||
pub sources: Vec<PlateInstance>,
|
||||
|
@ -172,6 +173,12 @@ fn get_transfer_for_pair(
|
|||
|
||||
let mut source_wells: HashSet<Well> = HashSet::new();
|
||||
let mut destination_wells: HashSet<Well> = HashSet::new();
|
||||
|
||||
// Volume Hash Maps
|
||||
let mut source_only_volume_map: HashMap<Well, f32> = HashMap::new();
|
||||
let mut destination_only_volume_map: HashMap<Well, f32> = HashMap::new();
|
||||
let mut paired_volume_map: HashMap<(Well, Well), f32> = HashMap::new();
|
||||
|
||||
for record in filtered_records {
|
||||
let source_point_opt = string_well_to_pt(&record.source_well);
|
||||
let destination_point_opt = string_well_to_pt(&record.destination_well);
|
||||
|
@ -182,11 +189,24 @@ fn get_transfer_for_pair(
|
|||
|
||||
source_wells.insert(source_point);
|
||||
destination_wells.insert(destination_point);
|
||||
|
||||
source_only_volume_map.entry(source_point).and_modify(|v| *v += record.volume)
|
||||
.or_insert(record.volume);
|
||||
destination_only_volume_map.entry(destination_point).and_modify(|v| *v += record.volume)
|
||||
.or_insert(record.volume);
|
||||
paired_volume_map.entry((source_point, destination_point)).and_modify(|v| *v += record.volume)
|
||||
.or_insert_with(|| record.volume); // No idea why this one needs to be different
|
||||
}
|
||||
}
|
||||
let source_wells_vec: Vec<Well> = source_wells.into_iter().collect();
|
||||
let destination_wells_vec: Vec<Well> = destination_wells.into_iter().collect();
|
||||
|
||||
let transfer_volume: TransferVolume = TransferVolume::WellMap(VolumeMaps {
|
||||
source_only: source_only_volume_map,
|
||||
destination_only: destination_only_volume_map,
|
||||
paired: paired_volume_map,
|
||||
});
|
||||
|
||||
let custom_region: Region =
|
||||
Region::Custom(CustomRegion::new(source_wells_vec, destination_wells_vec));
|
||||
|
||||
|
@ -201,10 +221,13 @@ fn get_transfer_for_pair(
|
|||
|
||||
let transfer_name = format!("{} to {}", source.name, destination.name);
|
||||
|
||||
Some(Transfer::new(
|
||||
let mut transfer = Transfer::new(
|
||||
source.clone(),
|
||||
destination.clone(),
|
||||
transfer_region,
|
||||
transfer_name,
|
||||
))
|
||||
);
|
||||
transfer.volume = transfer_volume;
|
||||
|
||||
Some(transfer)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::transfer_volume::TransferVolume;
|
||||
use crate::util::*;
|
||||
use crate::{transfer::Transfer, Well};
|
||||
|
||||
|
@ -18,11 +19,22 @@ pub fn transfer_to_records(
|
|||
let map = tr.transfer_region.calculate_map();
|
||||
|
||||
let mut records: Vec<TransferRecord> = vec![];
|
||||
if let TransferVolume::WellMap(wm) = &tr.volume {
|
||||
log::debug!("{:?}\n{}", wm.paired, wm.paired.len());
|
||||
}
|
||||
|
||||
for s_well in source_wells {
|
||||
let dest_wells = map(s_well);
|
||||
if let Some(dest_wells) = dest_wells {
|
||||
for d_well in dest_wells {
|
||||
// Get volume here:
|
||||
let volume: f32 = match &tr.volume {
|
||||
TransferVolume::Single(x) => *x, // If all have the same value, use it everywhere
|
||||
TransferVolume::WellMap(wm) => {
|
||||
*wm.paired.get(&(s_well, d_well)).unwrap_or(&2.5f32)
|
||||
}
|
||||
};
|
||||
|
||||
records.push(TransferRecord {
|
||||
source_plate: src_barcode.to_string(),
|
||||
source_well: format!("{}{}", num_to_letters(s_well.row).unwrap(), s_well.col),
|
||||
|
@ -32,7 +44,7 @@ pub fn transfer_to_records(
|
|||
num_to_letters(d_well.row).unwrap(),
|
||||
d_well.col
|
||||
),
|
||||
volume: tr.volume,
|
||||
volume,
|
||||
concentration: None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ mod auto;
|
|||
mod mangle_headers;
|
||||
mod alternative_formats;
|
||||
|
||||
pub use transfer_record::volume_default;
|
||||
pub use transfer_record::TransferRecord;
|
||||
pub use conversion::*;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ impl From<TransferRecordDeserializeIntermediate> for TransferRecord {
|
|||
}
|
||||
}
|
||||
|
||||
let volume = value.volume.unwrap_or(volume_default());
|
||||
let volume = value.volume.unwrap_or(2.5f32);
|
||||
|
||||
TransferRecord {
|
||||
source_plate: value.source_plate,
|
||||
|
@ -105,8 +105,3 @@ fn numeric_well_to_alphanumeric(input: u16, pformat: PlateFormat) -> Option<Stri
|
|||
|
||||
Some(format!("{}{}", row_str, column))
|
||||
}
|
||||
|
||||
// Why is this here?
|
||||
pub fn volume_default() -> f32 {
|
||||
Transfer::default().volume
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ pub mod plate;
|
|||
pub mod plate_instances;
|
||||
pub mod transfer;
|
||||
pub mod transfer_region;
|
||||
pub mod transfer_volume;
|
||||
pub mod util;
|
||||
|
||||
mod well;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
use crate::transfer_volume;
|
||||
|
||||
use super::plate_instances::*;
|
||||
use super::transfer_region::*;
|
||||
use super::transfer_volume::*;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use uuid::Uuid;
|
||||
|
@ -14,8 +17,7 @@ pub struct Transfer {
|
|||
#[serde(default = "Uuid::now_v7")]
|
||||
pub id: Uuid,
|
||||
pub transfer_region: TransferRegion,
|
||||
#[serde(default = "default_volume")]
|
||||
pub volume: f32,
|
||||
pub volume: TransferVolume,
|
||||
}
|
||||
|
||||
impl Default for Transfer {
|
||||
|
@ -26,15 +28,11 @@ impl Default for Transfer {
|
|||
name: "New Transfer".to_string(),
|
||||
id: Default::default(),
|
||||
transfer_region: Default::default(),
|
||||
volume: default_volume(),
|
||||
volume: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn default_volume() -> f32 {
|
||||
2.5f32
|
||||
}
|
||||
|
||||
impl Transfer {
|
||||
pub fn new(
|
||||
source: PlateInstance,
|
||||
|
@ -48,7 +46,7 @@ impl Transfer {
|
|||
name,
|
||||
id: Uuid::now_v7(),
|
||||
transfer_region: tr,
|
||||
volume: 2.5,
|
||||
volume: transfer_volume::TransferVolume::Single(2.5),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::Well;
|
||||
|
||||
type WellPair = (Well, Well);
|
||||
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
|
||||
pub enum TransferVolume {
|
||||
Single(f32),
|
||||
WellMap(VolumeMaps),
|
||||
}
|
||||
|
||||
#[serde_with::serde_as]
|
||||
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
|
||||
pub struct VolumeMaps {
|
||||
#[serde_as(as = "HashMap<serde_with::json::JsonString, _>")]
|
||||
pub source_only: HashMap<Well, f32>,
|
||||
#[serde_as(as = "HashMap<serde_with::json::JsonString, _>")]
|
||||
pub destination_only: HashMap<Well, f32>,
|
||||
#[serde_as(as = "HashMap<serde_with::json::JsonString, _>")]
|
||||
pub paired: HashMap<WellPair, f32>,
|
||||
}
|
||||
|
||||
impl Default for TransferVolume {
|
||||
fn default() -> Self {
|
||||
TransferVolume::Single(2.5f32)
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ use yew::prelude::*;
|
|||
use yewdux::prelude::*;
|
||||
|
||||
use crate::components::transfer_menu::RegionDisplay;
|
||||
use plate_tool_lib::{transfer::Transfer, transfer_region::Region};
|
||||
use plate_tool_lib::{transfer::Transfer, transfer_region::Region, transfer_volume::TransferVolume};
|
||||
|
||||
use crate::components::states::{CurrentTransfer, MainState};
|
||||
|
||||
|
@ -142,7 +142,7 @@ pub fn on_volume_change_callback(ct_dispatch: Dispatch<CurrentTransfer>) -> Call
|
|||
.expect("Must have been emitted by input");
|
||||
if let Ok(num) = input.value().parse::<f32>() {
|
||||
ct_dispatch.reduce_mut(|state| {
|
||||
state.transfer.volume = num;
|
||||
state.transfer.volume = TransferVolume::Single(num);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -191,7 +191,10 @@ pub fn save_transfer_button_callback_callback(
|
|||
ct_state.transfer.transfer_region.clone(),
|
||||
ct_state.transfer.name.clone(),
|
||||
);
|
||||
new_transfer.volume = ct_state.transfer.volume;
|
||||
|
||||
// This clone is cheap - we know this is just a single value
|
||||
// so cloning f32 will be fast.
|
||||
new_transfer.volume = ct_state.transfer.volume.clone();
|
||||
|
||||
main_dispatch.reduce_mut(|state| {
|
||||
state.transfers.push(new_transfer);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
use plate_tool_lib::transfer_volume::TransferVolume;
|
||||
use yew::prelude::*;
|
||||
use yewdux::prelude::*;
|
||||
|
||||
|
@ -63,12 +65,23 @@ pub fn Plate(props: &PlateProps) -> Html {
|
|||
} else {
|
||||
tooltip_map_temp.insert(well, vec![transfer]);
|
||||
}
|
||||
let temp_volume: f32 = match &transfer.volume {
|
||||
TransferVolume::Single(x) => *x,
|
||||
TransferVolume::WellMap(wm) => {
|
||||
*match props.ptype {
|
||||
PlateType::Source => wm.source_only.get(&well),
|
||||
PlateType::Destination => wm.destination_only.get(&well)
|
||||
}.unwrap_or(&2.5f32)
|
||||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
if let Some(val) = volume_map_temp.get_mut(&well) {
|
||||
*val += transfer.volume;
|
||||
*val += temp_volume
|
||||
} else {
|
||||
volume_map_temp.insert(well, transfer.volume);
|
||||
volume_map_temp.insert(well, temp_volume);
|
||||
}
|
||||
volume_max_temp = f32::max(volume_max_temp, transfer.volume);
|
||||
volume_max_temp = f32::max(volume_max_temp, *volume_map_temp.get(&well).expect("Just added"));
|
||||
}
|
||||
}
|
||||
tooltip_map = tooltip_map_temp;
|
||||
|
|
|
@ -9,6 +9,7 @@ use yewdux::prelude::*;
|
|||
|
||||
use crate::components::callbacks::transfer_menu_callbacks;
|
||||
use plate_tool_lib::transfer_region::Region;
|
||||
use plate_tool_lib::transfer_volume::TransferVolume;
|
||||
use plate_tool_lib::util::{letters_to_num, num_to_letters};
|
||||
|
||||
use super::states::{CurrentTransfer, MainState};
|
||||
|
@ -144,7 +145,10 @@ pub fn TransferMenu() -> Html {
|
|||
<input type="number" name="volume" class="volume_input"
|
||||
min="0" step="0.1"
|
||||
onchange={on_volume_change}
|
||||
value={ct_state.transfer.volume.to_string()}/>
|
||||
value={match ct_state.transfer.volume {
|
||||
TransferVolume::Single(x) => x.to_string(),
|
||||
_ => unreachable!(),
|
||||
}}/>
|
||||
</div>
|
||||
}
|
||||
<div id="controls">
|
||||
|
|
Loading…
Reference in New Issue