cytoscape / cyREST

Core App: REST API module for Cytoscape
https://github.com/cytoscape/cyREST/wiki
MIT License
30 stars 13 forks source link

Support for JSON "Infinity" values for double and integers #99

Open AlexanderPico opened 5 years ago

AlexanderPico commented 5 years ago

Currently, a "Infinity" values within attribute lists of doubles or integers lead to an error:

"Could not parse the input JSON for updating table because: Non-standard token 'Infinity': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow\n at [Source: org.glassfish.jersey.message.internal.EntityInputStream@78b71950; line: 13, column: 24]"

R encodes infinity as Inf. The conversion to JSON appears to be working as it translate these to Infinity. But I suspect the conversion to Java is failing. Java has Double.POSITIVE_INFINITY, but I'm not sure Cytoscape handles this well. I'm not sure in general how we want to handle infinity in Cytoscape.

In the meantime, this means folks coming from Python, R and other scripting languages have to consciously avoid infinity when working with CyREST. Not ideal...

Here's an example that I ran via Swagger to reproduce the error. It assumes you have a network with these GO term nodes in it already...

RCy3::cyrestPUT, HTTP Error Code: 500
 url=http://localhost:1234/v1/networks/3476/tables/defaultnode
 body={
 "key": "id",
"dataKey": "id",
"data": [
{
 "id": "GO:0005215",
"pvalue": 2.606047e-15,
"oddsRatio": 3.502064
},
{
 "id": "GO:0008556",
"pvalue": 2.632002e-15,
"oddsRatio":   Infinity
}
]}
dotasek commented 4 years ago

I'm digging into the code right now to find out how well Cytoscape does this.