From 3fdc2879cf13f5fde00f5570a9b40aad0587c0a8 Mon Sep 17 00:00:00 2001 From: xperthunter Date: Fri, 3 Feb 2023 12:29:20 -0800 Subject: [PATCH] updates --- cli/specdb | 15 ++++++++------- sql/specdb.sql | 6 +++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cli/specdb b/cli/specdb index 1a023e1..d1c679e 100755 --- a/cli/specdb +++ b/cli/specdb @@ -146,14 +146,15 @@ if sdb.command == 'create': print('Aborting') sys.exit() - if not sdb.backup.endswith('.db'): - print(f'{sdb.backup} does not end in .db') - print('change database name with .db at the end') - print('Aborting') - sys.exit() + if sdb.backup: + if not sdb.backup.endswith('.db'): + print(f'{sdb.backup} does not end in .db') + print('change database name with .db at the end') + print('Aborting') + sys.exit() specdb_path = os.path.abspath(sdb.db) - backup_path = os.path.abspath(sdb.backup) + if sdb.backup: backup_path = os.path.abspath(sdb.backup) if os.path.isfile(specdb_path): print(f'db file {sdb.db} already exists') @@ -169,7 +170,7 @@ if sdb.command == 'create': # initial SQLite database at SPECDB_DB location Create.init(location=specdb_path) - Create.init(location=backup_path) + if sdb.backup: Create.init(location=backup_path) print('db configured and initialized') print('Done') diff --git a/sql/specdb.sql b/sql/specdb.sql index 3e17cf8..6112625 100644 --- a/sql/specdb.sql +++ b/sql/specdb.sql @@ -136,7 +136,7 @@ CREATE TABLE buffer_components ( -- describe the component(s) of a buffer, REQUI buffer_id TEXT NOT NULL, -- `buffer_id` this component goes to, must already be in buffer table, Ex: hn4071 buffer_component TEXT CHECK( length(buffer_component) <= 64 ) NOT NULL, -- name of the component, len <= 64, Ex: NaCl buffer_component_value FLOAT NOT NULL, -- the numeric concentration value of the component, Ex: 100.0 - buffer_component_unit TEXT CHECK( buffer_component_unit in ('mM', '% (v/v)', 'mg/mL') ) NOT NULL, -- unit of concentration, one of (`mM`, `% (v/v)`, `mg/mL`), Ex: mM + buffer_component_unit TEXT CHECK( buffer_component_unit in ('mM', 'uM', 'x', '% (v/v)', 'mg/mL') ) NOT NULL, -- unit of concentration, one of (`mM`, `% (v/v)`, `mg/mL`), Ex: mM isotopic_labeling TEXT DEFAULT "natural abundance", UNIQUE(buffer_id, buffer_component), FOREIGN KEY ([buffer_id]) REFERENCES "buffer" ([buffer_id]) ON DELETE NO ACTION ON UPDATE CASCADE @@ -211,6 +211,10 @@ CREATE TABLE batch_components ( -- describe the purification batches in a pst, R FOREIGN KEY ([batch_id]) REFERENCES "purification_batch" ([batch_id]) ON DELETE NO ACTION ON UPDATE CASCADE ); +INSERT INTO batch_components (pst_id, batch_id, conc, conc_unit) +VALUES + ("NONE", "NONE", "0.0", "mM"); + CREATE TABLE spectrometer ( -- spectrometer information, REQUIRED: `spectrometer_id`, `manufacturer``, `field_strength` id INTEGER PRIMARY KEY NOT NULL, spectrometer_id TEXT CHECK( spectrometer_id NOT LIKE '% %' and length(spectrometer_id) <= 32 ) NOT NULL, -- text identifier for spectrometer, must be unique, no spaces, len <= 32, EX: HU800