Skip to content

Commit

Permalink
Merge pull request #63 from EBI-G2P/update/gene_scores
Browse files Browse the repository at this point in the history
Update gene scores to three decimal places
  • Loading branch information
seeta-ramaraju authored Nov 13, 2024
2 parents 37910c4 + 7d97d27 commit f47749a
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions gene2phenotype_project/gene2phenotype_app/serializers/locus.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,41 +174,23 @@ def badonyi_score(self):
"""
Retrieve the Badonyi scores for the current gene, organizing the results
in a dictionary where each key is the score's attribute (description_attrib.value)
and the value is the score.
This method filters `GeneStats` objects associated with the current gene (via `self.id`),
then creates a dictionary where the key is the `description_attrib.value` and the value
is the `score`.
and the value is the score rounded to three decimal places.
Returns:
-------
dict
A dictionary where:
- Key: The value of `description_attrib` (score's attribute) from each `GeneStats` object.
- Value: The score associated with that attribute.
Example:
-------
{
"gain_of_function": 1.5,
"loss_of_function": 0.7,
...
}
Notes:
-----
- Each unique attribute will have its own entry in the dictionary.
dictionary
- Key: The value of `description_attrib` (score's attribute) from each `GeneStats` object.
- Value: The score associated with that attribute.
"""

result_data = {}
badonyi_stats_objs = GeneStats.objects.filter(gene=self.id)

for badonyi_obj in badonyi_stats_objs:
key = badonyi_obj.description_attrib.value
result_data[key] = badonyi_obj.score
result_data[key] = round(badonyi_obj.score, 3)

return result_data


class Meta:
model = Locus
Expand Down

0 comments on commit f47749a

Please sign in to comment.