tskit icon indicating copy to clipboard operation
tskit copied to clipboard

Add metadata criteria to `TreeSequence` row accessors.

Open benjeffery opened this issue 2 years ago • 2 comments

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.

benjeffery avatar May 04 '22 14:05 benjeffery

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")?

hyanwong avatar Sep 27 '22 07:09 hyanwong

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.

benjeffery avatar Sep 27 '22 10:09 benjeffery