-
Notifications
You must be signed in to change notification settings - Fork 30
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
Clarify how can applications tell which top level element is intended #360
Comments
It looks like phenopacket-tools is going with strategy 3 and 1: i.e the user should specify the element type (strategy 3), otherwise default to strategy 1. I think this should be better documented in the main schema repo so all applications can implement analogous strategies |
A possible extension could be to use a wrapper object which will explicitly provide the type. Also this could allow other structures, such as the Phenopacket GA4GH Pedigree implementation to be added. message PhenopacketWrapper {
oneOf message {
Phenopacket phenopacket = 1;
Family family = 2;
Cohort cohort = 3;
// Ga4ghPedigree pedigree 4; // possible additions might include this
}
} e.g. # this is definitely a phenopacket, because it says so...
---
phenopacket:
id: 12345
subject:
id: "Bart"
phenotypicFeatures:
- type:
id: "HP:0000952"
label: "Jaundice" rather than this # this is probably a phenopacket, because it has a top-level 'subject' field
---
id: 12345
subject:
id: "Bart"
phenotypicFeatures:
- type:
id: "HP:0000952"
label: "Jaundice" |
It is possible to implement "sniffing" - determine the format (YAML, JSON, or Protobuf) and the top-level element, at least to some extent. A simple strategy can test if the document looks like YAML or JSON using file signatures. JSON should start with Sniffing top-level element can also be done to some extent. For JSON and YAML, it is possible to search for discriminatory top-level fields - fields that can be found only in specific elements (e.g. Sniffing can help but it will always be fallible (I think) unless we add a wrapper element. The wrapper would, however, cause other pain.. I implemented the sniffing in phenopacket-tools |
This is a great feature! It might be good to add a --strict flag (or to make this feature optional), because sometimes it is good for software to die if the input is not clear. |
@pnrobinson yeah, the sniffing is turned off if the user is explicit with the input using |
There are 3 top level elements (TLE) in phenopackets:
https://phenopacket-schema.readthedocs.io/en/latest/toplevel.html
All of the examples here:
https://phenopacket-schema.readthedocs.io/en/latest/examples.html
Use a phenopacket as a top level element
However, other repos have examples that use other top level elements; e.g. https://github.com/phenopackets/phenopacket-tools/blob/gh-pages/examples/families/family.yml
If an application is presented with a phenopacket document D, how should the application determine how to interpret it?
None of these seem particularly satisfactory. Perhaps future versions of phenopackets could include a type designator field in each TLE so applications can clearly and unambiguously interpret a document
The text was updated successfully, but these errors were encountered: