Skip to content

Commit 4155dbb

Browse files
committed
Merge pipeline
1 parent 07c6029 commit 4155dbb

File tree

6 files changed

+31
-12
lines changed

6 files changed

+31
-12
lines changed

v03_pipeline/lib/annotations/snv_indel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def AB(mt: hl.MatrixTable, **_: Any) -> hl.Expression: # noqa: N802
1313
return hl.bind(
1414
lambda total: hl.if_else(
1515
(is_called) & (total != 0) & (hl.len(mt.AD) > 1),
16-
hl.float(mt.AD[1] / total),
17-
hl.missing(hl.tfloat),
16+
hl.float32(mt.AD[1] / total),
17+
hl.missing(hl.tfloat32),
1818
),
1919
hl.sum(mt.AD),
2020
)
@@ -24,8 +24,8 @@ def DP(mt: hl.MatrixTable, **_: Any) -> hl.Expression: # noqa: N802
2424
is_called = hl.is_defined(mt.GT)
2525
return hl.if_else(
2626
is_called & hl.is_defined(mt.AD),
27-
hl.int(hl.min(hl.sum(mt.AD), 32000)),
28-
hl.missing(hl.tint),
27+
hl.int32(hl.min(hl.sum(mt.AD), 32000)),
28+
hl.missing(hl.tint32),
2929
)
3030

3131

v03_pipeline/lib/misc/math.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def constrain(number: int | float, lower_bound: int | float, upper_bound: int | float) -> int:
2+
if lower_bound > upper_bound:
3+
msg = 'Lower bound should be less than or equal to upper bound'
4+
raise ValueError(msg)
5+
return max(lower_bound, min(number, upper_bound))

v03_pipeline/lib/misc/math_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import unittest
2+
3+
from v03_pipeline.lib.misc.math import constrain
4+
5+
6+
class TestConstrainFunction(unittest.TestCase):
7+
8+
def test_constrain(self):
9+
self.assertEqual(constrain(5, 0, 10), 5)
10+
self.assertEqual(constrain(-3, 0, 10), 0)
11+
self.assertEqual(constrain(15, 0, 10), 10)
12+
with self.assertRaises(ValueError):
13+
constrain(5, 10, 0)

v03_pipeline/lib/tasks/update_project_table_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_update_project_table_task(self) -> None:
8181
entries=[
8282
hl.Struct(
8383
GQ=30,
84-
AB=0.3333333333333333,
84+
AB=hl.eval(hl.float32(0.3333333333333333)),
8585
DP=3,
8686
GT=hl.Call(alleles=[0, 1], phased=False),
8787
),
@@ -93,7 +93,7 @@ def test_update_project_table_task(self) -> None:
9393
),
9494
hl.Struct(
9595
GQ=61,
96-
AB=0.6,
96+
AB=hl.eval(hl.float32(0.6)),
9797
DP=5,
9898
GT=hl.Call(alleles=[0, 1], phased=False),
9999
),

v03_pipeline/lib/tasks/update_variant_annotations_table_with_new_samples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from v03_pipeline.lib.annotations.enums import annotate_enums
88
from v03_pipeline.lib.annotations.fields import get_fields
9+
from v03_pipeline.lib.misc.math import constrain
910
from v03_pipeline.lib.misc.util import callset_project_pairs
1011
from v03_pipeline.lib.model import ReferenceDatasetCollection
1112
from v03_pipeline.lib.paths import (
@@ -26,7 +27,7 @@
2627
from v03_pipeline.lib.vep import run_vep
2728

2829
GENCODE_RELEASE = 42
29-
VARIANTS_PER_VEP_PARTITION = 20e3
30+
VARIANTS_PER_VEP_PARTITION = 1e3
3031

3132

3233
class UpdateVariantAnnotationsTableWithNewSamplesTask(BaseVariantAnnotationsTableTask):
@@ -204,7 +205,7 @@ def update_table(self, ht: hl.Table) -> hl.Table:
204205
new_variants_ht = callset_ht.anti_join(ht)
205206
new_variants_count = new_variants_ht.count()
206207
new_variants_ht = new_variants_ht.repartition(
207-
max(math.ceil(new_variants_count / VARIANTS_PER_VEP_PARTITION), 1),
208+
constrain(math.ceil(new_variants_count / VARIANTS_PER_VEP_PARTITION), 10, 10000),
208209
)
209210
new_variants_ht = run_vep(
210211
new_variants_ht,

v03_pipeline/lib/tasks/write_family_table_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_snv_write_family_table_task(self) -> None:
7171
[
7272
hl.Struct(
7373
GQ=30,
74-
AB=0.3333333333333333,
74+
AB=hl.eval(hl.float32(0.3333333333333333)),
7575
DP=3,
7676
GT=hl.Call(alleles=[0, 1], phased=False),
7777
),
@@ -83,7 +83,7 @@ def test_snv_write_family_table_task(self) -> None:
8383
),
8484
hl.Struct(
8585
GQ=61,
86-
AB=0.6,
86+
AB=hl.eval(hl.float32(0.6)),
8787
DP=5,
8888
GT=hl.Call(alleles=[0, 1], phased=False),
8989
),
@@ -97,7 +97,7 @@ def test_snv_write_family_table_task(self) -> None:
9797
),
9898
hl.Struct(
9999
GQ=99,
100-
AB=0.5283018867924528,
100+
AB=hl.eval(hl.float32(0.5283018867924528)),
101101
DP=53,
102102
GT=hl.Call(alleles=[0, 1], phased=False),
103103
),
@@ -123,7 +123,7 @@ def test_snv_write_family_table_task(self) -> None:
123123
),
124124
hl.Struct(
125125
GQ=99,
126-
AB=0.4146341463414634,
126+
AB=hl.eval(hl.float32(0.4146341463414634)),
127127
DP=41,
128128
GT=hl.Call(alleles=[0, 1], phased=False),
129129
),

0 commit comments

Comments
 (0)