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

186 generalise rankcomparisongenerator class #192

Merged
merged 3 commits into from
Sep 14, 2023

Conversation

yaseminbridges
Copy link
Contributor

Generalised methods in the RankComparisonGenerator class

Copy link
Member

@matentzn matentzn left a comment

Choose a reason for hiding this comment

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

Beautiful code as always, some irrelevant suggestions.

RankComparisonGenerator(
prioritisation_data.variant_prioritisation.ranks
).generate_variant_output(f"{prioritisation_data.variant_prioritisation.results_dir.name}")
RankComparisonGenerator(prioritisation_data.variant_prioritisation.ranks).generate_output(
Copy link
Member

Choose a reason for hiding this comment

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

@julesjacobsen I am sure this is one of the things where you believe Python has gone wrong over a beautiful Java OO design..

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope. The previous implementation was all useless repetition. No one wants that.

Copy link
Member

Choose a reason for hiding this comment

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

I meant prioritisation_data.variant_prioritisation.ranks without encapsulation!

RankComparisonGenerator(prioritisation_data.gene_prioritisation.ranks).generate_gene_output(
f"{prioritisation_data.gene_prioritisation.results_dir.name}"
RankComparisonGenerator(prioritisation_data.gene_prioritisation.ranks).generate_output(
f"{prioritisation_data.gene_prioritisation.results_dir.name}", "-gene_rank_comparison.tsv"
Copy link
Member

Choose a reason for hiding this comment

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

Technically this filename seems to violate SRP (because it exists more than once in the code).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The construction of the full filename? Or the "-gene_rank_comparison.tsv" part?

Copy link
Member

Choose a reason for hiding this comment

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

The string "-gene_rank_comparison.tsv" appears twice in that file.

Copy link
Contributor Author

@yaseminbridges yaseminbridges Sep 12, 2023

Choose a reason for hiding this comment

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

Ah yes! I plan on addressing this in #193. I have the code roughly written out with how I plan it to be structured and it avoids this (used a constant for _rank_comparison.tsv)

def generate_gene_output(self, prefix: str) -> None:
"""Generate the output for gene prioritisation ranks."""
self._generate_dataframe().to_csv(prefix + "-gene_rank_comparison.tsv", sep="\t")
def generate_output(self, prefix: str, suffix: str):
Copy link
Member

Choose a reason for hiding this comment

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

You are a tiny bit inconsistent in whether a function that does not return anything should end in -> None or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're right! I'll fix this

@yaseminbridges yaseminbridges merged commit bd0683e into main Sep 14, 2023
@yaseminbridges yaseminbridges deleted the 186-generalise-rankcomparisongenerator-class branch September 14, 2023 14:30
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.

Generalise RankComparisonGenerator class
3 participants