Skip to content

Changing the metadata codec of existing metadata in a tree sequence from binary to JSON #629

Answered by hyanwong
JoshuaGensel asked this question in Q&A
Discussion options

You must be logged in to vote

Here's some dummy code using a schema for individuals (from here) - NB: now edited to reflect the discussion below

import json

basic_schema = tskit.MetadataSchema({'codec': 'json'})
complex_schema = tskit.MetadataSchema({
    'codec': 'json',
    'additionalProperties': False,
    'properties': {'accession': {'description': 'ENA accession number',
                                 'type': 'string'},
                   'pcr': {'description': 'Was PCR used on this sample',
                           'name': 'PCR Used',
                           'type': 'boolean'}},
    'required': ['accession', 'pcr'],
    'type': 'object',
})

# Make an example ts with struct metadata
tables = tskit.Table…

Replies: 4 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@JoshuaGensel
Comment options

@hyanwong
Comment options

@hyanwong
Comment options

@hyanwong
Comment options

@JoshuaGensel
Comment options

Answer selected by JoshuaGensel
Comment options

You must be logged in to vote
3 replies
@hyanwong
Comment options

@JoshuaGensel
Comment options

@hyanwong
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants