fairtracks / fairtracks_standard

FAIRtracks is a JSON Schema defining a minimal standard for genomic track metadata.

Home Page:https://fairtracks.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add flag for augmented metadata and related validation logic

sveinugu opened this issue · comments

This is the idea of JSON Schema logic I proposed:

    "allOf": [
                {
                    "if": {
                        "4/doc_info/augmented_metadata": true
                    },
                    "then": {
                        "required": [
                            "term_label"
                        ]
                    }
                }
            ]

With further thought, I don't think you can refer to parents in this way the relative JSON Pointers. But I think you instead can do it this way:

"allOf": [
                {
                    "if": {
                        "$ref": "4/doc_info/augmented_metadata"
                    },
                    "then": {
                        "required": [
                            "term_label"
                        ]
                    }
                }
            ]

Here the $ref should insert the subschema referred to, which would be the value 'false' or 'true'

No. The above is incorrect, as the only thing "$ref" does is to copy in the schema, not the data. I actually don't think what I am trying to do here is allowed (I looked into something related before). So the solution is then to rather add all the rules at the topmost level instead. Something like:

"if": {
  "properties": {
    "doc_info": {
      "properties": {
        "augmented_data": {
          "const": true
        }
      }
    }
  }
},
"then": {
  "properties": {
    "technique": {
      "required": [
        "term_label"
      ]
    },
    "target": {
      "properties": {
        "sequence_feature": {
          "properties": {
            "required": [
              "term_label"
            ]
          }
        }
      }
    }
  }
},

And so on, adding each property in the correct place in the tree..

Since this will be very large, one can instead choose to create a separate schema file for this and just "$ref" that in.

Speaking of which, perhaps this should be done for the other such rules also, especially the ones in the end of experiment?