Skip to content

Commit e227e9e

Browse files
committed
fix recall and enable workflow again
1 parent 67abf37 commit e227e9e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.github/workflows/python-package.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: [pull_request]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

src/utils/evaluation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def calculate_recall(number_of_haplotypes_per_region:dict, true_number_haps_per_
6969
if true_number_haps_per_sample_region[sample_name][region]['Wuhan'] == 0:
7070
recall_wuhan_region = 1
7171
else:
72-
recall_wuhan_region = max (number_of_haplotypes_per_region[region]['Wuhan'] / true_number_haps_per_sample_region[sample_name][region]['Wuhan'], 1)
72+
recall_wuhan_region = min (number_of_haplotypes_per_region[region]['Wuhan'] / true_number_haps_per_sample_region[sample_name][region]['Wuhan'], 1)
7373
if true_number_haps_per_sample_region[sample_name][region]['Omicron'] == 0:
7474
recall_omicron_region = 1
7575
else:
76-
recall_omicron_region = max (number_of_haplotypes_per_region[region]['Omicron'] / true_number_haps_per_sample_region[sample_name][region]['Omicron'], 1)
76+
recall_omicron_region = min (number_of_haplotypes_per_region[region]['Omicron'] / true_number_haps_per_sample_region[sample_name][region]['Omicron'], 1)
7777

7878
recall_wuhan.append(recall_wuhan_region)
7979
recall_omicron.append(recall_omicron_region)

tests/test_evaluation.py

+12
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ def test_calculate_recall_and_duplication_ratio(self):
4848

4949
dup_ratio = calculate_duplication_ratio(num_haps_per_region, true_num_of_haps_per_sample_per_region, sample_name)
5050
self.assertEqual(dup_ratio, 2)
51+
52+
def test_calculate_recall_not_all_haps_reconstructed(self):
53+
num_haps_per_region = {"test_region":{"Wuhan": 1, "Omicron": 0}}
54+
sample_name = "test"
55+
true_num_of_haps_per_sample_per_region = {"test": {"test_region": {"Wuhan": 1, "Omicron": 1}}}
56+
recall_wuhan, recall_omicron = calculate_recall(num_haps_per_region, true_num_of_haps_per_sample_per_region, sample_name)
57+
58+
self.assertEqual(recall_wuhan, 1)
59+
self.assertEqual(recall_omicron, 0)
60+
61+
dup_ratio = calculate_duplication_ratio(num_haps_per_region, true_num_of_haps_per_sample_per_region, sample_name)
62+
self.assertEqual(dup_ratio, 0.5)
5163

5264
def test_calculate_absolute_relative_abundance_error(self):
5365
true_abs_per_sample_per_region = {"test": {"test_region":{"Wuhan": 0.25, "Omicron": 0.75}}}

0 commit comments

Comments
 (0)