tskit-dev / pyslim

Tools for dealing with tree sequences coming to and from SLiM.
MIT License
27 stars 23 forks source link

adjust to new individual metadata #207

Closed bhaller closed 2 years ago

bhaller commented 2 years ago

Now that https://github.com/MesserLab/SLiM/issues/152 is fixed, pyslim needs to adjust to the new individual metadata. The two parental pedigree IDs are now part of the metadata record, for file_version "0.7" and later. From the new draft manual:

Each individual will have 40 bytes of binary metadata attached: 8 bytes (int64_t): the SLiM pedigree ID for this individual, as from pedigreeID 8 bytes (int64_t): the SLiM pedigree ID for parent 1, as from pedigreeParentIDs 8 bytes (int64_t): the SLiM pedigree ID for parent 2, as from pedigreeParentIDs 4 bytes (int32_t): the age of this individual, as from age 4 bytes (int32_t): the subpopulation the individual belongs to (i.e., 3 for p3) 4 bytes (int32_t): the sex of the individual (0 for female, 1 for male, -1 for hermaphrodite) 4 bytes (uint32_t): flags; see below. The two parental pedigree ID fields are present only in file version "0.7" and later (i.e., output generated by SLiM 3.7 and later; see below); in file version "0.6" those fields are not present, the individual metadata record is only 24 bytes in length, and parental pedigree IDs are not recorded.

petrelharp commented 2 years ago

The new schema is from here:

{"$schema":"http://json-schema.org/schema#","additionalProperties":false,"codec":"struct","description":"SLiM schema for individual metadata.","examples":[{"age":-1,"flags":0,"pedigree_id":123,"pedigree_p1":12,"pedigree_p2":23,"sex":0,"subpopulation":0}],"flags":{"SLIM_INDIVIDUAL_METADATA_MIGRATED":{"description":"Whether this individual was a migrant, either in the generation when the tree sequence was written out (if the individual was alive then), or in the generation of the last time they were Remembered (if not).","value":1}},"properties":{"age":{"binaryFormat":"i","description":"The age of this individual, either when the tree sequence was written out (if the individual was alive then), or the last time they were Remembered (if not).","index":4,"type":"integer"},"flags":{"binaryFormat":"I","description":"Other information about the individual: see 'flags'.","index":7,"type":"integer"},"pedigree_id":{"binaryFormat":"q","description":"The 'pedigree ID' of this individual in SLiM.","index":1,"type":"integer"},"pedigree_p1":{"binaryFormat":"q","description":"The 'pedigree ID' of this individual's first parent in SLiM.","index":2,"type":"integer"},"pedigree_p2":{"binaryFormat":"q","description":"The 'pedigree ID' of this individual's second parent in SLiM.","index":3,"type":"integer"},"sex":{"binaryFormat":"i","description":"The sex of the individual (0 for female, 1 for male, -1 for hermaphrodite).","index":6,"type":"integer"},"subpopulation":{"binaryFormat":"i","description":"The ID of the subpopulation the individual was part of, either when the tree sequence was written out (if the individual was alive then), or the last time they were Remembered (if not).","index":5,"type":"integer"}},"required":["pedigree_id","pedigree_p1","pedigree_p2","age","subpopulation","sex","flags"],"type":"object"}