Add Echo Client format support in lib
This commit is contained in:
parent
3fcd526010
commit
194b78430c
|
@ -0,0 +1,26 @@
|
|||
use serde::Serialize;
|
||||
|
||||
use super::TransferRecord;
|
||||
|
||||
// Format preferred by the Echo Client when using the Pick-List function.
|
||||
// Note that this does not export plate info!
|
||||
// Exports of this type should combine all transfers between the two actively selected plates.
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct EchoClientTransferRecord {
|
||||
#[serde(rename = "SrcWell")]
|
||||
pub source_well: String,
|
||||
#[serde(rename = "DestWell")]
|
||||
pub destination_well: String,
|
||||
#[serde(rename = "XferVol")]
|
||||
pub volume: f32,
|
||||
}
|
||||
|
||||
impl From<TransferRecord> for EchoClientTransferRecord {
|
||||
fn from(value: TransferRecord) -> Self {
|
||||
EchoClientTransferRecord {
|
||||
source_well: value.source_well,
|
||||
destination_well: value.destination_well,
|
||||
volume: value.volume,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
use crate::transfer::Transfer;
|
||||
use crate::util::*;
|
||||
|
||||
use super::{TransferRecord, transfer_record::TransferRecordDeserializeIntermediate, mangle_headers::mangle_headers};
|
||||
use super::{alternative_formats::EchoClientTransferRecord, mangle_headers::mangle_headers, transfer_record::TransferRecordDeserializeIntermediate, TransferRecord};
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::error::Error;
|
||||
|
||||
pub fn transfer_to_records(
|
||||
|
@ -44,6 +43,15 @@ pub fn records_to_csv(trs: Vec<TransferRecord>) -> Result<String, Box<dyn Error>
|
|||
Ok(data)
|
||||
}
|
||||
|
||||
pub fn records_to_echo_client_csv(trs: Vec<TransferRecord>) -> Result<String, Box<dyn Error>> {
|
||||
let mut wtr = csv::WriterBuilder::new().from_writer(vec![]);
|
||||
for record in trs {
|
||||
wtr.serialize(Into::<EchoClientTransferRecord>::into(record))?
|
||||
}
|
||||
let data = String::from_utf8(wtr.into_inner()?)?;
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
pub fn string_well_to_pt(input: &str) -> Option<(u8, u8)> {
|
||||
lazy_static! {
|
||||
static ref REGEX: Regex = Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap();
|
||||
|
|
|
@ -2,6 +2,7 @@ mod transfer_record;
|
|||
mod conversion;
|
||||
mod auto;
|
||||
mod mangle_headers;
|
||||
mod alternative_formats;
|
||||
|
||||
pub use transfer_record::volume_default;
|
||||
pub use transfer_record::TransferRecord;
|
||||
|
|
Loading…
Reference in New Issue