Skip to content

Commit

Permalink
Merge pull request #134 from tsheils/development
Browse files Browse the repository at this point in the history
updating swagger file and api
  • Loading branch information
tsheils authored Jan 31, 2024
2 parents e6bb198 + 0276314 commit 3c2fbd1
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ install:
- npm install

script:
- nx run ramp:lint
- ng run-many --all --target=test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
- ng run-many --all --target=lint
- ng run-many --all --target=test --no-watch --no-progress --browsers=ChromeHeadlessCI
43 changes: 22 additions & 21 deletions apps/ramp-server/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cors <- function(req, res) {
######
#* Return source version information
#* @serializer unboxedJSON
#* @get /api/source_versions
#* @get /api/source-versions
function() {
version_info <- RaMP::getCurrentRaMPSourceDBVersions(db = rampDB)

Expand All @@ -53,7 +53,7 @@ function() {
######
#* Return database version id
#* @serializer unboxedJSON
#* @get /api/ramp_db_version
#* @get /api/ramp-db-version
function() {
version <- RaMP::getCurrentRaMPVersion(db = rampDB)

Expand All @@ -66,7 +66,7 @@ function() {
######
#* Return current database file url
#* @serializer unboxedJSON
#* @get /api/current_db_file_url
#* @get /api/current-db-file-url
function() {
versionInfo <- RaMP::getCurrentRaMPVersion(db = rampDB, justVersion = FALSE)
dbURL <- unlist(versionInfo$db_sql_url)
Expand Down Expand Up @@ -95,7 +95,7 @@ function() {
####
#* Return counts on entities and their associations
#* @serializer unboxedJSON
#* @get /api/entity_counts
#* @get /api/entity-counts
function() {
entity_counts <- RaMP::getEntityCountsFromSourceDBs(db = rampDB)

Expand All @@ -109,7 +109,7 @@ function() {
#* Return analyte source intersects
#* @param analytetype specifies type of analyte intersects to return, 'metabolites' or 'genes'
#* @param query_scope specifies 'global' or 'mapped-to-pathway'
#* @get /api/analyte_intersects
#* @get /api/analyte-intersects
function(analytetype, query_scope = 'global') {
response <- ""
if(!missing(analytetype)) {
Expand Down Expand Up @@ -209,11 +209,11 @@ function(pathway, analyte_type="both", names_or_ids="names", match="fuzzy", max_
#####
#* Return ontologies from list of metabolites
#* @param metabolite
#* @param NameOrIds one of “name” or “ids”, default “ids"
#* @param namesOrIds one of “name” or “ids”, default “ids"
#* @post /api/ontologies-from-metabolites
function(metabolite, NameOrIds= "ids") {
function(metabolite, namesOrIds= "ids") {
ontologies_df <-
RaMP::getOntoFromMeta(db = rampDB, analytes = metabolite, NameOrIds = NameOrIds)
RaMP::getOntoFromMeta(db = rampDB, analytes = metabolite, NameOrIds = namesOrIds)
if(is.null(ontologies_df)){
ontologies_df<-data.frame()
}
Expand Down Expand Up @@ -328,7 +328,7 @@ function(analyte) {
analytes_df <- RaMP::rampFastCata(
db = rampDB,
analytes = analyte,
NameOrIds = "ids"
namesOrIds = "ids"
)
},
error = function(cond) {
Expand All @@ -339,7 +339,7 @@ function(analyte) {
# analytes_df_names <- tryCatch({
# analytes_df <- RaMP::rampFastCata(
# analytes = analytes,
# NameOrIds = "names"
# namesOrIds = "names"
# )
# },
# error = function(cond) {
Expand Down Expand Up @@ -574,15 +574,15 @@ function(metabolites = '', file = '', biospecimen = '', background = "database")
#' @param humanProtein
#' @param includeTransportRxns
#' @param rxnDirs
#' @post /api/reactions_from_analytes
#' @post /api/reactions-from-analytes
#' @serializer json list(digits = 6)
function(
analytes,
namesOrIds,
onlyHumanMets,
humanProtein,
includeTransportRxns,
rxnDirs
onlyHumanMets = false,
humanProtein = true,
includeTransportRxns = true,
rxnDirs = 'UN'
) {

result = getReactionsForAnalytes(
Expand All @@ -601,7 +601,7 @@ function(
return(
list(
data = result,
function_call = paste0("RaMP::getReactionsForAnalytes(db=RaMPDB, analytes=c(",analyteStr,"), namesOrIDs='ids', onlyHumanMets=",onlyHumanMets,", humanProtein=",humanProtein,", includeTransportRxns=",includeTransportRxns,", rxnDirs=c(",rxnDirs,")")
function_call = paste0("RaMP::getReactionsForAnalytes(db=RaMPDB, analytes=c(",analyteStr,"), namesOrIds='ids', onlyHumanMets=",onlyHumanMets,", humanProtein=",humanProtein,", includeTransportRxns=",includeTransportRxns,", rxnDirs=c(",rxnDirs,")")
)
)
}
Expand All @@ -612,13 +612,14 @@ function(
#' @param analytes
#' @param multiRxnParticipantCount
#' @param humanProtein
#' @post /api/reaction_classes_from_analytes
#' @param concatResults
#' @post /api/reaction-classes-from-analytes
#' @serializer json list(digits = 6)
function(
analytes,
multiRxnParticipantCount,
multiRxnParticipantCount = 1,
humanProtein,
concatResults
concatResults = true
) {
result = getReactionClassesForAnalytes(db=rampDB, analytes=analytes, multiRxnParticipantCount = multiRxnParticipantCount, humanProtein=humanProtein, concatResults=concatResults)

Expand All @@ -639,7 +640,7 @@ function(
#' 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
#' @post /api/get-reaction-participants
#' @serializer json list(digits = 6)
function(
reactionList
Expand All @@ -663,7 +664,7 @@ function(
#' 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
#' @post /api/get-reaction-details
#' @serializer json list(digits = 6)
function(
reactionList
Expand Down
6 changes: 3 additions & 3 deletions apps/ramp-server/ramp_openapi_with_extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ paths:
type: array
items:
type: string
NameOrIds:
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
Expand All @@ -260,7 +260,7 @@ paths:
'hmdb:HMDB0000148',
'ensembl:ENSG00000141510',
]
NameOrIds: 'ids'
namesOrIds: 'ids'
/api/metabolites-from-ontologies:
post:
summary: Return metabolites from ontology
Expand Down Expand Up @@ -397,7 +397,7 @@ paths:
type: array
items:
type: string
NameOrIds:
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ paths:
type: array
items:
type: string
NameOrIds:
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
Expand All @@ -260,7 +260,7 @@ paths:
'hmdb:HMDB0000148',
'ensembl:ENSG00000141510',
]
NameOrIds: 'ids'
namesOrIds: 'ids'
/api/metabolites-from-ontologies:
post:
summary: Return metabolites from ontology
Expand Down Expand Up @@ -393,11 +393,11 @@ paths:
schema:
type: object
properties:
analyte:
analytes:
type: array
items:
type: string
NameOrIds:
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
Expand All @@ -409,6 +409,97 @@ paths:
'hmdb:HMDB0000148',
'ensembl:ENSG00000141510',
]
/api/reactions-from-analytes:
post:
summary: Return reactions from a given list of analytes
responses:
'200':
description: OK
'500':
description: Internal Server Error
requestBody:
description: Retrieve reactions from a list of analytes. IDs should be prepended by ID source (e.g. **hmdb**:C00412).
required: true
content:
application/json:
schema:
type: object
properties:
analytes:
type: array
items:
type: string
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
multiRxnParticipantCount:
type: number
required: false
humanProtein:
type: boolean
required: false
concatResults:
type: boolean
required: false
example:
analytes:
[
'hmdb:HMDB0000033',
'hmdb:HMDB0000052',
'hmdb:HMDB0000094',
'hmdb:HMDBP00789',
'hmdb:HMDBP00283',
'hmdb:HMDBP00284'
]

/api/reaction-classes-from-analytes:
post:
summary: Return reaction classes from a given list of analytes
responses:
'200':
description: OK
'500':
description: Internal Server Error
requestBody:
description: Retrieve reaction classes from a list of analytes. IDs should be prepended by ID source (e.g. **hmdb**:C00412).
required: true
content:
application/json:
schema:
type: object
properties:
analytes:
type: array
items:
type: string
namesOrIds:
type: string
enum: ['name', 'ids']
required: false
onlyHumanMets:
type: boolean
required: false
humanProtein:
type: boolean
required: false
includeTransportRxns:
type: boolean
required: false
rxnDirs:
type: string
enum: ['UN']
required: false
example:
analytes:
[
'hmdb:HMDB0000033',
'hmdb:HMDB0000052',
'hmdb:HMDB0000094',
'hmdb:HMDBP00789',
'hmdb:HMDBP00283',
'hmdb:HMDBP00284'
]
/api/combined-fisher-test:
post:
summary: Return combined Fisher's test results from given list of analytes query results
Expand Down
8 changes: 4 additions & 4 deletions libs/stores/ramp-store/src/lib/+state/ramp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class RampService {

fetchSourceVersions(): Observable<SourceVersion[]> {
return this.http
.get<{ data: SourceVersion[] }>(`${this.url}source_versions`) // ,{responseType: 'text'})
.get<{ data: SourceVersion[] }>(`${this.url}source-versions`) // ,{responseType: 'text'})
.pipe(
map((response) => response.data),
catchError(this.handleError('fetchSourceVersions', [])),
Expand All @@ -68,7 +68,7 @@ export class RampService {

fetchEntityCounts() {
return this.http
.get<{ data: {[p: string]: string}[] }>(`${this.url}entity_counts`) // ,{responseType: 'text'})
.get<{ data: {[p: string]: string}[] }>(`${this.url}entity-counts`) // ,{responseType: 'text'})
.pipe(
map((response: { data: {[p: string]: string}[] }) =>
response.data.map((obj: {[p: string]: string}) => new EntityCount(obj)),
Expand All @@ -92,7 +92,7 @@ export class RampService {

fetchDatabaseUrl() {
return this.http
.get<{ data: string }>(`${this.url}current_db_file_url`)
.get<{ data: string }>(`${this.url}current-db-file-url`)
.pipe(
map((response:{data:string}) => response.data),
// catchError(this.handleError('fetchAnalyteIntersects', [])),
Expand All @@ -110,7 +110,7 @@ export class RampService {
fetchAnalyteIntersects(param: string) {
return this.http
.get<{ data: { id: string; sets: string[]; size: number }[]; }>(
`${this.url}analyte_intersects?analytetype=${param}&query_scope=global`,
`${this.url}analyte-intersects?analytetype=${param}&query_scope=global`,
)
.pipe(
map((response: {data: { id: string; sets: string[]; size: number }[]}) => response.data),
Expand Down

0 comments on commit 3c2fbd1

Please sign in to comment.