Skip to content

Commit

Permalink
Merge branch 'main' of github.com:earth-metabolome-initiative/emi-mon…
Browse files Browse the repository at this point in the history
…orepo
  • Loading branch information
mvisani committed Feb 9, 2024
2 parents 770daf6 + 7839d8e commit 9776524
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 2 deletions.
24 changes: 24 additions & 0 deletions bindings/sirius/src/sirius.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,21 @@ impl<V: Version> Sirius<V> {

// We check that the provided sirius username and password are not empty
if sirius_username.is_empty() {
<<<<<<< HEAD
return Err(format!(concat!(
=======
return Err(concat!(
>>>>>>> 846f0feac57a70f394fa531de8010a2013d16a77
"The sirius username provided in the environment variable SIRIUS_USERNAME is empty. ",
"We expected there to exist a .env file in the current directory ",
"with the SIRIUS_USERNAME variable set to the username of the sirius account. ",
"The variable may also be set in the environment directly, for instance ",
"in the .bashrc file."
<<<<<<< HEAD
)));
=======
).to_string());
>>>>>>> 846f0feac57a70f394fa531de8010a2013d16a77
}

if sirius_password.is_empty() {
Expand Down Expand Up @@ -153,6 +161,22 @@ impl<V: Version> Sirius<V> {
));
}

// We check that the extension of the input file is MGF, in either upper or lower case
let input_file_extension = input_file_path
.extension()
.ok_or_else(|| format!(concat!(
"The input file {:?} does not have an extension. ",
"We expected the input file to have the extension .mgf"
), input_file_path))?;

if input_file_extension.to_string_lossy().to_lowercase() != "mgf" {
return Err(format!(
"The input file {:?} does not have the extension .mgf",
input_file_path
));
}


// Prepare the command
let mut command = Command::new(sirius_path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@
-- items. This table defines the items that are tracked and managed by the system.
-- An item can be movable or immovable.
-- An example of an Item may be a measurement device, a tube potentially containing a sample,
-- or a sample itself.
-- or a sample itself.
CREATE TABLE items (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
description TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
created_by UUID NOT NULL,
updated_by UUID NOT NULL,
project_id UUID NOT NULL,
parent_id UUID,
location_id UUID,
FOREIGN KEY (created_by) REFERENCES users(id),
FOREIGN KEY (updated_by) REFERENCES users(id),
FOREIGN KEY (project_id) REFERENCES projects(id),
FOREIGN KEY (parent_id) REFERENCES items(id),
FOREIGN KEY (item_type_id) REFERENCES item_types(id),
FOREIGN KEY (location_id) REFERENCES locations(id)
);
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ CREATE TABLE procedure_item_requirements (
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (procedure_id, item_category_id),
FOREIGN KEY (item_category_id, unit_id) REFERENCES item_units(item_id, unit_id)
);
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- SQL defining the item_real_quantities table.
-- Each item, being a physical object, has a weight. This table defines the weights of items.
-- The weight of an item may change over time, and be measured using different scales and by
-- different people.
CREATE TABLE item_real_quantities (
id SERIAL PRIMARY KEY,
item_id INTEGER REFERENCES items(id),
weight DECIMAL(10, 2) NOT NULL,
unit_id INTEGER REFERENCES units(id),
sensor_id INTEGER REFERENCES items(id),
measured_at TIMESTAMPTZ NOT NULL DEFAULT now(),
measured_by INTEGER REFERENCES users(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
created_by INTEGER NOT NULL REFERENCES users(id),
updated_by INTEGER NOT NULL REFERENCES users(id),
FOREIGN KEY (item_id, unit_id) REFERENCES items(item_id, unit_id),
FOREIGN KEY (unit_id) REFERENCES real_units(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- SQL defining the item_quantities table.
-- Some items may be counted discretely, as opposed to a weight in grams.
-- This table defines the discrete quantities of items that we have in stock.
-- The quantity of an item may change over time, so multiple quantity entries
-- may be inserted for the same item.
-- While these quantities are discrete, in order to facilitate the semantics of
-- the system, we will still allow for the user to specify the counter unit for
-- the item. For example, a counter unit may be a box, a tube, or a vial.
CREATE TABLE item_discrete_quantities (
id SERIAL PRIMARY KEY,
item_id INTEGER REFERENCES items(id),
quantity INTEGER NOT NULL,
unit_id INTEGER REFERENCES weight_units(id),
measured_at TIMESTAMPTZ NOT NULL DEFAULT now(),
measured_by INTEGER REFERENCES users(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
created_by INTEGER NOT NULL REFERENCES users(id),
updated_by INTEGER NOT NULL REFERENCES users(id),
FOREIGN KEY (item_id, unit_id) REFERENCES item_units(item_id, unit_id),
FOREIGN KEY (unit_id) REFERENCES discrete_units(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- SQL describing the discrete_units table.
-- The discrete_units table is used as the finite set of units that can be used to measure
-- the discrete quantities of items. For example, a box, a tube, or a vial.
CREATE TABLE discrete_units (
id INTEGER PRIMARY KEY,
FOREIGN KEY (id) REFERENCES units(id)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- This file should undo anything in `up.sql`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- SQL describing the real_units table.
-- The real_units table is used as the finite set of units that can be used to measure
-- the real quantities of items. For example, a box, a tube, or a vial.
CREATE TABLE real_units (
id INTEGER PRIMARY KEY,
FOREIGN KEY (id) REFERENCES units(id)
);

0 comments on commit 9776524

Please sign in to comment.