Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON should be sorted for GIT diff sake #150

Closed
matentzn opened this issue Jan 29, 2019 · 6 comments
Closed

JSON should be sorted for GIT diff sake #150

matentzn opened this issue Jan 29, 2019 · 6 comments

Comments

@matentzn
Copy link
Contributor

The JSON files are not in order so creating large diffs after every re-release. Distracting :P

@matentzn
Copy link
Contributor Author

matentzn commented Aug 5, 2019

Until the obgraphs issue is solved; @althonos can you help me make this work. Given this small example:

{
  "graphs" : [ {
    "nodes" : [ {
      "id" : "http://purl.obolibrary.org/obo/ZECO_0000246",
      "type" : "CLASS",
      "lbl" : "undercrowding"
    }, {
      "id" : "http://purl.obolibrary.org/obo/ZECO_0000125",
      "type" : "CLASS",
      "lbl" : "low fat"
    }, {
      "id" : "http://purl.obolibrary.org/obo/BFO_0000050",
      "type" : "PROPERTY",
      "lbl" : "part of"
    } ],
    "edges" : [ {
      "sub" : "http://purl.obolibrary.org/obo/ZECO_0000123",
      "pred" : "is_a",
      "obj" : "http://purl.obolibrary.org/obo/ZECO_0000122"
    }, {
      "sub" : "http://purl.obolibrary.org/obo/ZECO_0000164",
      "pred" : "is_a",
      "obj" : "http://purl.obolibrary.org/obo/ZECO_0000160"
    } ],
    "id" : "http://purl.obolibrary.org/obo/zeco.json",
    "meta" : {
      "subsets" : [ ],
      "xrefs" : [ ],
      "basicPropertyValues" : [ {
        "pred" : "http://purl.org/dc/elements/1.1/description",
        "val" : "None"
      }, {
        "pred" : "http://purl.org/dc/elements/1.1/title",
        "val" : "Zebrafish Experimental Conditions Ontology"
      }, {
        "pred" : "http://purl.org/dc/terms/license",
        "val" : "CC-BY"
      } ],
      "version" : "http://purl.obolibrary.org/obo/zeco/releases/2019-08-02"
    },
    "equivalentNodesSets" : [ ],
    "logicalDefinitionAxioms" : [ ],
    "domainRangeAxioms" : [ ],
    "propertyChainAxioms" : [ ]
  } ]
}

Can we sort this somhow like this (does not work, cant figure out syntax):

jq '.nodes[].properties|=sort_by(.type,.id)' zeco.json > ../../zeco.json
# Sort only the nodes first by type, then by id

and this:

jq '.edges[].properties|=sort_by(.sub,.pred,.obj)' zeco.json > ../../zeco.json
# Sort only the edges first by sub, then by pred, then by id

Thank you! :)

@matentzn
Copy link
Contributor Author

@althonos I assume from your silence you also dont know :) Anyone else that know a bit of basic jq maybe?

@althonos
Copy link
Contributor

Ha! No I don't know JQuery but I maybe could write a Python (inline?) script to do the same?

@matentzn
Copy link
Contributor Author

Ah, I did not mean jquery, i meant this command line tool called jq that I somehow remember somehow you added for some reason to ODK :P Wrong synapsing in my head. Don't mind either way; since it is just an intermediate solution. Better, of course, would be if we simply fixed fastobo.. :P

@althonos
Copy link
Contributor

althonos commented Aug 19, 2019

Ah, I did not mean jquery, i meant this command line tool called jq that I somehow remember somehow you added for some reason to ODK

not me! 😄

Better, of course, would be if we simply fixed fastobo.. :P

And the OWLAPI as well! That's what ROBOT and owltools are using currently

@matentzn
Copy link
Contributor Author

Lol @althonos I must have been completely out of concept yesterday; I meant obographs, not fastobo. Hhaha. No worries. I will close the issue here since there is already a corresponding one on obographs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants