Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/catplus-common/src/graph/namespaces/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace! {
Observation,
optimizationType,
order,
Peak,
peak,
PeakList,
Plate,
ProcessedDataDocument,
Expand Down
7 changes: 7 additions & 0 deletions src/catplus-common/src/models/agilent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ pub struct AgilentProduct {
}

impl InsertIntoGraph for AgilentProduct {
fn get_uri(&self) -> SimpleTerm<'static> {
//same as in synth.rs set_product_uri function
//same as in bravo.rs get_uri function for BravoProduct
let mut uri = cat_resource::ns.clone().as_str().to_owned();
uri.push_str(&hash_identifier(&self.product_identifier));
IriRef::new_unchecked(uri).try_into_term().unwrap()
}
fn insert_into(&self, graph: &mut LightGraph, iri: SimpleTerm) -> anyhow::Result<()> {
for (pred, value) in [
(rdf::type_, &cat::Product.as_simple() as &dyn InsertIntoGraph),
Expand Down
17 changes: 13 additions & 4 deletions src/catplus-common/src/models/bravo.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{
graph::{
insert_into::{InsertIntoGraph, Link},
namespaces::{alloprop, alloqual, allores, cat, purl},
namespaces::{alloprop, alloqual, allores, cat, cat_resource, purl},
utils::hash_identifier,
},
models::{
core::{Chemical, Observation, Plate, Well},
Expand All @@ -13,6 +14,7 @@ use serde::{Deserialize, Serialize};
use sophia::{
api::ns::{rdf, xsd},
inmem::graph::LightGraph,
iri::IriRef,
};
use sophia_api::term::{SimpleTerm, Term};

Expand Down Expand Up @@ -60,7 +62,7 @@ pub struct BravoAction {
pub start_duration: Option<Observation>,
pub ending_duration: Option<Observation>,
pub order: Option<String>,
pub product_identification: ProductIdentification,
pub product_identification: BravoProduct,
}

impl InsertIntoGraph for BravoAction {
Expand Down Expand Up @@ -191,14 +193,21 @@ impl InsertIntoGraph for BravoWell {

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ProductIdentification {
pub struct BravoProduct {
#[serde(rename = "sampleID")]
pub sample_id: String,
// Peak identifier is added on the action, not on the product
pub peak_identifier: String,
}

impl InsertIntoGraph for ProductIdentification {
impl InsertIntoGraph for BravoProduct {
fn get_uri(&self) -> SimpleTerm<'static> {
//same as in synth.rs set_product_uri function
//same as in agilent.rs get_uri function for AgilentProduct
let mut uri = cat_resource::ns.clone().as_str().to_owned();
uri.push_str(&hash_identifier(&self.sample_id));
IriRef::new_unchecked(uri).try_into_term().unwrap()
}
fn insert_into(&self, graph: &mut LightGraph, iri: SimpleTerm) -> anyhow::Result<()> {
for (pred, value) in [
(rdf::type_, &cat::Product.as_simple() as &dyn InsertIntoGraph),
Expand Down
16 changes: 15 additions & 1 deletion src/catplus-common/src/models/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,27 @@ impl InsertIntoGraph for PeakList {
fn insert_into(&self, graph: &mut LightGraph, iri: SimpleTerm) -> anyhow::Result<()> {
for (pred, value) in [
(rdf::type_, &cat::PeakList.as_simple() as &dyn InsertIntoGraph),
(cat::Peak, &self.peak),
(cat::peak, &self.peak),
] {
value.attach_into(
graph,
Link { source_iri: iri.clone(), pred: pred.as_simple(), target_iri: None },
)?;
}
let product = cat::Product.as_simple();
let rdf_type = rdf::type_.as_simple();

let product_object = graph.triples().filter_map(Result::ok).find_map(|[s, p, o]| {
if *p == rdf_type && *o == product {
Some(s.clone())
} else {
None
}
});

if let Some(subject) = product_object {
graph.insert(iri.clone(), cat::hasProduct.as_simple(), subject)?;
}
Ok(())
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/catplus-common/src/models/synth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ pub struct SynthBatch {
pub actions: Vec<SynthAction>,
}

fn set_product_uri(product_id: String) -> SimpleTerm<'static> {
Comment thread
vancauwe marked this conversation as resolved.
//same as in agilent.rs get_uri function for AgilentProduct
//same as in bravo.rs get_uri function for BravoProduct
let mut uri = cat_resource::ns.clone().as_str().to_owned();
uri.push_str(&hash_identifier(&product_id));
IriRef::new_unchecked(uri).try_into_term().unwrap()
}

impl InsertIntoGraph for SynthBatch {
fn get_uri(&self) -> SimpleTerm<'static> {
// build URI based on self.batch_id
Expand Down Expand Up @@ -64,7 +72,8 @@ impl InsertIntoGraph for SynthBatch {
// Create the product_id from container_id and position
let product_id =
format!("{}-{}", &well.has_plate.container_id, well.position);
Comment thread
vancauwe marked this conversation as resolved.
let new_product_uri = well.get_uri();
//let new_product_uri = well.get_uri();
let new_product_uri = set_product_uri(product_id.clone());
for (pred, value) in [
(
rdf::type_,
Expand Down Expand Up @@ -169,7 +178,7 @@ impl InsertIntoGraph for SynthAction {
(allores::AFR_0001606, &self.method_name.as_simple()),
(allores::AFR_0001723, &self.equipment_name.as_simple()),
(cat::subEquipmentName, &self.sub_equipment_name.as_simple()),
(cat::speedInRPM, &self.speed_shaker),
(alloprop::AFX_0000211, &self.speed_shaker),
(cat::temperatureTumbleStirrer, &self.temperature_tumble_stirrer),
(alloprop::AFX_0000211, &self.speed_tumble_stirrer),
(cat::vacuum, &self.vacuum),
Expand Down
Loading