Skip to content

Commit

Permalink
SP: insert sample image auto score + bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlLevik committed Jan 6, 2020
1 parent f32f465 commit 311493a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/list_of_procs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"**insert_container_inspections**","p_containerId int(11) unsigned, p_scheduleName varchar(10)","Inserts records into ContainerInspection"
"**insert_processing_scaling**","OUT p_id integer unsigned, p_parentId integer unsigned, p_Type1 enum('overall','innerShell','outerShell'), p_Comments1 varchar(255), p_ResolutionLimitLow1 float , p_ResolutionLimitHigh1 float , p_rMerge1 float , p_rMeasWithinIPlusIMinus1 float , p_rMeasAllIPlusIMinus1 float, p_rPimWithinIPlusIMinus1 float, p_rPimAllIPlusIMinus1 float, p_fractionalPartialBias1 float, p_nTotalObservations1 integer, p_nTotalUniqueObservations1 integer, p_meanIOverSigI1 float, p_completeness1 float, p_multiplicity1 float, p_anomalous1 boolean, p_anomalousCompleteness1 float, p_anomalousMultiplicity1 float, p_ccHalf1 float, p_ccAnomalous1 float, p_Type2 enum('overall','innerShell','outerShell'), p_Comments2 varchar(255), p_ResolutionLimitLow2 float, p_ResolutionLimitHigh2 float, p_rMerge2 float, p_rMeasWithinIPlusIMinus2 float, p_rMeasAllIPlusIMinus2 float, p_rPimWithinIPlusIMinus2 float, p_rPimAllIPlusIMinus2 float, p_fractionalPartialBias2 float, p_nTotalObservations2 integer, p_nTotalUniqueObservations2 integer, p_meanIOverSigI2 float, p_completeness2 float, p_multiplicity2 float, p_anomalous2 boolean, p_anomalousCompleteness2 float, p_anomalousMultiplicity2 float, p_ccHalf2 float, p_ccAnomalous2 float, p_Type3 enum('overall','innerShell','outerShell'), p_Comments3 varchar(255), p_ResolutionLimitLow3 float, p_ResolutionLimitHigh3 float, p_rMerge3 float, p_rMeasWithinIPlusIMinus3 float, p_rMeasAllIPlusIMinus3 float, p_rPimWithinIPlusIMinus3 float, p_rPimAllIPlusIMinus3 float, p_fractionalPartialBias3 float, p_nTotalObservations3 integer, p_nTotalUniqueObservations3 integer, p_meanIOverSigI3 float, p_completeness3 float, p_multiplicity3 float, p_anomalous3 boolean, p_anomalousCompleteness3 float, p_anomalousMultiplicity3 float, p_ccHalf3 float, p_ccAnomalous3 float","Inserts 1 row in AutoProcScaling, 3 rows in AutoProcScalingStati"
"**insert_quality_indicators**","OUT p_id int(11) unsigned, p_dataCollectionId int(11) unsigned, p_autoProcProgramId int(10) unsigned, p_imageNumber mediumint(8) unsigned, p_spotTotal int(10), p_inResTotal int(10), p_goodBraggCandidates int(10), p_iceRings int(10), p_method1Res float, p_method2Res float, p_maxUnitCell float, p_pctSaturationTop50Peaks float, p_inResolutionOvrlSpots int(10), p_binPopCutOffMethod2Res float, p_totalIntegratedSignal double, p_driftFactor float","Inserts a row into the image quality indicators table"
"**insert_sample_image_auto_score**","OUT p_id int(11) unsigned, p_imageFullPath varchar(255), p_schemaName varchar(25), p_scoreClass varchar(15), p_probability float","Insert a row with the auto scored probability for a given sample image using a certain class and schema. Returns the ID in p_id."
"**insert_screening**","OUT p_id int(11) unsigned, p_dcgId int(11) unsigned, p_dcId int(11) unsigned, p_programVersion varchar(45), p_shortComments varchar(20), p_comments varchar(255)","Insert a row with info about a screening. Returns the ID in p_id"
"**insert_screening_input**","OUT p_id int(11) unsigned, p_screeningId int(10) unsigned, p_beamX float, p_beamY float, p_rmsErrorLimits float, p_minFractionIndexed float, p_maxFractionRejected float, p_minSignalToNoise float","Insert a row with info about a screening input. Returns the ID i"
"**insert_screening_output**","OUT p_id int(11) unsigned, p_screeningId int(10) unsigned, p_statusDescription varchar(1024), p_rejectedReflections int(10) unsigned, p_resolutionObtained float, p_spotDeviationR float, p_spotDeviationTheta float, p_beamShiftX float, p_beamShiftY float, p_numSpotsFound int(10) unsigned, p_numSpotsUsed int(10) unsigned, p_numSpotsRejected int(10) unsigned, p_mosaicity float, p_iOverSigma float, p_diffractionRings boolean, p_mosaicityEstimated boolean, p_rankingResolution double, p_program varchar(45), p_doseTotal double, p_totalExposureTime double, p_totalRotationRange double, p_totalNumberOfImages int(11), p_rFriedel double, p_indexingSuccess boolean, p_strategySuccess boolean","Insert a row with info about a screening output. Returns the ID"
Expand Down
6 changes: 3 additions & 3 deletions schema/lookups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
--

/*!40000 ALTER TABLE `AdminVar` DISABLE KEYS */;
INSERT INTO `AdminVar` (`varId`, `name`, `value`) VALUES (4,'schemaVersion','1.9.1');
INSERT INTO `AdminVar` (`varId`, `name`, `value`) VALUES (4,'schemaVersion','1.10.0');
/*!40000 ALTER TABLE `AdminVar` ENABLE KEYS */;

--
-- Dumping data for table `SchemaStatus`
--

/*!40000 ALTER TABLE `SchemaStatus` DISABLE KEYS */;
INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'),(73,'2019_08_15_Sleeve.sql','DONE','2019-08-15 08:34:34'),(74,'2019_08_15_AdminVar_bump_version.sql','DONE','2019-08-15 08:57:37'),(75,'2019_08_28_AdminVar_bump_version.sql','DONE','2019-08-28 13:30:13'),(76,'2019_08_30_AdminVar_bump_version.sql','DONE','2019-08-30 11:58:16'),(77,'2019_10_06_BLSampleImage_fk3.sql','DONE','2019-10-06 16:55:44'),(78,'2019_10_08_DiffractionPlan_experimentKind.sql','DONE','2019-10-08 12:47:10'),(79,'2019_11_07_AutoProcProgramAttachment_importanceRank.sql','DONE','2019-11-07 16:35:25'),(80,'2019_11_07_AdminVar_bump_version.sql','DONE','2019-11-07 16:45:44'),(81,'2019_11_08_AdminVar_bump_version.sql','DONE','2019-11-08 16:09:52'),(82,'2019_11_26_v_run_idx1.sql','DONE','2019-11-26 15:00:21'),(83,'2019_12_02_AdminVar_bump_version.sql','DONE','2019-12-02 11:29:05'),(84,'2019_12_02_AdminVar_bump_version_v2.sql','DONE','2019-12-02 18:14:11'),(85,'2020_01_03_BLSampleImage_tables.sql','DONE','2020-01-03 16:05:45');
INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'),(73,'2019_08_15_Sleeve.sql','DONE','2019-08-15 08:34:34'),(74,'2019_08_15_AdminVar_bump_version.sql','DONE','2019-08-15 08:57:37'),(75,'2019_08_28_AdminVar_bump_version.sql','DONE','2019-08-28 13:30:13'),(76,'2019_08_30_AdminVar_bump_version.sql','DONE','2019-08-30 11:58:16'),(77,'2019_10_06_BLSampleImage_fk3.sql','DONE','2019-10-06 16:55:44'),(78,'2019_10_08_DiffractionPlan_experimentKind.sql','DONE','2019-10-08 12:47:10'),(79,'2019_11_07_AutoProcProgramAttachment_importanceRank.sql','DONE','2019-11-07 16:35:25'),(80,'2019_11_07_AdminVar_bump_version.sql','DONE','2019-11-07 16:45:44'),(81,'2019_11_08_AdminVar_bump_version.sql','DONE','2019-11-08 16:09:52'),(82,'2019_11_26_v_run_idx1.sql','DONE','2019-11-26 15:00:21'),(83,'2019_12_02_AdminVar_bump_version.sql','DONE','2019-12-02 11:29:05'),(84,'2019_12_02_AdminVar_bump_version_v2.sql','DONE','2019-12-02 18:14:11'),(85,'2020_01_03_BLSampleImage_tables.sql','DONE','2020-01-03 16:05:45'),(86,'2020_01_06_AdminVar_bump_version.sql','DONE','2020-01-06 11:45:02');
/*!40000 ALTER TABLE `SchemaStatus` ENABLE KEYS */;

--
Expand Down Expand Up @@ -175,4 +175,4 @@ INSERT INTO `BLSampleImageAutoScoreClass` (`blSampleImageAutoScoreClassId`, `blS
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2020-01-03 16:08:39
-- Dump completed on 2020-01-06 11:46:02
48 changes: 45 additions & 3 deletions schema/routines.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- MariaDB dump 10.17 Distrib 10.4.10-MariaDB, for Linux (x86_64)
-- MariaDB dump 10.17 Distrib 10.4.11-MariaDB, for Linux (x86_64)
--
-- Host: localhost Database: ispyb_build
-- ------------------------------------------------------
-- Server version 10.4.10-MariaDB
-- Server version 10.4.11-MariaDB

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand Down Expand Up @@ -1251,6 +1251,48 @@ 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 `insert_sample_image_auto_score` */;
/*!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 `insert_sample_image_auto_score`(
OUT p_id int(11) unsigned,
p_imageFullPath varchar(255),
p_schemaName varchar(25),
p_scoreClass varchar(15),
p_probability float
)
MODIFIES SQL DATA
COMMENT 'Insert a row with the auto scored probability for a given sample image using a certain class and schema. Returns the ID in p_id.'
BEGIN
DECLARE l_blSampleImageId int(11) unsigned;
DECLARE l_blSampleImageAutoScoreClassId tinyint(3) unsigned;

IF p_imageFullPath IS NOT NULL AND p_schemaName IS NOT NULL AND p_scoreClass IS NOT NULL THEN

SELECT max(blSampleImageId) INTO l_blSampleImageId FROM BLSampleImage WHERE imageFullPath = p_imageFullPath;

SELECT blSampleImageAutoScoreClassId INTO l_blSampleImageAutoScoreClassId FROM BLSampleImageAutoScoreClass bsiasc INNER JOIN BLSampleImageAutoScoreSchema bsiass USING(blSampleImageAutoScoreSchemaId)
WHERE bsiasc.scoreClass = p_scoreClass AND bsiass.schemaName = p_schemaName AND bsiass.enabled > 0;

INSERT INTO BLSampleImage_has_AutoScoreClass (blSampleImageId, blSampleImageAutoScoreClassId, probability)
VALUES (l_blSampleImageId, l_blSampleImageAutoScoreClassId, p_probability);

SET p_id = LAST_INSERT_ID();

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 `insert_screening` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -7617,4 +7659,4 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-12-02 11:24:31
-- Dump completed on 2020-01-06 11:39:27
29 changes: 29 additions & 0 deletions schema/stored_programs/sp_insert_sample_image_auto_score.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
DELIMITER ;;
CREATE OR REPLACE PROCEDURE `insert_sample_image_auto_score`(
OUT p_id int(11) unsigned,
p_imageFullPath varchar(255),
p_schemaName varchar(25),
p_scoreClass varchar(15),
p_probability float
)
MODIFIES SQL DATA
COMMENT 'Insert a row with the auto scored probability for a given sample image using a certain class and schema. Returns the ID in p_id.'
BEGIN
DECLARE l_blSampleImageId int(11) unsigned;
DECLARE l_blSampleImageAutoScoreClassId tinyint(3) unsigned;

IF p_imageFullPath IS NOT NULL AND p_schemaName IS NOT NULL AND p_scoreClass IS NOT NULL THEN

SELECT max(blSampleImageId) INTO l_blSampleImageId FROM BLSampleImage WHERE imageFullPath = p_imageFullPath;

SELECT blSampleImageAutoScoreClassId INTO l_blSampleImageAutoScoreClassId FROM BLSampleImageAutoScoreClass bsiasc INNER JOIN BLSampleImageAutoScoreSchema bsiass USING(blSampleImageAutoScoreSchemaId)
WHERE bsiasc.scoreClass = p_scoreClass AND bsiass.schemaName = p_schemaName AND bsiass.enabled > 0;

INSERT INTO BLSampleImage_has_AutoScoreClass (blSampleImageId, blSampleImageAutoScoreClassId, probability)
VALUES (l_blSampleImageId, l_blSampleImageAutoScoreClassId, p_probability);

SET p_id = LAST_INSERT_ID();

END IF;
END;;
DELIMITER ;
5 changes: 5 additions & 0 deletions schema/updates/2020_01_06_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 ('2020_01_06_AdminVar_bump_version.sql', 'ONGOING');

UPDATE AdminVar SET `value` = '1.10.0' WHERE `name` = 'schemaVersion';

UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2020_01_06_AdminVar_bump_version.sql';

0 comments on commit 311493a

Please sign in to comment.