Skip to content

Commit

Permalink
Merge pull request #98 from DiamondLightSource/pp_sprocs_v2
Browse files Browse the repository at this point in the history
New versions of upsert sprocs for particle picker and particle classifiation
  • Loading branch information
KarlLevik committed Jul 26, 2021
2 parents 2dab246 + e9a49f6 commit 4cd3f1f
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 5 deletions.
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ History
Unreleased / master
-------------------

1.25.0 (2021-07-26)
-------------------

New versions of stored procedures:

* ``upsert_particle_picker_v2`` - new parameter ``p_summaryImageFullPath``
* ``upsert_particle_classification_v2`` - new parameter ``p_classDistribution``



1.24.0 (2021-07-23)
-------------------

Expand Down
3 changes: 3 additions & 0 deletions grants/ispyb_processing.sql
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,8 @@ GRANT EXECUTE ON PROCEDURE insert_phasing_analysis_results TO 'ispyb_processing'

GRANT EXECUTE ON PROCEDURE insert_cryoem_initial_model TO 'ispyb_processing';
GRANT EXECUTE ON PROCEDURE upsert_particle_classification TO 'ispyb_processing';
GRANT EXECUTE ON PROCEDURE upsert_particle_classification_v2 TO 'ispyb_processing';
GRANT EXECUTE ON PROCEDURE upsert_particle_classification_group TO 'ispyb_processing';
GRANT EXECUTE ON PROCEDURE upsert_particle_picker TO 'ispyb_processing';
GRANT EXECUTE ON PROCEDURE upsert_particle_picker_v2 TO 'ispyb_processing';

6 changes: 3 additions & 3 deletions schemas/ispyb/lookups.sql

Large diffs are not rendered by default.

107 changes: 105 additions & 2 deletions schemas/ispyb/routines.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9657,6 +9657,64 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `upsert_particle_classification_v2` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE 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 ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `upsert_particle_picker` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -9700,6 +9758,51 @@ DELIMITER ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `upsert_particle_picker_v2` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE 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 ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `upsert_person` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -11027,7 +11130,7 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-07-23 18:38:10
-- Dump completed on 2021-07-26 11:38:57
-- MariaDB dump 10.19 Distrib 10.5.10-MariaDB, for Linux (x86_64)
--
-- Host: 10.88.0.5 Database: ispyb_build
Expand Down Expand Up @@ -11074,4 +11177,4 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2021-07-23 18:38:11
-- Dump completed on 2021-07-26 11:38:57
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 schemas/ispyb/stored_programs/sp_upsert_particle_picker_v2.sql
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 ;
5 changes: 5 additions & 0 deletions schemas/ispyb/updates/2021_07_26_AdminVar_bump_version.sql
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';

0 comments on commit 4cd3f1f

Please sign in to comment.