Skip to content

Commit

Permalink
Documentation in TableCollection points to ts doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hyanwong committed Sep 27, 2019
1 parent 4105401 commit 01ee82d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 39 deletions.
51 changes: 17 additions & 34 deletions python/tskit/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1722,26 +1721,18 @@ 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
in increasing order. The list of intervals must be interpretable as a
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),
Expand All @@ -1757,30 +1748,22 @@ 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
in increasing order. The list of intervals must be interpretable as a
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()
Expand Down
9 changes: 4 additions & 5 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
"""
Expand Down

0 comments on commit 01ee82d

Please sign in to comment.