Skip to content

Refactor utils.py: add GvfFileReader class - #52

Open
khetherin wants to merge 13 commits into
EBIvariation:mainfrom
khetherin:utils_gvf_reader
Open

Refactor utils.py: add GvfFileReader class#52
khetherin wants to merge 13 commits into
EBIvariation:mainfrom
khetherin:utils_gvf_reader

Conversation

@khetherin

Copy link
Copy Markdown
Collaborator

Another minor PR to refactor utils.py, this time to pull read_in_gvf_header and read_in_gvf_data into a GvfFileReader class.
Files changed:

  • utils.py: added new class GvfFileReader
  • test_utils.py: amend tests
  • convert_gvf_to_vcf_logic.py: calls to test

@khetherin
khetherin requested a review from tcezard July 31, 2026 15:47
if not line.startswith("#"):
f_list = line.rstrip().split("\t")
yield GvfFeatureline(f_list[0], f_list[1], f_list[2], f_list[3], f_list[4], f_list[5], f_list[6], f_list[7], f_list[8])
class GvfFileReader:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are going to create a reader class, you might as well make it pythoninc and implement __iter__ to make it iterable. That would allow you to user is like.

for gvf_line in gvf_file_reader:
   ...

@khetherin
khetherin requested a review from tcezard August 3, 2026 10:09
@khetherin khetherin closed this Aug 3, 2026
@khetherin khetherin reopened this Aug 3, 2026
@khetherin

Copy link
Copy Markdown
Collaborator Author

Merge conflicts have been resolved, ready for review.

Comment on lines +288 to +289
for _ in header_reader:
break # stops at first data line

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this you can also do

Suggested change
for _ in header_reader:
break # stops at first data line
next(header_reader)

Comment thread tests/test_utils.py
# fresh instance
gvf_reader = GvfFileReader(self.input_file)
reader_iter = iter(gvf_reader)
reader_iter = iter(gvf_reader)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reader_iter = iter(gvf_reader)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants