tskit-dev / pyslim

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

check for ts version in operations like pyslim.recapitate( ) #250

Closed petrelharp closed 2 years ago

petrelharp commented 2 years ago

As noted by Chrystelle Delord in the SLiM mailing list, passing a SLiM v3.6 tree sequence to pyslim.recapitate( ) can get a metadata validation error:

"MetadataValidationError: 'slim_id' is a required property

This wouldn't happen if the tree sequence was made into a SlimTreeSequence first, as that would update the metadata to the current version. But, we don't want to require that, so pyslim.recapitate( ) ought to check for version and update if necessary.

Workarounds: do pyslim.recapitate(pyslim.SlimTreeSequence(ts), ...) or just use the current version of SLiM.

bhaller commented 2 years ago

Or it should at least give a better error message, if the full fix turns out to be hard. An error message might really be better than silently updating the tree sequence; the user is using mismatched versions of SLiM and pyslim, which should probably trigger an error. They can do the workaround themselves if they really want to, but my guess is that 99% of the time the version mismatch is unintentional and the best thing to do is to strongly encourage the user to update.

petrelharp commented 2 years ago

This is done already, for instance: here, with the function defined here. Thanks, former self!!