jeetsukumaran / DendroPy

A Python library for phylogenetic scripting, simulation, data processing and manipulation.
https://pypi.org/project/DendroPy/.
BSD 3-Clause "New" or "Revised" License
210 stars 61 forks source link

bug in export of new characters from a char mat: need to delete or update char sets #22

Closed mtholder closed 9 years ago

mtholder commented 9 years ago

The indices of characters in a CharSet need to change if you subsample a matrix.

https://github.com/jeetsukumaran/DendroPy/blob/master/dendropy/datamodel/charmatrixmodel.py#L1585-L1610

But export_character_subset returns a new matrix that has a char set with incorrect indices, because it just copies the set from the original matrix.

The easiest workaround would entail just not cloning the character sets.

jeetsukumaran commented 9 years ago

Ok, I think with some careful planning we might be able to migrate the CharacterSubset instances over to the clone, adjusting for missing indices etc. But for now, the simpler/brute-force approach of dropping these in the clone will do unless someone requires this and submits a feature request. Implementing your suggestion in 46cd459.