fix: Consider well re-usage when calculating volume
Gitea Scan/plate-tool/pipeline/head This commit looks good
Details
Gitea Scan/plate-tool/pipeline/head This commit looks good
Details
This commit is contained in:
parent
a1d4cc74c5
commit
51093f5efd
|
@ -157,13 +157,13 @@ To turn them back on, do the exact same thing.
|
|||
This can be used to verify that all of the wells in a plate will have the same volume
|
||||
transferred at a glance.
|
||||
Wells will be colored based on the sum of all transfers using that plate.
|
||||
In version `0.5.0`, this is best suited for use with CSV imports.
|
||||
|
||||
To toggle this feature, mouse over "Options", then "Styles", then click "Toggle volume heatmap".
|
||||
|
||||
_NOTE:_ In version `<=0.5.0`, if a source well is used multiple times it's volume will
|
||||
be representative of the total usage.
|
||||
|
||||
_NOTE_: The scale for the colors is spaced linearly; if you have a well that is being used
|
||||
significantly more than some others, it may be difficult to see the difference between other wells
|
||||
with more similar volumes.
|
||||
If you have a use case that would benefit from a logarithmic scale here, please let me know.
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Deref;
|
||||
use plate_tool_lib::transfer_region::TransferRegion;
|
||||
use plate_tool_lib::transfer_volume::TransferVolume;
|
||||
use yew::prelude::*;
|
||||
use yewdux::prelude::*;
|
||||
|
@ -75,11 +76,15 @@ pub fn Plate(props: &PlateProps) -> Html {
|
|||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
// Usage to be used as a volume multiplier; should be in [1, U32_MAX]
|
||||
// First convert to f64 (u32 can not fit in f32 directly) and then cast
|
||||
// to round into the closest f32.
|
||||
let usage: f32 = Into::<f64>::into(count_plate_usage(transfer, &well).unwrap_or(1u32).max(1u32)) as f32;
|
||||
|
||||
if let Some(val) = volume_map_temp.get_mut(&well) {
|
||||
*val += temp_volume
|
||||
*val += temp_volume * usage;
|
||||
} else {
|
||||
volume_map_temp.insert(well, temp_volume);
|
||||
volume_map_temp.insert(well, temp_volume * usage);
|
||||
}
|
||||
volume_max_temp = f32::max(volume_max_temp, *volume_map_temp.get(&well).expect("Just added"));
|
||||
}
|
||||
|
@ -270,6 +275,15 @@ pub fn in_rect(corner1: Option<(u8, u8)>, corner2: Option<(u8, u8)>, pt: (u8, u8
|
|||
}
|
||||
}
|
||||
|
||||
fn count_plate_usage(transfer: &Transfer, well: &Well) -> Option<u32> {
|
||||
if let Region::Custom(_) = transfer.transfer_region.source_region {
|
||||
return None;
|
||||
}
|
||||
|
||||
let map = transfer.transfer_region.calculate_map();
|
||||
map(*well).and_then(|list| Some(list.len() as u32))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use wasm_bindgen_test::*;
|
||||
|
|
Loading…
Reference in New Issue