Querying the Aliquots table¶
Volume tracking information in MultiLIMS Warehouse are stored in the aliquot table. The schema of this table is given below.
Note
MultiLIMS Warehouse is a MySQL database.
Therefore, aliquot is a relational schema, that adheres to relational database architecture.
It contains a primary key id (auto incremented) and the attributes are typed with MySQL standard data types.
Top up Management¶
One of the main reasons for the volume tracking data is to be able to query whether there is enough library available for resequencing to increase yield to a suitable amount.
Common Queries¶
Given below are some common SQL queries we think that would be useful for querying the MultiLIMS Warehouse' aliquot table.
Note
Please note that the queries listed here are meant for technical use. To view an in-depth explanation of each query, please visit this page.
-
What is the initial volume of a library identified by the barcode
foo? -
What is the initial volume of a pool identified by the barcode
foo? -
How much of volume left in a library identified by the barcode
foo?- Find out the initial volume of the library.
- Find out the distinct
used_by_barcodefor the given library. - Within each
used_by_barcoderecord, we need to find the latest record - Then, sum the volume of all the latest
used_by_barcoderecords.
SELECT (SELECT volume FROM aliquot WHERE source_barcode = 'foo' -- Change "foo" to the actual barcode AND aliquot_type = 'primary' AND source_type = 'library' ORDER BY id DESC LIMIT 1) - ( SELECT SUM(volume) FROM aliquot a INNER JOIN ( SELECT source_barcode, used_by_barcode, MAX(created_at) AS latest FROM aliquot WHERE source_barcode = 'foo' AND aliquot_type = 'derived' GROUP BY source_barcode, used_by_barcode ) b ON a.source_barcode = b.source_barcode AND a.used_by_barcode = b.used_by_barcode AND a.created_at = b.latest WHERE a.source_barcode = 'foo' AND a.aliquot_type = 'derived' ) AS remaining_volume; -
How much volume of a pool (identified by barcode
foo) is used in a run (identified by barcodebar)?SELECT volume FROM aliquot WHERE source_barcode = "foo" -- Change "foo" to the actual barcode AND source_type = "pool" AND aliquot_type = "derived" AND used_by_type = "run" AND used_by_barcode = "bar" -- Change "bar" to the actual barcode ORDER BY created_at DESC LIMIT 1;Note
Note that we use generated barcodes using
sequencing_kit_box_barcode, the plate number of the plate used for the run and the position of the well.sequencing_kit_box_barcodeis defined inPacbio::Runrelation mentioned in the ERD e.g format4438383464646466464646466464:1:A1. -
How much volume of a library (identified by barcode
foo) is used in a run (identified by barcodebar)? -
How much of volume left in a pool identified by the barcode
foo?SELECT (SELECT volume FROM aliquot WHERE source_barcode = 'foo' -- Change "foo" to the actual barcode AND aliquot_type = 'primary' AND source_type = 'pool' ORDER BY id DESC LIMIT 1) - ( SELECT SUM(volume) FROM aliquot a INNER JOIN ( SELECT source_barcode, used_by_barcode, MAX(created_at) AS latest FROM aliquot WHERE source_barcode = 'foo' AND aliquot_type = 'derived' GROUP BY source_barcode, used_by_barcode ) b ON a.source_barcode = b.source_barcode AND a.used_by_barcode = b.used_by_barcode AND a.created_at = b.latest WHERE a.source_barcode = 'foo' AND a.aliquot_type = 'derived' ) AS remaining_volume;