-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from DiamondLightSource/pp_sprocs_v2
New versions of upsert sprocs for particle picker and particle classifiation
- Loading branch information
Showing
7 changed files
with
236 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
schemas/ispyb/stored_programs/sp_upsert_particle_classification_v2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
-- Example calls: | ||
-- | ||
-- First create a Movie, a MotionCorrection, a ParticlePicker and a ParticleClassificationGroup: | ||
|
||
/* | ||
SET @mid := NULL; | ||
SET @mcid := NULL; | ||
CALL upsert_movie(@mid, 6017405, NULL, NULL, NULL, NULL, NULL, NULL); | ||
CALL upsert_motion_correction(@mcid, @mid, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
SET @ppid := NULL; | ||
CALL upsert_particle_picker_v2(@ppid, @mcid, NULL, 'pp template 1', 8.1, 151, '/xyzls/bl101/data/2021/bi23456-1/processed/kl_1_summary.jpg'); | ||
SET @pcgid := NULL; | ||
CALL upsert_particle_classification_group(@pcgid, @ppid, NULL, '2D', 1, 1300, 2, 'P222'); | ||
-- Then call this procedure: | ||
SET @pcid := NULL; | ||
CALL upsert_particle_classification_v2(@pcid, @pcgid, 1, '/absolute/path/to/image/file', 1200, 0.91, 2, 3.5, 2.8, 92); | ||
*/ | ||
|
||
DELIMITER ;; | ||
CREATE OR REPLACE DEFINER=`ispyb_root`@`%` PROCEDURE `upsert_particle_classification_v2`( | ||
INOUT p_id int unsigned, | ||
p_particleClassificationGroupId int unsigned, | ||
p_classNumber int unsigned, | ||
p_classImageFullPath varchar(255), | ||
p_particlesPerClass int unsigned, | ||
p_classDistribution float, | ||
p_rotationAccuracy float, | ||
p_translationAccuracy float, | ||
p_estimatedResolution float, | ||
p_overallFourierCompleteness float | ||
) | ||
MODIFIES SQL DATA | ||
COMMENT 'Inserts or updates info about a particle classification (p_id).\nMandatory columns:\nFor insert: p_particleClassificationGroupId\nFor update: p_id \nReturns: Record ID in p_id.' | ||
BEGIN | ||
IF p_id IS NOT NULL OR p_particleClassificationGroupId IS NOT NULL THEN | ||
INSERT INTO ParticleClassification (particleClassificationId, | ||
particleClassificationGroupId, classNumber, classImageFullPath, | ||
particlesPerClass, classDistribution, rotationAccuracy, | ||
translationAccuracy, estimatedResolution, overallFourierCompleteness) | ||
VALUES (p_id, p_particleClassificationGroupId, p_classNumber, | ||
p_classImageFullPath, | ||
p_particlesPerClass, p_classDistribution, p_rotationAccuracy, | ||
p_translationAccuracy, p_estimatedResolution, | ||
p_overallFourierCompleteness) | ||
ON DUPLICATE KEY UPDATE | ||
particleClassificationGroupId = IFNULL(p_particleClassificationGroupId, particleClassificationGroupId), | ||
classNumber = IFNULL(p_classNumber, classNumber), | ||
classImageFullPath = IFNULL(p_classImageFullPath, classImageFullPath), | ||
particlesPerClass = IFNULL(p_particlesPerClass, particlesPerClass), | ||
classDistribution = IFNULL(p_classDistribution, classDistribution), | ||
rotationAccuracy = IFNULL(p_rotationAccuracy, rotationAccuracy), | ||
translationAccuracy = IFNULL(p_translationAccuracy, translationAccuracy), | ||
estimatedResolution = IFNULL(p_estimatedResolution, estimatedResolution), | ||
overallFourierCompleteness = IFNULL(p_overallFourierCompleteness, overallFourierCompleteness); | ||
|
||
IF p_id IS NULL THEN | ||
SET p_id = LAST_INSERT_ID(); | ||
END IF; | ||
ELSE | ||
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument(s) are NULL: p_id OR p_particleClassificationGroupId must be non-NULL.'; | ||
END IF; | ||
END;; | ||
DELIMITER ; |
46 changes: 46 additions & 0 deletions
46
schemas/ispyb/stored_programs/sp_upsert_particle_picker_v2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- Example calls: | ||
-- First create a Movie and a MotionCorrection: | ||
-- | ||
/* | ||
SET @mid := NULL; | ||
SET @mcid := NULL; | ||
CALL upsert_movie(@mid, 6017405, NULL, NULL, NULL, NULL, NULL, NULL); | ||
CALL upsert_motion_correction(@mcid, @mid, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
-- Then call this procedure: | ||
SET @ppid := NULL; | ||
CALL upsert_particle_picker_v2(@ppid, @mcid, NULL, 'pp template 1', 8.1, 151, '/xyzls/bl101/data/2021/bi23456-1/processed/kl_1_summary.jpg'); | ||
*/ | ||
|
||
DELIMITER ;; | ||
CREATE OR REPLACE DEFINER=`ispyb_root`@`%` PROCEDURE `upsert_particle_picker_v2`( | ||
INOUT p_id int(11) unsigned, | ||
p_firstMotionCorrectionId int(11) unsigned, | ||
p_programId int(11) unsigned, | ||
p_particlePickingTemplate varchar(255), | ||
p_particleDiameter float, | ||
p_numberOfParticles int unsigned, | ||
p_summaryImageFullPath varchar(255) | ||
) | ||
MODIFIES SQL DATA | ||
COMMENT 'Inserts or updates info about a particle picker (p_id).\nMandatory columns:\nFor insert: p_firstMotionCorrectionId\nFor update: p_id \nReturns: Record ID in p_id.' | ||
BEGIN | ||
IF p_id IS NOT NULL OR p_firstMotionCorrectionId IS NOT NULL THEN | ||
INSERT INTO ParticlePicker (particlePickerId, firstMotionCorrectionId, programId, particlePickingTemplate, particleDiameter, numberOfParticles, summaryImageFullPath) | ||
VALUES (p_id, p_firstMotionCorrectionId, p_programId, p_particlePickingTemplate, p_particleDiameter, p_numberOfParticles, p_summaryImageFullPath) | ||
ON DUPLICATE KEY UPDATE | ||
firstMotionCorrectionId = IFNULL(p_firstMotionCorrectionId, firstMotionCorrectionId), | ||
programId = IFNULL(p_programId, programId), | ||
particlePickingTemplate = IFNULL(p_particlePickingTemplate, particlePickingTemplate), | ||
particleDiameter = IFNULL(p_particleDiameter, particleDiameter), | ||
numberOfParticles = IFNULL(p_numberOfParticles, numberOfParticles), | ||
summaryImageFullPath = IFNULL(p_summaryImageFullPath, summaryImageFullPath); | ||
|
||
IF p_id IS NULL THEN | ||
SET p_id = LAST_INSERT_ID(); | ||
END IF; | ||
ELSE | ||
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument(s) are NULL: p_id OR p_firstMotionCorrectionId must be non-NULL.'; | ||
END IF; | ||
END;; | ||
DELIMITER ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2021_07_26_AdminVar_bump_version.sql', 'ONGOING'); | ||
|
||
UPDATE AdminVar SET `value` = '1.25.0' WHERE `name` = 'schemaVersion'; | ||
|
||
UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2021_07_26_AdminVar_bump_version.sql'; |