Skip to content

Commit

Permalink
Slight improvements to the generic GFLine class and to the to_gff wra…
Browse files Browse the repository at this point in the history
…pper
  • Loading branch information
lucventurini committed Apr 26, 2019
1 parent b81d51f commit ca4a84c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Mikado/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ def to_gff(string, input_format=None):
"""
Function to recognize the input file type (GFF or GTF).
:param string:
:type string: str
:type string: (str|io.TextIOWrapper|io.BytesIO|io.BufferedReader|IO)
:rtype: (Mikado.parsers.GTF.GTF | Mikado.parsers.GFF.GFF3)
"""

# handle = open(string)
if isinstance(string, io.TextIOWrapper):
fname = "-"
elif isinstance(string, (io.BytesIO, io.BufferedReader)):
fname = "-"
string = io.TextIOWrapper(string)
else:
fname = string

Expand Down
18 changes: 18 additions & 0 deletions Mikado/parsers/gfannotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,24 @@ def __lt__(self, other):
else:
return False

def remove_attribute(self, attribute):
"""Method to remove attributes from the internal dictionary."""

if attribute in self.attributes:
del self.attributes[attribute]
try:
self.attribute_order.remove(attribute)
except ValueError:
pass
return

def add_attribute(self, attribute, value):

self.attributes[attribute] = value

if attribute not in self.attribute_order:
self.attribute_order.append(attribute)

def __eq__(self, other):

if self.is_exon is True:
Expand Down

0 comments on commit ca4a84c

Please sign in to comment.