mittinatten / freesasa

C-library for calculating Solvent Accessible Surface Areas
http://freesasa.github.io/
MIT License
103 stars 37 forks source link

NaN in json output should be null via json spec? #57

Closed demianriccardi closed 3 years ago

demianriccardi commented 3 years ago

NaN does not appear in the spec(https://www.json.org/json-en.html), but it is output for Glycine sidechain sasa.

e.g.

 {
                  "name":"GLY",
                  "number":"3",
                  "area":{
                    "total":50.257614963200652,
                    "polar":20.988538652337159,
                    "apolar":29.26907631086349,
                    "main-chain":50.257614963200652,
                    "side-chain":0
                  },
                  "relative-area":{
                    "total":61.977574254779441,
                    "polar":47.006805492356463,
                    "apolar":80.321285156046898,
                    "main-chain":61.977574254779441,
                    "side-chain":NaN
                  },
                  "n-atoms":4
                },

workaround is to just s/NaN/null/g on the file

Thank you for creating such a wonderful tool

mittinatten commented 3 years ago

Hi, thanks for pointing this out. I guess undefined would be most correct, but that's apparently also only defined in javascript. I will try to simply not output it for NaN and Infinity.

mittinatten commented 3 years ago

This should be fixed by the last commit in the dev branch.

demianriccardi commented 3 years ago

The fix works. Thanks!