def readFileNoSideEffects(filepath, format=FileFormats.NEXUS, out=None): """Returns a (list of taxon labels, DataSource, TreeCollection) from the file `filepath`""" _readFileSanityCheck(filepath, format, out) from phycas.ReadNexus import NexusReader reader = NexusReader() reader.readFile(filepath) x = PhyloPackage() x.taxon_labels = reader.taxa matrix = reader.getLastDiscreteMatrix(True) x.characters = DataSource(matrix=matrix, taxon_labels=x.taxon_labels) x.trees = TreeCollection(trees=reader.getTrees(), taxon_labels=x.taxon_labels) return x
def readTrees(filepath, format=FileFormats.NEXUS, out=None): """Returns a (taxon_list, list of TreeDescription objects) (or an empty list if there are no trees) from `filepath` Currently only supports NEXUS and only returns the last data matrix, but this will be generalized to read other formats and return the supermatrix of all data matrices in the file.""" _readFileSanityCheck(filepath, format, out) from phycas.ReadNexus import NexusReader reader = NexusReader() reader.readFile(filepath) return reader.taxa, reader.getTrees()