API Client for Monarch Initiative linked biological objects. Source: https://github.com/biolink/biolink-api/
Critical bugs, presumably due to "TODO_OBJECT_MAPPING" in the swagger-codegen for generating r client code. (See versions below.)
Recommend waiting for someone in the swagger codegen community to fix that / those mappings for R clients.
In the meantime, I show below that on the request and response side, the generated code appears OK. So it may be useful to branch off of this for server request and response.
The problems start to occur when we want to look at processed results.
Some of the content is processed into results, but not enough to consider it useful.
This API client was generated by the swagger-codegen project. By using the OpenAPI/Swagger spec from a remote server, you can easily generate an API client.
You'll need the devtools
package in order to build the API.
Make sure you have a proper CRAN repository from which you can download packages.
Install the devtools
package with the following command.
if(!require(devtools)) { install.packages("devtools") }
Make sure you set the working directory to where the code is located. Then execute
library(devtools)
install(".")
(see versions, I commented out some code to generate a partially functional client).
(These examples demonstrate some basic functionality and that the request and response parts of the code seem OK. Problems occur as we see holes in the content as it is parsed into R6 classes.)
running biolink-api from localhost (see versions below for starting the server):
Mimic call to bioentity disease genes in the browser we can get this by:
http://localhost:8888/api/bioentity/disease/OMIM%3A605543/genes/
In the client, we instantiate a BioentityAPI object, and call get_disease_gene_associations() with a valid OMIM for a form of Parkinson's disease.
Note we are using safe encoding of the URL so the ":" in OMIM:605543 is "%3A".
be <- BioentityApi$new()
be$apiClient$basePath <- "http://localhost:8888/api"
x <- be$get_disease_gene_associations(id = "OMIM%3A605543")
Check the content.
x # AssociationResults as R6 class.
x$content$associations$publications$id
x$content$toJSON()
The associations seem far less populated than expected. Either they weren't processed correctly, or we don't know quite how to access the details.
We'd like to be able to see additional information like the evidence graph, but it seems empty.
Check the content from the server, as saved in x$response, see if it is OK and has the full set of details we expected.
httr::content(x$response, "text")
jsonlite::fromJSON(httr::content(x$response, "text"))
jsonlite::fromJSON(httr::content(x$response, "text"), simplifyVector = TRUE)
We saw that all the information we expect is in JSON from server response.
We conclude, there were issues in processing of that resonse into appropriate fields.
Let's try functions and see how much of our expected results we pull out.
# be <- BioentityApi$new("http://localhost:8888/api")
# OR
be <- BioentityApi$new()
be$apiClient$basePath <- "http://localhost:8888/api"
z <- be$get_gene_function_associations("NCBIGene%3A8314")
z # everything looks empty
z$response$status_code # success
It looked empty. Let's examine the URL, paste it into firefox and see what the results look like there.
z$response$request # http://localhost:8888/api/bioentity/gene/NCBIGene%3A8314/function/
Firefox showed the fields were empty. But we weren't expecting that to be the case.
Try an alternate ID of the same gene.
z <- be$get_gene_function_associations("HGNC%3A950") # ok
z$content$toJSON()
We see ids, subject and objects are there. objects$id are GO IDs.
But the evidence graph and other fields are still empty.
Let's try homologs.
be <- BioentityApi$new()
be$apiClient$basePath <- "http://localhost:8888/api"
y <- be$get_gene_homolog_associations("HGNC%3A950")
Get a large traceback here.
The biolink-api package was generated from a locally cloned biolink-api repository Source: https://github.com/biolink/biolink-api/ at commit 39b378db440e9f666c2fb518cd8fde3e68bacb39
Swagger-codegen was obtained from https://oss.sonatype.org/content/repositories/snapshots/io/swagger/swagger-codegen-cli/2.4.0-SNAPSHOT/
Instructions, generating the code:
./start_server.sh
java -jar ../swagger-codegen-cli-2.4.0-20180407.135302-217.jar
generate -i http://localhost:8888/api/swagger.json -l r
We note a number of TODO items in the code. I had already commented out some of those.
# in the project directory
cd ./R/
grep TODO ./*.r
./AssociationResults.r: # facet_pivotObject <- TODO_OBJECT_MAPPING$new()
./AssociationResults.r: # facet_countsObject <- TODO_OBJECT_MAPPING$new()
./AssociationResults.r: #TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
./AssociationResults.r: #self$facet_pivot
<- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(AssociationResultsObject$facet_pivot, auto_unbox = TRUE))
./AssociationResults.r: #TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
./AssociationResults.r: #self$facet_counts
<- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(AssociationResultsObject$facet_counts, auto_unbox = TRUE))
./BioentitysetApi.r:#' get_entity_set_graph_resource TODO Graph object spanning all entities
./IdentifiermapperApi.r:#' get_identifier_mapper TODO maps a list of identifiers from a source to a target
./PubpubsApi.r:#' get_foo TODO Returns list of matches
./SearchResult.r: facet_pivotObject <- TODO_OBJECT_MAPPING$new()
./SearchResult.r: facet_countsObject <- TODO_OBJECT_MAPPING$new()
./SearchResult.r: TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
./SearchResult.r: self$facet_pivot
<- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(SearchResultObject$facet_pivot, auto_unbox = TRUE))
./SearchResult.r: TODO_OBJECT_MAPPINGObject <- TODO_OBJECT_MAPPING$new()
./SearchResult.r: self$facet_counts
<- TODO_OBJECT_MAPPINGObject$fromJSON(jsonlite::toJSON(SearchResultObject$facet_counts, auto_unbox = TRUE))
Checking swagger-codegen github, the source of these are from Swagger-codegen R client codegenerator.
modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/RClientCodegen.java
I commented out the TODO items as seen above to see if I can get a partially functional client. I do, it is partially functional.