Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace string-based file extension checks with pathlib #2

Merged
merged 4 commits into from
Nov 15, 2024
Merged

Conversation

davidbonet
Copy link
Member

Refactor file handling across multiple modules by adopting pathlib to replace string-based file extension manipulations.

  • Path.suffix and Path.suffixes for extension checks and with_suffix/with_name for consistent and cross-platform extension modifications.
  • Simplifying the logic for verifying and appending file extensions, ensuring the codebase handles VCF, BCF, MSP, BED, and other file formats in a more Pythonic way.

This refactor improves code readability and reduces potential errors with manual string slicing. All tests related to file handling have been adapted to work with pathlib.

@davidbonet davidbonet requested a review from salcc November 14, 2024 23:56
Copy link
Member

@salcc salcc left a comment

Choose a reason for hiding this comment

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

Looks good to me, but a unused import was introduced in read_vcf

benchmark/read_vcf.py Outdated Show resolved Hide resolved
@salcc
Copy link
Member

salcc commented Nov 15, 2024

And it would be nice to update the plink link to the latest release: https://s3.amazonaws.com/plink2-assets/alpha6/plink2_linux_x86_64_20241114.zip

@salcc salcc merged commit c24bd46 into main Nov 15, 2024
2 checks passed
@salcc salcc deleted the fix-pathlib branch November 15, 2024 01:44
@salcc salcc restored the fix-pathlib branch November 15, 2024 01:57
Copy link
Member

@salcc salcc left a comment

Choose a reason for hiding this comment

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

All good now!

@salcc salcc deleted the fix-pathlib branch November 15, 2024 01:58
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