def subset_sites(ts, position):
    """
    Return a copy of the specified tree sequence with sites reduced to those
    with positions in the specified list.
    """
    tables = ts.dump_tables()
    lookup = frozenset(position)
    tables.sites.clear()
    tables.mutations.clear()
    for site in ts.sites():
        if site.position in lookup:
            site_id = tables.sites.add_row(site.position, ancestral_state=
                site.ancestral_state, metadata=site.metadata)
            for mutation in site.mutations:
                tables.mutations.add_row(site_id, node=mutation.node,
                    parent=mutation.parent, derived_state=mutation.
                    derived_state, metadata=mutation.metadata)
    return tables.tree_sequence()
