Skip to content

Commit

Permalink
Merge pull request #44 from standage/fix/entrytype
Browse files Browse the repository at this point in the history
Fix entry type inference by inheriting from object
  • Loading branch information
standage committed Dec 20, 2016
2 parents 30ba88c + 7961148 commit b98cab3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 30 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- CLI implemented using `entry_points` instead of a dedicated script.

### Fixed
- Entry type inference now correct by inheriting from `object`.

## [0.1.0] - 2016-12-16
### Added
- Basic data structures
Expand Down
2 changes: 2 additions & 0 deletions tag/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
except: # pragma: no cover
import builtins
from . import comment
from . import directive
from . import feature
from . import sequence
from . import range
from . import reader
from . import writer
Expand Down
6 changes: 1 addition & 5 deletions tag/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# ------------------------------------------------------------------------------


class Comment():
class Comment(object):
"""
Represents a comment in an annotation (GFF3) file.
Expand All @@ -24,10 +24,6 @@ def __init__(self, data):
assert data.startswith('#')
self._rawdata = data

@property
def entry_type(self):
return 'tag.comment.Comment'

def __repr__(self):
return self._rawdata

Expand Down
6 changes: 1 addition & 5 deletions tag/directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'attribute-ontology', 'source-ontology', 'genome-build']


class Directive():
class Directive(object):
"""
Represents a directive from a GFF3 file.
Expand Down Expand Up @@ -86,10 +86,6 @@ def __init__(self, data):

assert self.dirtype is not None

@property
def entry_type(self):
return 'tag.directive.Directive'

@property
def type(self):
if self.dirtype in dirtypes:
Expand Down
4 changes: 0 additions & 4 deletions tag/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ def __init__(self, data):
assert self.phase in [0, 1, 2], \
'invalid phase "{}"'.format(self.phase)

@property
def entry_type(self):
return 'tag.feature.Feature'

def __str__(self):
"""String representation of the feature, sans children."""
score = '.'
Expand Down
21 changes: 10 additions & 11 deletions tag/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,19 @@ class GFF3Reader():
>>> reader = GFF3Reader(infilename='tests/testdata/pbar-withseq.gff3')
>>> for entry in reader:
... print(entry.entry_type)
tag.directive.Directive
tag.directive.Directive
tag.directive.Directive
tag.comment.Comment
tag.feature.Feature
tag.feature.Feature
tag.feature.Feature
tag.sequence.Sequence
tag.sequence.Sequence
... print(type(entry))
<class 'tag.directive.Directive'>
<class 'tag.directive.Directive'>
<class 'tag.directive.Directive'>
<class 'tag.comment.Comment'>
<class 'tag.feature.Feature'>
<class 'tag.feature.Feature'>
<class 'tag.feature.Feature'>
<class 'tag.sequence.Sequence'>
<class 'tag.sequence.Sequence'>
>>> reader = GFF3Reader(infilename='tests/testdata/pbar-withseq.gff3')
>>> for feature in tag.select.features(reader, type='gene'):
... print(feature.slug)
...
gene@NW_011929623.1[4557, 5749]
gene@NW_011929624.1[3725, 4229]
Expand Down
6 changes: 1 addition & 5 deletions tag/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import re


class Sequence():
class Sequence(object):
"""
Represents a sequence (almost always a nucleotide sequence).
Expand Down Expand Up @@ -39,10 +39,6 @@ def __init__(self, defline, seq):
self.defline = defline
self.seq = seq

@property
def entry_type(self):
return 'tag.sequence.Sequence'

def __str__(self):
return self.defline + '\n' + self.format_seq()

Expand Down

0 comments on commit b98cab3

Please sign in to comment.