From 01ee82d1b4a9334cb44bde8c643133313f2c2e8e Mon Sep 17 00:00:00 2001 From: Yan Wong Date: Fri, 27 Sep 2019 22:21:22 +0100 Subject: [PATCH] Documentation in TableCollection points to ts doc --- python/tskit/tables.py | 51 ++++++++++++++---------------------------- python/tskit/trees.py | 9 ++++---- 2 files changed, 21 insertions(+), 39 deletions(-) diff --git a/python/tskit/tables.py b/python/tskit/tables.py index 35eaf28d6c..dce4a8c03e 100644 --- a/python/tskit/tables.py +++ b/python/tskit/tables.py @@ -1481,6 +1481,8 @@ def simplify( requirements to specify a valid tree sequence (but the resulting tables will). + This is identical to the :class:`TreeSequence` method of the same + name but acts *in place* to alter the data in this :class:`TableCollection`. Please see the :meth:`TreeSequence.simplify` method for a description of the remaining parameters. @@ -1662,15 +1664,12 @@ def deduplicate_sites(self): def delete_sites(self, site_ids, record_provenance=True): """ Remove the specified sites entirely from the sites and mutations tables in this - collection. The site IDs do not need to be in any particular order, and - specifying the same ID multiple times does not have any effect (i.e., calling - ``tables.delete_sites([0, 1, 1])`` has the same effect as calling - ``tables.delete_sites([0, 1])``. + collection. This is identical to the :class:`TreeSequence` method of the same + name but acts *in place* to alter the data in this :class:`TableCollection`. :param list[int] site_ids: A list of site IDs specifying the sites to remove. - :param bool record_provenance: If True, record details of this call to - ``delete_sites`` in the this TableCollection's provenance information. - (Default: True). + :param bool record_provenance: If ``True``, add details of this operation + to the provenance table in this TableCollection. (Default: ``True``). """ keep_sites = np.ones(len(self.sites), dtype=bool) site_ids = util.safe_np_int_cast(site_ids, np.int32) @@ -1722,16 +1721,9 @@ def delete_sites(self, site_ids, record_provenance=True): def delete_intervals(self, intervals, simplify=True, record_provenance=True): """ Delete all information from this set of tables which lies *within* the - specified list of genomic intervals. Edges spanning these intervals - are truncated or deleted, and sites and mutations falling within them are - discarded. - - Note that node IDs may change as a result of this operation, - as by default :meth:`.simplify` is called on this TableCollection to - remove redundant nodes. If you wish to map node IDs onto the same - nodes before and after this method has been called, specify ``simplify=False``. - - See also :meth:`.keep_intervals`. + specified list of genomic intervals. This is identical to the + :class:`TreeSequence` method of the same name but acts *in place* to alter + the data in this :class:`TableCollection`. :param array_like intervals: A list (start, end) pairs describing the genomic intervals to delete. Intervals must be non-overlapping and @@ -1739,9 +1731,8 @@ def delete_intervals(self, intervals, simplify=True, record_provenance=True): 2D numpy array with shape (N, 2), where N is the number of intervals. :param bool simplify: If True, run simplify on this tables so that nodes no longer used are discarded. (Default: True). - :param bool record_provenance: If True, record details of this operation - in the table collection's provenance information. - (Default: True). + :param bool record_provenance: If ``True``, add details of this operation + to the provenance table in this TableCollection. (Default: ``True``). """ self.keep_intervals( util.negate_intervals(intervals, 0, self.sequence_length), @@ -1757,16 +1748,9 @@ def delete_intervals(self, intervals, simplify=True, record_provenance=True): def keep_intervals(self, intervals, simplify=True, record_provenance=True): """ Delete all information from this set of tables which lies *outside* the - specified list of genomic intervals. Edges are truncated to lie within - these intervals, and sites and mutations falling outside these intervals - are discarded. - - Note that node IDs may change as a result of this operation, - as by default :meth:`.simplify` is called on this TableCollection to - remove redundant nodes. If you wish to map node IDs onto the same - nodes before and after this method has been called, specify ``simplify=False``. - - See also :meth:`.delete_intervals`. + specified list of genomic intervals. This is identical to the + :class:`TreeSequence` method of the same name but acts *in place* to alter + the data in this :class:`TableCollection`. :param array_like intervals: A list (start, end) pairs describing the genomic intervals to keep. Intervals must be non-overlapping and @@ -1774,13 +1758,12 @@ def keep_intervals(self, intervals, simplify=True, record_provenance=True): 2D numpy array with shape (N, 2), where N is the number of intervals. :param bool simplify: If True, run simplify on this tables so that nodes no longer used are discarded. (Default: True). - :param bool record_provenance: If True, record details of this operation - in this table collection's provenance information. - (Default: True). + :param bool record_provenance: If ``True``, add details of this operation + to the provenance table in this TableCollection. (Default: ``True``). """ intervals = util.intervals_to_np_array(intervals, 0, self.sequence_length) if len(self.migrations) > 0: - raise ValueError("Migrations not supported by keep_intervals") + raise ValueError("Migrations not supported by keep_ and delete_ intervals") edges = self.edges.copy() self.edges.clear() diff --git a/python/tskit/trees.py b/python/tskit/trees.py index b22826a58a..0dc9903041 100644 --- a/python/tskit/trees.py +++ b/python/tskit/trees.py @@ -3233,9 +3233,8 @@ def delete_intervals(self, intervals, simplify=True, record_provenance=True): 2D numpy array with shape (N, 2), where N is the number of intervals. :param bool simplify: If True, return a simplified tree sequence where nodes no longer used are discarded. (Default: True). - :param bool record_provenance: If True, record details of this operation - in the tree sequence's provenance information. - (Default: True). + :param bool record_provenance: If ``True``, add details of this operation to the + provenance information of the returned tree sequence. (Default: ``True``). :rtype: .TreeSequence """ tables = self.dump_tables() @@ -3262,8 +3261,8 @@ def keep_intervals(self, intervals, simplify=True, record_provenance=True): 2D numpy array with shape (N, 2), where N is the number of intervals. :param bool simplify: If True, return a simplified tree sequence where nodes no longer used are discarded. (Default: True). - :param bool record_provenance: If True, record details of this operation - in the tree sequence's provenance information. + :param bool record_provenance: If True, add details of this operation to the + provenance information of the returned tree sequence. (Default: True). :rtype: .TreeSequence """