Skip to content

Commit

Permalink
Fix Parent attribute handling for features with multiple parents (#85)
Browse files Browse the repository at this point in the history
* Fix Parent attribute handling for features with multiple parents

* Update change log

* No longer explicitly support python 3.5
  • Loading branch information
standage authored Oct 21, 2020
1 parent a107d27 commit 9447ba8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ branches:
- master
language: python
python:
- 3.5
- 3.6
- 3.7
- 3.8
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.5.1] - 2020-10-21
### Fixed
- A bug with handling of the "Parent" attribute for features with multiple parents (see #85).


## [0.5] - 2020-06-03
### Added
- New `NamedIndex` class for storing and retrieving features by ID (see #82).
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
'Development Status :: 4 - Beta',
'Environment :: Console',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
Expand Down
5 changes: 2 additions & 3 deletions tag/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def add_attribute(self, attrkey, attrvalue, append=False, oldvalue=None):
oldid = self.get_attribute('ID')
for child in self.children:
child.add_attribute('Parent', attrvalue,
oldvalue=oldid)
oldvalue=oldid, append=True)
self._attrs[attrkey] = attrvalue
if self.is_multi:
self.multi_rep._attrs[attrkey] = attrvalue
Expand All @@ -451,8 +451,7 @@ def add_attribute(self, attrkey, attrvalue, append=False, oldvalue=None):

# Handle all other attribute types
if oldvalue is not None:
if attrkey in self._attrs:
assert oldvalue in self._attrs[attrkey]
if attrkey in self._attrs and oldvalue in self._attrs[attrkey]:
del self._attrs[attrkey][oldvalue]
if attrkey not in self._attrs or append is False:
self._attrs[attrkey] = dict()
Expand Down
6 changes: 3 additions & 3 deletions tag/tests/data/eden-mod.gff3
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ ctg123 . CDS 5000 5500 . + 0 ID=cds00002;Parent=mRNA00002;Name=edenprotein.2
ctg123 . CDS 7000 7600 . + 0 ID=cds00002;Parent=mRNA00002;Name=edenprotein.2
ctg123 . mRNA 1300 9000 . + . ID=mRNA3;Parent=g1;Name=EDEN.3
ctg123 . exon 1300 1500 . + . ID=exon00001;Parent=mRNA3
ctg123 . exon 3000 3902 . + . ID=exon00003;Parent=mRNA3
ctg123 . exon 3000 3902 . + . ID=exon00003;Parent=mRNA00001,mRNA3
ctg123 . CDS 3301 3902 . + 0 ID=cds00003;Parent=mRNA3;Name=edenprotein.3
ctg123 . CDS 3391 3902 . + 0 ID=cds00004;Parent=mRNA3;Name=edenprotein.4
ctg123 . exon 5000 5500 . + . ID=exon00004;Parent=mRNA3
ctg123 . exon 5000 5500 . + . ID=exon00004;Parent=mRNA00001,mRNA00002,mRNA3
ctg123 . CDS 5000 5500 . + 1 ID=cds00003;Parent=mRNA3;Name=edenprotein.3
ctg123 . CDS 5000 5500 . + 1 ID=cds00004;Parent=mRNA3;Name=edenprotein.4
ctg123 . CDS 7000 7600 . + 1 ID=cds00003;Parent=mRNA3;Name=edenprotein.3
ctg123 . CDS 7000 7600 . + 1 ID=cds00004;Parent=mRNA3;Name=edenprotein.4
ctg123 . exon 7000 9000 . + . ID=exon00005;Parent=mRNA3
ctg123 . exon 7000 9000 . + . ID=exon00005;Parent=mRNA00001,mRNA00002,mRNA3

0 comments on commit 9447ba8

Please sign in to comment.