Skip to content

Commit

Permalink
Fix bug when '#' is found in gff between different features in same chr
Browse files Browse the repository at this point in the history
  • Loading branch information
nchenche committed Oct 1, 2022
1 parent cadedd2 commit 86c2d4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Orfmap data #
##########################

examples/tests

orfmap-*/orfmap/*
!orfmap-*/orfmap/data/

Expand Down
13 changes: 11 additions & 2 deletions orftrack/orftrack/lib/gff_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def get_overlap(orf_coors=(), other_coors=None):
def set_gff_descr(gff_fname):
global GFF_DESCR
GFF_DESCR = {}

with open(gff_fname, 'rb') as gff_file:
line = gff_file.readline().decode(encoding='utf-8')
while line:
Expand Down Expand Up @@ -603,8 +603,12 @@ def parse(param=None, fasta_hash=None, chr_asked=None, chr_exclude=None):
elif param.types_only:
if element_type in param.types_only:
chromosome.add(gff_element=GffElement(gff_line=line, fasta_chr=fasta_hash[chr_id]))

while True:
line = gff_file.readline()
if not line.startswith("#"):
break

line = gff_file.readline()
if gff_file.tell() == eof:
break
else:
Expand All @@ -614,6 +618,11 @@ def parse(param=None, fasta_hash=None, chr_asked=None, chr_exclude=None):
for chr_name in sorted(gff_data):
gff_data[chr_name].index_cds()

# output all proteins (even reconstructed) in info.log
# for chr_name in sorted(gff_data):
# for pfasta in gff_data[chr_name].proteins_fasta():
# logger.info(pfasta)

return gff_data


Expand Down

0 comments on commit 86c2d4a

Please sign in to comment.