Skip to content

Commit

Permalink
Overlap queries
Browse files Browse the repository at this point in the history
  • Loading branch information
standage committed Feb 3, 2017
1 parent a695b68 commit a2acfd7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.3.1] - 2017-02-02
### Fixed
- Range overlap queries accidentally left out of the previous release.

## [0.3.0] - 2017-02-02
### Added
- New convenience functions in the `Range` and `Feature` classes for range and
Expand Down
4 changes: 4 additions & 0 deletions tag/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ def cdslen(self):

return sum([len(c) for c in self.children if c.type == 'CDS'])

def overlap(self, rng):
"""Report whether this feature overlaps with the specified range."""
return self._range.overlap(rng)

def contains(self, rng):
"""Report whether this feature contains the specified range."""
return self._range.contains(rng)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def test_region():
assert f1.start == 999 and f1.end == 2000
assert f1.contains(Range(1500, 1600))
assert f1.contains_point(5) is False
assert f1.overlap(Range(2000, 2001)) is False
assert f1.overlap(Range(1999, 2001)) is True

gff3 = ['contig5', 'vim', 'mRNA', '500', '2500', '.', '+', '.',
'ID=t1;Parent=g1']
Expand Down

0 comments on commit a2acfd7

Please sign in to comment.