Formatting on tests
Gitea Scan/plate-tool/pipeline/head This commit looks good Details

This commit is contained in:
Emilia Allison 2024-11-15 15:28:34 -06:00
parent 04554f634b
commit 3d8445ec82
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
1 changed files with 75 additions and 57 deletions

View File

@ -423,85 +423,85 @@ mod tests {
let transfer1 = TransferRegion {
source_plate: source,
source_region: Region::Rect(Well{ row: 1, col: 1}, Well { row: 1, col: 1 }),
source_region: Region::Rect(Well { row: 1, col: 1 }, Well { row: 1, col: 1 }),
dest_plate: destination,
dest_region: Region::Point(Well {row: 3, col: 3}),
dest_region: Region::Point(Well { row: 3, col: 3 }),
interleave_source: (1, 1),
interleave_dest: (1, 1),
};
let transfer1_map = transfer1.calculate_map();
assert_eq!(
transfer1_map(Well {row: 1, col: 1}),
transfer1_map(Well { row: 1, col: 1 }),
Some(vec! {Well {row: 3, col: 3}}),
"Failed basic shift transfer 1"
);
assert_eq!(
transfer1_map(Well{ row: 1, col: 2}),
transfer1_map(Well { row: 1, col: 2 }),
Some(vec! {Well{ row: 3, col: 4}}),
"Failed basic shift transfer 2"
);
assert_eq!(
transfer1_map(Well{ row: 2, col: 2}),
transfer1_map(Well { row: 2, col: 2 }),
Some(vec! {Well{ row: 4, col: 4}}),
"Failed basic shift transfer 3"
);
let transfer2 = TransferRegion {
source_plate: source,
source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 3, col: 3}),
source_region: Region::Rect(Well { row: 1, col: 1 }, Well { row: 3, col: 3 }),
dest_plate: destination,
dest_region: Region::Point(Well{ row: 3, col: 3}),
dest_region: Region::Point(Well { row: 3, col: 3 }),
interleave_source: (2, 2),
interleave_dest: (1, 1),
};
let transfer2_map = transfer2.calculate_map();
assert_eq!(
transfer2_map(Well{ row: 1, col: 1}),
transfer2_map(Well { row: 1, col: 1 }),
Some(vec! {Well{ row: 3, col: 3}}),
"Failed source interleave, type simple 1"
);
assert_eq!(
transfer2_map(Well{ row: 1, col: 2}),
transfer2_map(Well { row: 1, col: 2 }),
None,
"Failed source interleave, type simple 2"
);
assert_eq!(
transfer2_map(Well{ row: 2, col: 2}),
transfer2_map(Well { row: 2, col: 2 }),
None,
"Failed source interleave, type simple 3"
);
assert_eq!(
transfer2_map(Well{ row: 3, col: 3}),
transfer2_map(Well { row: 3, col: 3 }),
Some(vec! {Well{ row: 4, col: 4}}),
"Failed source interleave, type simple 4"
);
let transfer3 = TransferRegion {
source_plate: source,
source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 3, col: 3}),
source_region: Region::Rect(Well { row: 1, col: 1 }, Well { row: 3, col: 3 }),
dest_plate: destination,
dest_region: Region::Point(Well{ row: 3, col: 3}),
dest_region: Region::Point(Well { row: 3, col: 3 }),
interleave_source: (1, 1),
interleave_dest: (2, 3),
};
let transfer3_map = transfer3.calculate_map();
assert_eq!(
transfer3_map(Well{ row: 1, col: 1}),
transfer3_map(Well { row: 1, col: 1 }),
Some(vec! {Well{ row: 3, col: 3}}),
"Failed destination interleave, type simple 1"
);
assert_eq!(
transfer3_map(Well{ row: 2, col: 1}),
transfer3_map(Well { row: 2, col: 1 }),
Some(vec! {Well{ row: 5, col: 3}}),
"Failed destination interleave, type simple 2"
);
assert_eq!(
transfer3_map(Well{ row: 1, col: 2}),
transfer3_map(Well { row: 1, col: 2 }),
Some(vec! {Well{ row: 3, col: 6}}),
"Failed destination interleave, type simple 3"
);
assert_eq!(
transfer3_map(Well{ row: 2, col: 2}),
transfer3_map(Well { row: 2, col: 2 }),
Some(vec! {Well{ row: 5, col: 6}}),
"Failed destination interleave, type simple 4"
);
@ -514,29 +514,33 @@ mod tests {
let transfer1 = TransferRegion {
source_plate: source,
source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 2, col: 2}),
source_region: Region::Rect(Well { row: 1, col: 1 }, Well { row: 2, col: 2 }),
dest_plate: destination,
dest_region: Region::Rect(Well{ row: 2, col: 2}, Well{row:11, col:11}),
dest_region: Region::Rect(Well { row: 2, col: 2 }, Well { row: 11, col: 11 }),
interleave_source: (1, 1),
interleave_dest: (3, 3),
};
let transfer1_map = transfer1.calculate_map();
assert_eq!(
transfer1_map(Well{ row: 1, col: 1}),
Some(vec! {Well{ row: 2, col: 2}, Well{ row: 2, col: 8}, Well{ row: 8, col: 2}, Well{ row: 8, col: 8}}),
transfer1_map(Well { row: 1, col: 1 }),
Some(
vec! {Well{ row: 2, col: 2}, Well{ row: 2, col: 8}, Well{ row: 8, col: 2}, Well{ row: 8, col: 8}}
),
"Failed type replicate 1"
);
assert_eq!(
transfer1_map(Well{ row: 2, col: 1}),
Some(vec! {Well{ row: 5, col: 2}, Well{ row: 5, col: 8}, Well{ row: 11, col: 2}, Well{ row: 11, col: 8}}),
transfer1_map(Well { row: 2, col: 1 }),
Some(
vec! {Well{ row: 5, col: 2}, Well{ row: 5, col: 8}, Well{ row: 11, col: 2}, Well{ row: 11, col: 8}}
),
"Failed type replicate 1"
);
let transfer2 = TransferRegion {
source_plate: Plate::new(PlateType::Source, PlateFormat::W384),
dest_plate: Plate::new(PlateType::Destination, PlateFormat::W384),
source_region: Region::Rect(Well{ row: 1, col: 1}, Well{ row: 2, col: 3}),
dest_region: Region::Rect(Well{ row: 2, col: 2}, Well{ row: 11, col: 16}),
source_region: Region::Rect(Well { row: 1, col: 1 }, Well { row: 2, col: 3 }),
dest_region: Region::Rect(Well { row: 2, col: 2 }, Well { row: 11, col: 16 }),
interleave_source: (1, 1),
interleave_dest: (2, 2),
};
@ -544,36 +548,43 @@ mod tests {
let transfer2_dest = transfer2.get_destination_wells();
assert_eq!(
transfer2_source,
vec![Well{ row: 1, col: 1}, Well{ row: 1, col: 2}, Well{ row: 1, col: 3}, Well{ row: 2, col: 1}, Well{ row: 2, col: 2}, Well{ row: 2, col: 3}],
vec![
Well { row: 1, col: 1 },
Well { row: 1, col: 2 },
Well { row: 1, col: 3 },
Well { row: 2, col: 1 },
Well { row: 2, col: 2 },
Well { row: 2, col: 3 }
],
"Failed type replicate 2 source"
);
assert_eq!(
transfer2_dest,
vec![
Well{ row: 2, col: 2},
Well{ row: 2, col: 8},
Well{ row: 6, col: 2},
Well{ row: 6, col: 8},
Well{ row: 2, col: 4},
Well{ row: 2, col: 10},
Well{ row: 6, col: 4},
Well{ row: 6, col: 10},
Well{ row: 2, col: 6},
Well{ row: 2, col: 12},
Well{ row: 6, col: 6},
Well{ row: 6, col: 12},
Well{ row: 4, col: 2},
Well{ row: 4, col: 8},
Well{ row: 8, col: 2},
Well{ row: 8, col: 8},
Well{ row: 4, col: 4},
Well{ row: 4, col: 10},
Well{ row: 8, col: 4},
Well{ row: 8, col: 10},
Well{ row: 4, col: 6},
Well{ row: 4, col: 12},
Well{ row: 8, col: 6},
Well{ row: 8, col: 12}
Well { row: 2, col: 2 },
Well { row: 2, col: 8 },
Well { row: 6, col: 2 },
Well { row: 6, col: 8 },
Well { row: 2, col: 4 },
Well { row: 2, col: 10 },
Well { row: 6, col: 4 },
Well { row: 6, col: 10 },
Well { row: 2, col: 6 },
Well { row: 2, col: 12 },
Well { row: 6, col: 6 },
Well { row: 6, col: 12 },
Well { row: 4, col: 2 },
Well { row: 4, col: 8 },
Well { row: 8, col: 2 },
Well { row: 8, col: 8 },
Well { row: 4, col: 4 },
Well { row: 4, col: 10 },
Well { row: 8, col: 4 },
Well { row: 8, col: 10 },
Well { row: 4, col: 6 },
Well { row: 4, col: 12 },
Well { row: 8, col: 6 },
Well { row: 8, col: 12 }
],
"Failed type replicate 2 destination"
);
@ -585,8 +596,8 @@ mod tests {
let transfer1 = TransferRegion {
source_plate: Plate::new(PlateType::Source, PlateFormat::W384),
dest_plate: Plate::new(PlateType::Destination, PlateFormat::W384),
source_region: Region::Rect(Well{ row: 1, col: 4}, Well{ row: 3, col: 7}),
dest_region: Region::Point(Well{ row: 1, col: 9}),
source_region: Region::Rect(Well { row: 1, col: 4 }, Well { row: 3, col: 7 }),
dest_region: Region::Point(Well { row: 1, col: 9 }),
interleave_source: (1, 1),
interleave_dest: (0, 2),
};
@ -596,17 +607,24 @@ mod tests {
// Skipping source check---it's just 12 wells.
assert_eq!(
transfer1_dest,
vec![Well{ row: 1, col: 9}, Well{ row: 1, col: 11}, Well{ row: 1, col: 13}, Well{ row: 1, col: 15}].into_iter().collect(),
vec![
Well { row: 1, col: 9 },
Well { row: 1, col: 11 },
Well { row: 1, col: 13 },
Well { row: 1, col: 15 }
]
.into_iter()
.collect(),
"Failed type pool 1 dest"
);
assert_eq!(
transfer1_map(Well{ row: 2, col: 6}),
Some(vec![Well{ row: 1, col: 13}]),
transfer1_map(Well { row: 2, col: 6 }),
Some(vec![Well { row: 1, col: 13 }]),
"Failed type pool 1 map 1"
);
assert_eq!(
transfer1_map(Well{ row: 3, col: 7}),
Some(vec![Well{ row: 1, col: 15}]),
transfer1_map(Well { row: 3, col: 7 }),
Some(vec![Well { row: 1, col: 15 }]),
"Failed type pool 1 map 2"
);
}