From 027631418292b5e0035aeaf39ccbf3c7ee08a0a9 Mon Sep 17 00:00:00 2001 From: tsheils Date: Wed, 31 Jan 2024 15:18:41 -0500 Subject: [PATCH] updating swagger file and api --- .travis.yml | 4 +- apps/ramp-server/plumber.R | 43 ++++---- .../ramp_openapi_with_extensions.yml | 6 +- .../data/ramp_openapi_with_extensions.yml | 99 ++++++++++++++++++- .../ramp-store/src/lib/+state/ramp.service.ts | 8 +- 5 files changed, 126 insertions(+), 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6719e1..c312d8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/apps/ramp-server/plumber.R b/apps/ramp-server/plumber.R index c62aaa6..01e9714 100644 --- a/apps/ramp-server/plumber.R +++ b/apps/ramp-server/plumber.R @@ -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) @@ -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) @@ -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) @@ -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) @@ -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)) { @@ -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() } @@ -328,7 +328,7 @@ function(analyte) { analytes_df <- RaMP::rampFastCata( db = rampDB, analytes = analyte, - NameOrIds = "ids" + namesOrIds = "ids" ) }, error = function(cond) { @@ -339,7 +339,7 @@ function(analyte) { # analytes_df_names <- tryCatch({ # analytes_df <- RaMP::rampFastCata( # analytes = analytes, - # NameOrIds = "names" + # namesOrIds = "names" # ) # }, # error = function(cond) { @@ -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( @@ -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,")") ) ) } @@ -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) @@ -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 @@ -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 diff --git a/apps/ramp-server/ramp_openapi_with_extensions.yml b/apps/ramp-server/ramp_openapi_with_extensions.yml index cd62845..a8b45f5 100644 --- a/apps/ramp-server/ramp_openapi_with_extensions.yml +++ b/apps/ramp-server/ramp_openapi_with_extensions.yml @@ -248,7 +248,7 @@ paths: type: array items: type: string - NameOrIds: + namesOrIds: type: string enum: ['name', 'ids'] required: false @@ -260,7 +260,7 @@ paths: 'hmdb:HMDB0000148', 'ensembl:ENSG00000141510', ] - NameOrIds: 'ids' + namesOrIds: 'ids' /api/metabolites-from-ontologies: post: summary: Return metabolites from ontology @@ -397,7 +397,7 @@ paths: type: array items: type: string - NameOrIds: + namesOrIds: type: string enum: ['name', 'ids'] required: false diff --git a/libs/features/ramp/ramp-api/src/assets/data/ramp_openapi_with_extensions.yml b/libs/features/ramp/ramp-api/src/assets/data/ramp_openapi_with_extensions.yml index cd62845..6bfd673 100644 --- a/libs/features/ramp/ramp-api/src/assets/data/ramp_openapi_with_extensions.yml +++ b/libs/features/ramp/ramp-api/src/assets/data/ramp_openapi_with_extensions.yml @@ -248,7 +248,7 @@ paths: type: array items: type: string - NameOrIds: + namesOrIds: type: string enum: ['name', 'ids'] required: false @@ -260,7 +260,7 @@ paths: 'hmdb:HMDB0000148', 'ensembl:ENSG00000141510', ] - NameOrIds: 'ids' + namesOrIds: 'ids' /api/metabolites-from-ontologies: post: summary: Return metabolites from ontology @@ -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 @@ -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 diff --git a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts index 9fded72..58bc4f5 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts @@ -59,7 +59,7 @@ export class RampService { fetchSourceVersions(): Observable { 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', [])), @@ -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)), @@ -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', [])), @@ -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),