INCATools / ontology-development-kit

Bootstrap an OBO Library ontology
http://incatools.github.io/ontology-development-kit/
BSD 3-Clause "New" or "Revised" License
224 stars 54 forks source link

JSON should be sorted for GIT diff sake #150

Closed matentzn closed 5 years ago

matentzn commented 5 years ago

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

matentzn commented 5 years ago

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 commented 5 years ago

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

althonos commented 5 years ago

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

matentzn commented 5 years ago

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 commented 5 years ago

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! :smile:

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 commented 5 years ago

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.