Skip to content

Cleanup#11

Merged
khetherin merged 19 commits intoEBIvariation:mainfrom
khetherin:cleanup
Oct 22, 2025
Merged

Cleanup#11
khetherin merged 19 commits intoEBIvariation:mainfrom
khetherin:cleanup

Conversation

@khetherin
Copy link
Collaborator

changes made to clean up

@khetherin khetherin requested a review from tcezard October 17, 2025 15:22
Copy link
Member

@tcezard tcezard left a comment

Choose a reason for hiding this comment

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

This is a good improvement already. It makes the code cleaner.
I've added a few suggestions that you can address right away or in the next PR.

Comment on lines 613 to 614
pragma_fileformat = generate_custom_unstructured_metainformation_line("fileformat", "VCFv4.4")
pragmas_to_add.append(pragma_fileformat)
Copy link
Member

Choose a reason for hiding this comment

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

These 2 lines could be simplified

Suggested change
pragma_fileformat = generate_custom_unstructured_metainformation_line("fileformat", "VCFv4.4")
pragmas_to_add.append(pragma_fileformat)
pragmas_to_add.append(generate_custom_unstructured_metainformation_line("fileformat", "VCFv4.4"))

Same thing could be done on the other ones below.

for pragma in gvf_pragmas:
# file date
if pragma.startswith("##file-date"):
date = pragma.split(" ")[1].replace("-", "")
Copy link
Member

Choose a reason for hiding this comment

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

For a latter refactoring but the if/elif could be converted to a mapping that looks like:

for pragma in gvf_pragmas:
    pragma_name, pragma_value = parse_pragma(pragma)   # <== need a function to parse the pragma
    if pragma_name in list_of_pragma:
        vcf_header_key = pragma_name_to_vcf_header.get(pragma_name)  # <== need a map that match the pragma_name to a VCF header name
        pragmas_to_add.append(generate_custom_unstructured_metainformation_line(vcf_header_key, pragma_value))

header_type = "FORMAT"
file_lines = read_file(prefix,header_type)
assert len(file_lines) > 1
#2
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't number the tests as it will quickly become unsustainable or unreliable.

#3
def test_read_info_attributes(self):
info_attribute_dict = read_info_attributes(self.info_attribute_input_file)
assert len(info_attribute_dict) > 1
Copy link
Member

Choose a reason for hiding this comment

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

It is worth adding something that check length of the array and the content of the first element to ensure is formatted as intended.

@khetherin khetherin requested a review from tcezard October 22, 2025 08:13
Comment on lines +40 to +44
kv = next(iter(info_attribute_dict.items()))
key_to_check = "3'_inner_flank_link"
value_to_check = ["3'_inner_flank_link", '.', 'String', 'Three prime inner flank link', 'DGVa']
assert kv[0] == key_to_check
assert kv[1] == value_to_check
Copy link
Member

Choose a reason for hiding this comment

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

If you're goinf to test 3'_inner_flank_link you might as well get it explicitly from the dict.
Unless you think that the fact that it is the first element added to the dict is important but I don't see why it would matter

Suggested change
kv = next(iter(info_attribute_dict.items()))
key_to_check = "3'_inner_flank_link"
value_to_check = ["3'_inner_flank_link", '.', 'String', 'Three prime inner flank link', 'DGVa']
assert kv[0] == key_to_check
assert kv[1] == value_to_check
expected_value = ["3'_inner_flank_link", '.', 'String', 'Three prime inner flank link', 'DGVa']
assert info_attribute_dict.get("3'_inner_flank_link") == expected_value

@khetherin khetherin merged commit f9f3f26 into EBIvariation:main Oct 22, 2025
1 check passed
khetherin added a commit to khetherin/convertGVFtoVCF that referenced this pull request Oct 22, 2025
tcezard pushed a commit to tcezard/convertGVFtoVCF that referenced this pull request Oct 22, 2025
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.

2 participants