def setUp(self): self.nex = NexusReader() self.nex.read_string( """Begin data; Dimensions ntax=3 nchar=2; Format datatype=standard symbols="01" gap=-; Charstatelabels 1 char1, 2 char2; Matrix Maori 14 Dutch 25 Latin 36 ;""") self.nex = binarise(self.nex)
if __name__ == '__main__': #set up command-line options from optparse import OptionParser parser = OptionParser(usage="usage: %prog old.nex new.nex") parser.add_option("-1", "--onefile", dest="onefile", action="store_true", default=False, help="One nexus file for each multistate character") options, args = parser.parse_args() try: nexusname = args[0] newnexusname = args[1] except IndexError: print __doc__ print "Author: %s\n" % __author__ parser.print_help() sys.exit() nexus = NexusReader(nexusname) new = binarise(nexus, one_nexus_per_block=options.onefile) if isinstance(new, NexusWriter): new.write_to_file(newnexusname) elif len(new) > 1: newnexusname, ext = os.path.splitext(newnexusname) for nex in new: nex.write_to_file("%s-%s%s" % (newnexusname, nex.clean(nex.characters[0]), ext))
if __name__ == '__main__': #set up command-line options from optparse import OptionParser parser = OptionParser(usage="usage: %prog old.nex new.nex") parser.add_option("-1", "--onefile", dest="onefile", action="store_true", default=False, help="One nexus file for each multistate character") options, args = parser.parse_args() try: nexusname = args[0] newnexusname = args[1] except IndexError: print(__doc__) print("Author: %s\n" % __author__) parser.print_help() sys.exit() nexus = NexusReader(nexusname) new = binarise(nexus, one_nexus_per_block=options.onefile) if isinstance(new, NexusWriter): new.write_to_file(newnexusname) elif len(new) > 1: newnexusname, ext = os.path.splitext(newnexusname) for nex in new: nex.write_to_file("%s-%s%s" % (newnexusname, nex.clean(nex.characters[0]), ext))