tskit
tskit copied to clipboard
Add metadata criteria to `TreeSequence` row accessors.
Something like ts.node(metadata=('key', 'subkey', 'value')
would be a handy convenience to have. It would mean things like ts.node(metadata=('name', 'es423'))
would work well or ts.individual(metadata=('accession','id','BOB'))
.
We considered hardcoding for example ts.node(name="es423")
but this would be very restrictive unless we allowed any kwarg
which would then be a name-collision compatibility problem if we ever added any other kwargs to the method.
We considered hardcoding for example ts.node(name="es423") but this would be very restrictive unless we allowed any kwarg which would then be a name-collision compatibility problem if we ever added any other kwargs to the method.
It this is something we do want, could we also have a separate method as syntactic sugar, e.g. node_from_metadata(name="my_node")
?
I'm not sure I see the advantage over say ts.node(metadata_query={'name':'my_node'})
We already have too many methods on the ts class so there has to be a compelling reason to add one.