Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

added 4 Rhea reaction endpoints #128

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions apps/ramp-server/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,122 @@ function(metabolites = '', file = '', biospecimen = '', background = "database")
}


###########
########### Reaction endpoints
###########



#' Returns reactions associated with input analytes, metabolites and/or genes/proteins.
#' @param analytes
#' @param namesOrIds
#' @param onlyHumanMets
#' @param humanProtein
#' @param includeTransportRxns
#' @param rxnDirs
#' @post /api/reactions_from_analytes
#' @serializer json list(digits = 6)
function(
analytes,
namesOrIds,
onlyHumanMets,
includeTransportRxns,
rxnDirs
) {

result = getReactionsForAnalytes(
db=rampDB,
analytes=analytes,
namesOrIds = 'ids',
onlyHumanMets = onlyHumanMets,
includeTransportRxns,
rxnDirs = rxnDirs
)

analyteStr = RaMP:::listToQueryString(analytes)
rxnDirs = RaMP:::listToQueryString(rxnDirs)

return(
list(
data = result,
function_call = paste0("RaMP::getReactionsForAnalytes(db=RaMPDB, analytes=c(",analyteStr,"), namesOrIDs='ids', onlyHumanMets=",onlyHumanMets,", includeTransportRxns=",includeTransportRxns,", rxnDirs=c(",rxnDirs,")")
)
)
}


#' getReactionClassesForAnalytes returns reactions class and EC numbers for a collection of input compound ids
#'
#' @param analytes
#' @param multiParticipantCount
#' @param humanProtein
#' @post /api/reaction_classes_from_analytes
#' @serializer json list(digits = 6)
function(
analytes,
multiRxnParticipantCount,
humanProtein,
concatResults
) {
result = getReactionClassesForAnalytes(db=rampDB, analytes=analytes, multiRxnParticipantCount = multiRxnParticipantCount, humanProtein=humanProtein, concatResults=concatResults)

analyteStr = RaMP:::listToQueryString(analytes)

return(
list(
data = result,
function_call = paste0("RaMP::getReactionClassesForAnalytes(db=RaMPDB, analytes=c(",analyteStr,"), multiRxnParticipantCount=",multiRxnParticipantCount,", humanProtein=",humanProtein,", concatResults=",concatResults,")")
)
)
}


#' getReactionParticipants returns protein information for a list of reaction ids.
#' This utility method can help extend information from previous queries.
#' For instance, if a user queries for reactions related to a list of metabolites,
#' this method can be used to return proteins on some subset of reaction ids to find related proteins.
#'
#' @param reactionList Rhea reactions ids, such as rhea:38747
#' @post /api/get_reaction_participants
#' @serializer json list(digits = 6)
function(
reactionList
) {
result = getReactionParticipants(db=rampDB, reactionList=reactionList)

rxnStr = RaMP:::listToQueryString(reactionList)

return(
list(
data = result,
function_call = paste0("RaMP::getReactionParticipants(db=RaMPDB, reactionList=c(",rxnStr,"))")
)
)
}


#' getReactionDetails returns general reaction information for a list of reaction ids.
#' This utility methed can help extend information from previous queries.
#' For instance, if a user queries for reactions related to a list of analytes, or filtered on reactions,
#' this method can be used to return general reaction info on some subset of reaction ids of interest.
#'
#' @param reactionList list of reaction ids
#' @post /api/get_reaction_details
#' @serializer json list(digits = 6)
function(
reactionList
) {
result = getReactionDetails(db=rampDB, reactionList=reactionList)

rxnStr = RaMP:::listToQueryString(reactionList)

return(
list(
data = result,
function_call = paste0("RaMP::getReactionDetails(db=RaMPDB, reactionList=c(",rxnStr,"))")
)
)
}



1 change: 1 addition & 0 deletions apps/ramp-server/runRamp.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ramp_api <- plumber::plumb("plumber.R")
source("db.R")
ramp_api$run(host = "127.0.0.1", port = 5762)

Loading