Skip to content
Snippets Groups Projects
Commit e1da1bac authored by Jean-Karim Heriche's avatar Jean-Karim Heriche
Browse files

Fix retrieval of phenotypes by well, add options for retrieving wells by compound.

parent ed157c73
No related branches found
No related tags found
No related merge requests found
......@@ -34,7 +34,7 @@ PhenotypeHandle <- R6Class(
#' @param well A Well object
#' @return List of Phenotype objects
get_all_by_well = function(well) {
query <- "SELECT P.* FROM Phenotype AS P, Well_has_Phenotype AS WhP
query <- "SELECT P.*, WhP.value, WhP.unit FROM Phenotype AS P, Well_has_Phenotype AS WhP
WHERE WhP.Plate_ID = ? AND WhP.Well_position = ? AND
WhP.Phenotype_ID = P.ID"
data <- self$dbConnection$get_data(query, list(well$plate_ID, well$position))
......@@ -47,7 +47,9 @@ PhenotypeHandle <- R6Class(
xrefID = df$xrefID,
xrefDB = df$xrefDB,
name = df$name,
description = df$description)
description = df$description,
value = df$value,
unit = df$unit)
phenotypes <- c(phenotypes, ph)
}
return(phenotypes)
......
......@@ -110,7 +110,7 @@ ScreenHandle <- R6Class(
#' @description Store Screen objects in the database
#' @param screen.list A list of Screen objects
#' @param fast.mode (optional, default: FALSE) Speeds up data loading by
#' disabling integrity checks
#' disabling integrity checks.
store = function(screen.list, fast.mode = FALSE) {
if(fast.mode) { # Disable integrity checks
result <- self$dbConnection$execute("SET @@session.unique_checks = 0")
......
......@@ -95,21 +95,42 @@ WellHandle <- R6Class(
#' @description Retrieve all wells where a compound is found
#' @param compound A Compound object
#' @param screen (optional) a Screen object to limit to wells from this screen
#' @param dose (optional) limit to wells with this dose. Unit must also be specified.
#' @param unit (optional) unit for the dose value.
#' @return List of Well objects
get_all_by_compound = function(compound, screen = NULL) {
get_all_by_compound = function(compound, screen = NULL, dose = NULL, unit = NULL) {
if(is.null(screen)) {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC
WHERE WhC.Compound_ID = ?
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position"
data <- self$dbConnection$get_data(query, list(compound$ID))
if(is.null(dose) || is.null(unit)) {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC
WHERE WhC.Compound_ID = ?
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position"
data <- self$dbConnection$get_data(query, list(compound$ID))
} else {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC
WHERE WhC.Compound_ID = ?
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position
AND WhC.dose = ? AND lower(WhC.unit) = ?"
data <- self$dbConnection$get_data(query, list(compound$ID, dose, tolower(unit)))
}
} else {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC, Screen_has_Plate AS ShP
WHERE WhC.Compound_ID = ? AND ShP.Screen_ID = ?
AND ShP.Plate_ID = WhC.Plate_ID
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position"
data <- self$dbConnection$get_data(query, list(compound$ID, screen$ID))
if(is.null(dose) || is.null(unit)) {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC, Screen_has_Plate AS ShP
WHERE WhC.Compound_ID = ? AND ShP.Screen_ID = ?
AND ShP.Plate_ID = WhC.Plate_ID
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position"
data <- self$dbConnection$get_data(query, list(compound$ID, screen$ID))
} else {
query <- "SELECT W.* FROM Well AS W, Well_has_Compound AS WhC, Screen_has_Plate AS ShP
WHERE WhC.Compound_ID = ? AND ShP.Screen_ID = ?
AND ShP.Plate_ID = WhC.Plate_ID
AND WhC.Plate_ID = W.Plate_ID
AND WhC.Well_position = W.position
AND WhC.dose = ? AND lower(WhC.unit) = ?"
data <- self$dbConnection$get_data(query, list(compound$ID, screen$ID, dose, tower(unit))
) }
}
if(length(data$position)>0) {
wells <- list()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment