def test_alternate_range(self): assert parse_deltree('1:10') == \ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] assert parse_deltree('1,3,4:6') == \ [1, 3, 4, 5, 6] assert parse_deltree('1,3,4:6,8,9:10') == \ [1, 3, 4, 5, 6, 8, 9, 10]
def test_error(self): with self.assertRaises(ValueError): parse_deltree("1-x") with self.assertRaises(ValueError): parse_deltree("sausage") with self.assertRaises(ValueError): parse_deltree("first:last")
def test_simple(self): assert parse_deltree('1') == [1] assert parse_deltree('1,2,3') == [1, 2, 3] assert parse_deltree('1,3,5') == [1, 3, 5] assert parse_deltree('1-10') == \ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] assert parse_deltree('1,3,4-6') == \ [1, 3, 4, 5, 6] assert parse_deltree('1,3,4-6,8,9-10') == \ [1, 3, 4, 5, 6, 8, 9, 10]
newnexus = None if options.number: print_site_values(nexus) exit() if options.stats: print_character_stats(nexus) exit() const, unique, zeros, remove = [], [], [], [] if options.constant: const = find_constant_sites(nexus) print("Constant Sites: %s" % ",".join([str(i) for i in const])) if options.unique: unique = find_unique_sites(nexus) print("Unique Sites: %s" % ",".join([str(i) for i in unique])) if options.zeros: zeros = check_zeros(nexus) print("Zero Sites: %s" % ",".join([str(i) for i in zeros])) if options.remove: remove = [int(i) for i in parse_deltree(options.remove)] print("Remove: %s" % ",".join([str(i) for i in zeros])) newnexus = new_nexus_without_sites(nexus, set(const + unique + zeros + remove)) # check for saving if newnexus is not None and newnexusname is not None: newnexus.write_to_file(newnexusname) print("New nexus written to %s" % newnexusname)