haplohub-cli 3.2.1__tar.gz → 3.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/.github/workflows/on_pr.yml +1 -1
  2. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/.github/workflows/on_push_main.yml +1 -1
  3. {haplohub_cli-3.2.1/haplohub_cli.egg-info → haplohub_cli-3.3.0}/PKG-INFO +3 -2
  4. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/docs/sdk-coupling.md +1 -1
  5. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/_version.py +3 -3
  6. haplohub_cli-3.3.0/haplohub_cli/commands/tests/test_variant.py +116 -0
  7. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/variant.py +70 -8
  8. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/api/client.py +3 -0
  9. haplohub_cli-3.3.0/haplohub_cli/formatters/tests/test_variant.py +42 -0
  10. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/variant.py +7 -4
  11. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0/haplohub_cli.egg-info}/PKG-INFO +3 -2
  12. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/SOURCES.txt +2 -0
  13. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/requires.txt +2 -1
  14. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/scm_file_list.json +2 -0
  15. haplohub_cli-3.3.0/haplohub_cli.egg-info/scm_version.json +8 -0
  16. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/pyproject.toml +2 -1
  17. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/uv.lock +404 -402
  18. haplohub_cli-3.2.1/haplohub_cli.egg-info/scm_version.json +0 -8
  19. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/.github/dependabot.yml +0 -0
  20. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/.gitignore +0 -0
  21. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/.pre-commit-config.yaml +0 -0
  22. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/AGENTS.md +0 -0
  23. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/CLAUDE.md +0 -0
  24. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/README.md +0 -0
  25. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/docs/index.md +0 -0
  26. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/docs/release.md +0 -0
  27. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/docs/stage-verification.md +0 -0
  28. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/docs/testing.md +0 -0
  29. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/__init__.py +0 -0
  30. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/__init__.py +0 -0
  31. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/auth.py +0 -0
  32. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/auth_web_server.py +0 -0
  33. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/oauth_client.py +0 -0
  34. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/tests/__init__.py +0 -0
  35. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/tests/test_auth_web_server.py +0 -0
  36. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/tests/test_token_storage.py +0 -0
  37. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/auth/token_storage.py +0 -0
  38. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/cli.py +0 -0
  39. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/__init__.py +0 -0
  40. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/algorithm/__init__.py +0 -0
  41. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/algorithm/result/__init__.py +0 -0
  42. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/algorithm/tests/__init__.py +0 -0
  43. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/algorithm/tests/test_result_create.py +0 -0
  44. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/__init__.py +0 -0
  45. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/biomarker.py +0 -0
  46. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/member/__init__.py +0 -0
  47. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/member/report.py +0 -0
  48. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/sample.py +0 -0
  49. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/tests/__init__.py +0 -0
  50. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/cohort/tests/test_delete.py +0 -0
  51. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/config.py +0 -0
  52. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/file.py +0 -0
  53. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/login.py +0 -0
  54. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/metadata/__init__.py +0 -0
  55. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/tests/__init__.py +0 -0
  56. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/tests/test_file.py +0 -0
  57. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/commands/version.py +0 -0
  58. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/config/__init__.py +0 -0
  59. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/config/config.py +0 -0
  60. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/config/config_manager.py +0 -0
  61. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/__init__.py +0 -0
  62. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/api/__init__.py +0 -0
  63. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/checksum.py +0 -0
  64. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/deletion.py +0 -0
  65. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/network.py +0 -0
  66. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/slug.py +0 -0
  67. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/tests/__init__.py +0 -0
  68. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/tests/test_checksum.py +0 -0
  69. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/tests/test_network.py +0 -0
  70. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/tests/test_slug.py +0 -0
  71. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/types.py +0 -0
  72. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/core/upload.py +0 -0
  73. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/__init__.py +0 -0
  74. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/algorithm.py +0 -0
  75. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/algorithm_result.py +0 -0
  76. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/biomarker.py +0 -0
  77. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/config.py +0 -0
  78. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/decorators.py +0 -0
  79. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/file.py +0 -0
  80. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/formatter_registry.py +0 -0
  81. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/generic.py +0 -0
  82. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/generic_table.py +0 -0
  83. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/tests/__init__.py +0 -0
  84. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/tests/test_generic_table.py +0 -0
  85. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/formatters/utils.py +0 -0
  86. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/settings.py +0 -0
  87. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/tests/__init__.py +0 -0
  88. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/tests/test_cli.py +0 -0
  89. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/types/__init__.py +0 -0
  90. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli/types/variant_range.py +0 -0
  91. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/dependency_links.txt +0 -0
  92. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/entry_points.txt +0 -0
  93. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/haplohub_cli.egg-info/top_level.txt +0 -0
  94. {haplohub_cli-3.2.1 → haplohub_cli-3.3.0}/setup.cfg +0 -0
@@ -13,7 +13,7 @@ jobs:
13
13
  python-version: ["3.10", "3.11", "3.12", "3.13"]
14
14
 
15
15
  steps:
16
- - uses: actions/checkout@v6
16
+ - uses: actions/checkout@v7
17
17
  - uses: astral-sh/setup-uv@v7
18
18
  with:
19
19
  python-version: ${{ matrix.python-version }}
@@ -15,7 +15,7 @@ jobs:
15
15
  name: Build python package
16
16
  runs-on: ubuntu-latest
17
17
  steps:
18
- - uses: actions/checkout@v6
18
+ - uses: actions/checkout@v7
19
19
  with:
20
20
  fetch-depth: 0
21
21
  - uses: hynek/build-and-inspect-python-package@v2
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haplohub-cli
3
- Version: 3.2.1
3
+ Version: 3.3.0
4
4
  Summary: HaploHub Command Line Interface
5
5
  Author-email: Mike Polcari <mike@haplotype-labs.com>, Ilya Khrustalev <ilya@haplotype-labs.com>
6
6
  Requires-Python: >=3.10
7
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: certifi>=2026.10.19
8
9
  Requires-Dist: click>=8.1.8
9
- Requires-Dist: haplohub<4,>=3.1.0
10
+ Requires-Dist: haplohub<4,>=3.8.0
10
11
  Requires-Dist: pendulum>=3.0.0
11
12
  Requires-Dist: requests>=2.32.0
12
13
  Requires-Dist: rich>=13.9.4
@@ -12,7 +12,7 @@ newer or older than the released SDK.
12
12
 
13
13
  ## Version constraint
14
14
 
15
- `pyproject.toml` pins a range like `haplohub>=3.1.0,<4`. Policy:
15
+ `pyproject.toml` pins a range like `haplohub>=3.8.0,<4`. Policy:
16
16
 
17
17
  - The lower bound is the oldest SDK release whose API surface this code uses.
18
18
  Raise it whenever code starts using something newer.
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '3.2.1'
22
- __version_tuple__ = version_tuple = (3, 2, 1)
21
+ __version__ = version = '3.3.0'
22
+ __version_tuple__ = version_tuple = (3, 3, 0)
23
23
 
24
- __commit_id__ = commit_id = 'g3cb30f685'
24
+ __commit_id__ = commit_id = 'ga6eca03c9'
@@ -0,0 +1,116 @@
1
+ from unittest import TestCase
2
+ from unittest.mock import patch
3
+
4
+ from click.testing import CliRunner
5
+
6
+ from haplohub_cli.commands.variant import variant
7
+
8
+ COHORT = "coh-abc123"
9
+
10
+
11
+ class VariantCommandTestCase(TestCase):
12
+ def invoke(self, *args):
13
+ with patch("haplohub_cli.commands.variant.client") as client:
14
+ result = CliRunner().invoke(variant, list(args))
15
+ return result, client
16
+
17
+ def sent_request(self, client):
18
+ cohort_id, request = client.variant.get_variant.call_args.args
19
+ self.assertEqual(cohort_id, COHORT)
20
+ return request
21
+
22
+ def test_region_brava_flag_adds_selector(self):
23
+ result, client = self.invoke(
24
+ "region", COHORT, "-s", "smp-1", "-a", "NC_000001.11", "--start", "100", "--end", "200", "--gwas", "--brava"
25
+ )
26
+
27
+ self.assertEqual(result.exit_code, 0, result.output)
28
+ self.assertEqual(self.sent_request(client).selectors, ["gwas", "brava"])
29
+
30
+ def test_hgvs_brava_flag_adds_selector(self):
31
+ result, client = self.invoke("hgvs", COHORT, "-s", "smp-1", "-h", "NC_000001.11:g.100A>G", "--brava")
32
+
33
+ self.assertEqual(result.exit_code, 0, result.output)
34
+ self.assertEqual(self.sent_request(client).selectors, ["brava"])
35
+
36
+ def test_region_without_flags_sends_no_selectors(self):
37
+ result, client = self.invoke("region", COHORT, "-s", "smp-1", "-a", "NC_000001.11", "--start", "1", "--end", "2")
38
+
39
+ self.assertEqual(result.exit_code, 0, result.output)
40
+ self.assertIsNone(self.sent_request(client).selectors)
41
+
42
+ def test_gwas_brava_flag_adds_selector(self):
43
+ result, client = self.invoke("gwas", COHORT, "-s", "smp-1", "--gene", "TCF7L2", "--brava")
44
+
45
+ self.assertEqual(result.exit_code, 0, result.output)
46
+ self.assertEqual(self.sent_request(client).selectors, ["gwas", "brava"])
47
+
48
+ def test_brava_builds_brava_target(self):
49
+ result, client = self.invoke(
50
+ "brava",
51
+ COHORT,
52
+ "-s",
53
+ "smp-1",
54
+ "-s",
55
+ "smp-2",
56
+ "--trait",
57
+ "AFib",
58
+ "--gene",
59
+ "PCSK9",
60
+ "--p-value-max",
61
+ "1e-5",
62
+ "--limit",
63
+ "20",
64
+ "--call-state",
65
+ "all",
66
+ "--clinvar",
67
+ )
68
+
69
+ self.assertEqual(result.exit_code, 0, result.output)
70
+ request = self.sent_request(client)
71
+ self.assertEqual(request.sample_ids, ["smp-1", "smp-2"])
72
+ self.assertEqual(request.selectors, ["clinvar", "brava"])
73
+ self.assertEqual(request.filters.call_state, "all")
74
+ self.assertEqual(
75
+ request.to_dict()["targets"],
76
+ [{"type": "brava", "trait": "AFib", "gene": "PCSK9", "p_value_max": 1e-5, "limit": 20}],
77
+ )
78
+
79
+ def test_brava_defaults(self):
80
+ result, client = self.invoke("brava", COHORT, "-s", "smp-1", "--gene", "PCSK9")
81
+
82
+ self.assertEqual(result.exit_code, 0, result.output)
83
+ request = self.sent_request(client)
84
+ self.assertEqual(request.selectors, ["brava"])
85
+ self.assertEqual(
86
+ request.to_dict()["targets"],
87
+ [{"type": "brava", "trait": None, "gene": "PCSK9", "p_value_max": None, "limit": 100}],
88
+ )
89
+
90
+ def test_brava_requires_trait_or_gene(self):
91
+ result, client = self.invoke("brava", COHORT, "-s", "smp-1")
92
+
93
+ self.assertEqual(result.exit_code, 2)
94
+ self.assertIn("Provide at least one of --trait or --gene", result.output)
95
+ client.variant.get_variant.assert_not_called()
96
+
97
+ def test_brava_treats_blank_trait_and_gene_as_missing(self):
98
+ result, client = self.invoke("brava", COHORT, "-s", "smp-1", "--trait", " ", "--gene", "")
99
+
100
+ self.assertEqual(result.exit_code, 2)
101
+ self.assertIn("Provide at least one of --trait or --gene", result.output)
102
+ client.variant.get_variant.assert_not_called()
103
+
104
+ def test_brava_rejects_out_of_range_limit_and_p_value(self):
105
+ for extra in (
106
+ ["--limit", "0"],
107
+ ["--limit", "1001"],
108
+ ["--p-value-max", "0"],
109
+ ["--p-value-max", "1.5"],
110
+ ["--p-value-max", "nan"],
111
+ ):
112
+ with self.subTest(extra=extra):
113
+ result, client = self.invoke("brava", COHORT, "-s", "smp-1", "--trait", "AFib", *extra)
114
+
115
+ self.assertEqual(result.exit_code, 2, result.output)
116
+ client.variant.get_variant.assert_not_called()
@@ -1,5 +1,8 @@
1
+ import math
2
+
1
3
  import click
2
4
  from haplohub import (
5
+ BravaTargetSchema,
3
6
  GetVariantRequest,
4
7
  GwasTargetSchema,
5
8
  HgvsTargetSchema,
@@ -11,13 +14,15 @@ from haplohub import (
11
14
  from haplohub_cli.core.api.client import client
12
15
 
13
16
 
14
- def _selectors(clinvar: bool, gwas: bool) -> list[str] | None:
17
+ def _selectors(clinvar: bool, gwas: bool, brava: bool) -> list[str] | None:
15
18
  """Build the selector list; None when no annotations were requested."""
16
19
  selectors = []
17
20
  if clinvar:
18
21
  selectors.append("clinvar")
19
22
  if gwas:
20
23
  selectors.append("gwas")
24
+ if brava:
25
+ selectors.append("brava")
21
26
  return selectors or None
22
27
 
23
28
 
@@ -40,7 +45,8 @@ def variant():
40
45
  @click.option("--call-state", type=click.Choice(["called", "all"]), default="called", help="Filter by call state")
41
46
  @click.option("--clinvar", is_flag=True, default=False, help="Include ClinVar annotations")
42
47
  @click.option("--gwas", is_flag=True, default=False, help="Include GWAS Catalog annotations")
43
- def region(sample_ids, cohort_id, accession, start, end, reference, alternate, call_state, clinvar, gwas):
48
+ @click.option("--brava", is_flag=True, default=False, help="Include BRaVa rare-variant associations")
49
+ def region(sample_ids, cohort_id, accession, start, end, reference, alternate, call_state, clinvar, gwas, brava):
44
50
  """
45
51
  Query variants by genomic region
46
52
  """
@@ -56,7 +62,7 @@ def region(sample_ids, cohort_id, accession, start, end, reference, alternate, c
56
62
  sample_ids=list(sample_ids),
57
63
  targets=[VariantTargetSchema(target)],
58
64
  filters=VariantFilterSchema(call_state=call_state),
59
- selectors=_selectors(clinvar, gwas),
65
+ selectors=_selectors(clinvar, gwas, brava),
60
66
  )
61
67
 
62
68
  return client.variant.get_variant(cohort_id, request)
@@ -69,7 +75,8 @@ def region(sample_ids, cohort_id, accession, start, end, reference, alternate, c
69
75
  @click.option("--call-state", type=click.Choice(["called", "all"]), default="called", help="Filter by call state")
70
76
  @click.option("--clinvar", is_flag=True, default=False, help="Include ClinVar annotations")
71
77
  @click.option("--gwas", is_flag=True, default=False, help="Include GWAS Catalog annotations")
72
- def hgvs(sample_ids, cohort_id, hgvs, call_state, clinvar, gwas):
78
+ @click.option("--brava", is_flag=True, default=False, help="Include BRaVa rare-variant associations")
79
+ def hgvs(sample_ids, cohort_id, hgvs, call_state, clinvar, gwas, brava):
73
80
  """
74
81
  Query variants by HGVS notation
75
82
  """
@@ -79,7 +86,7 @@ def hgvs(sample_ids, cohort_id, hgvs, call_state, clinvar, gwas):
79
86
  sample_ids=list(sample_ids),
80
87
  targets=targets,
81
88
  filters=VariantFilterSchema(call_state=call_state),
82
- selectors=_selectors(clinvar, gwas),
89
+ selectors=_selectors(clinvar, gwas, brava),
83
90
  )
84
91
 
85
92
  return client.variant.get_variant(cohort_id, request)
@@ -95,13 +102,15 @@ def hgvs(sample_ids, cohort_id, hgvs, call_state, clinvar, gwas):
95
102
  @click.option("--limit", type=int, default=100, help="Max associations to resolve (most significant first)")
96
103
  @click.option("--call-state", type=click.Choice(["called", "all"]), default="called", help="Filter by call state")
97
104
  @click.option("--clinvar", is_flag=True, default=False, help="Also include ClinVar annotations")
98
- def gwas(sample_ids, cohort_id, gene, trait_id, rs_ids, p_value_max, limit, call_state, clinvar):
105
+ @click.option("--brava", is_flag=True, default=False, help="Also include BRaVa rare-variant associations")
106
+ def gwas(sample_ids, cohort_id, gene, trait_id, rs_ids, p_value_max, limit, call_state, clinvar, brava):
99
107
  """
100
108
  Genotype the SNPs of GWAS Catalog associations in a sample.
101
109
 
102
110
  Selects associations by --gene, --trait-id and/or --rs (at least one required),
103
111
  genotypes their SNP positions in the sample, and attaches the matching GWAS
104
- associations to each result. Combine with --clinvar to also attach ClinVar.
112
+ associations to each result. Combine with --clinvar or --brava to also attach
113
+ ClinVar or BRaVa annotations.
105
114
  """
106
115
  if not (gene or trait_id or rs_ids):
107
116
  raise click.UsageError("Provide at least one of --gene, --trait-id or --rs.")
@@ -118,7 +127,60 @@ def gwas(sample_ids, cohort_id, gene, trait_id, rs_ids, p_value_max, limit, call
118
127
  sample_ids=list(sample_ids),
119
128
  targets=[VariantTargetSchema(target)],
120
129
  filters=VariantFilterSchema(call_state=call_state),
121
- selectors=_selectors(clinvar, gwas=True),
130
+ selectors=_selectors(clinvar, gwas=True, brava=brava),
131
+ )
132
+
133
+ return client.variant.get_variant(cohort_id, request)
134
+
135
+
136
+ @variant.command()
137
+ @click.argument("cohort_id", type=str)
138
+ @click.option("--sample", "-s", "sample_ids", type=str, multiple=True, required=True, help="Sample ID (repeatable)")
139
+ @click.option("--trait", type=str, default=None, help="BRaVa trait code (e.g. AFib)")
140
+ @click.option("--gene", type=str, default=None, help="HGNC gene symbol (e.g. PCSK9)")
141
+ @click.option(
142
+ "--p-value-max",
143
+ type=click.FloatRange(min=0, max=1, min_open=True),
144
+ default=None,
145
+ help="Select only variants with an association p-value <= this (attachments still list all of the variant's associations)",
146
+ )
147
+ @click.option(
148
+ "--limit",
149
+ type=click.IntRange(min=1, max=1000),
150
+ default=100,
151
+ help="Max variants to resolve (most significant first)",
152
+ )
153
+ @click.option("--call-state", type=click.Choice(["called", "all"]), default="called", help="Filter by call state")
154
+ @click.option("--clinvar", is_flag=True, default=False, help="Also include ClinVar annotations")
155
+ @click.option("--gwas", is_flag=True, default=False, help="Also include GWAS Catalog annotations")
156
+ def brava(sample_ids, cohort_id, trait, gene, p_value_max, limit, call_state, clinvar, gwas):
157
+ """
158
+ Genotype the variants of BRaVa rare-variant associations in a sample.
159
+
160
+ Selects variant associations by --trait and/or --gene (at least one required),
161
+ genotypes those variants in the sample, and attaches the matching BRaVa
162
+ associations to each result. Combine with --clinvar or --gwas to also attach
163
+ ClinVar or GWAS Catalog annotations.
164
+ """
165
+ trait = (trait or "").strip() or None
166
+ gene = (gene or "").strip() or None
167
+ if not (trait or gene):
168
+ raise click.UsageError("Provide at least one of --trait or --gene.")
169
+ if p_value_max is not None and math.isnan(p_value_max):
170
+ raise click.BadParameter("must be a number greater than 0 and at most 1.", param_hint="--p-value-max")
171
+
172
+ target = BravaTargetSchema(
173
+ trait=trait,
174
+ gene=gene,
175
+ p_value_max=p_value_max,
176
+ limit=limit,
177
+ )
178
+
179
+ request = GetVariantRequest(
180
+ sample_ids=list(sample_ids),
181
+ targets=[VariantTargetSchema(target)],
182
+ filters=VariantFilterSchema(call_state=call_state),
183
+ selectors=_selectors(clinvar, gwas, brava=True),
122
184
  )
123
185
 
124
186
  return client.variant.get_variant(cohort_id, request)
@@ -1,5 +1,6 @@
1
1
  from functools import cached_property
2
2
 
3
+ import certifi
3
4
  import click
4
5
  from haplohub import ApiClient, Configuration
5
6
 
@@ -22,11 +23,13 @@ class Client:
22
23
  config = Configuration(
23
24
  host=api_url,
24
25
  api_key={"ApiKeyAuth": self.token_storage.get_api_key(api_url)},
26
+ ssl_ca_cert=certifi.where(),
25
27
  )
26
28
  else:
27
29
  config = Configuration(
28
30
  host=api_url,
29
31
  access_token=self.token_storage.get_access_token(api_url),
32
+ ssl_ca_cert=certifi.where(),
30
33
  )
31
34
  return ApiClient(config)
32
35
 
@@ -0,0 +1,42 @@
1
+ from types import SimpleNamespace
2
+ from unittest import TestCase
3
+
4
+ from haplohub_cli.formatters.variant import _format_annotations
5
+
6
+
7
+ class FormatAnnotationsTestCase(TestCase):
8
+ def test_counts_each_source(self):
9
+ attachments = SimpleNamespace(clinvar=[object()], gwas=[object()] * 5, brava=[object()] * 2)
10
+
11
+ self.assertEqual(_format_annotations(attachments), "clinvar:1 gwas:5 brava:2")
12
+
13
+ def test_brava_only(self):
14
+ attachments = SimpleNamespace(clinvar=None, gwas=[], brava=[object()])
15
+
16
+ self.assertEqual(_format_annotations(attachments), "brava:1")
17
+
18
+ def test_no_attachments(self):
19
+ self.assertEqual(_format_annotations(None), "")
20
+
21
+
22
+ class FormatVariantResultsTestCase(TestCase):
23
+ def _item(self, target):
24
+ variant = SimpleNamespace(accession="chr13", position=101, reference="A", alternate=["G", "T"], quality=None)
25
+ sample = SimpleNamespace(sample_id="smp-1", is_called=True, dosage=1)
26
+ return SimpleNamespace(error_message=None, target=target, variant=variant, samples=[sample], attachments=None)
27
+
28
+ def _target_cell(self, target):
29
+ from haplohub_cli.formatters.variant import format_variant_results
30
+
31
+ table = format_variant_results(SimpleNamespace(items=[self._item(target)]))
32
+ return table.columns[0]._cells[0]
33
+
34
+ def test_brava_row_shows_the_counted_allele(self):
35
+ target = SimpleNamespace(type="brava", input="trait=AFib", resolved="chr13:101:A>T")
36
+
37
+ self.assertEqual(self._target_cell(target), "chr13:101:A>T")
38
+
39
+ def test_other_rows_keep_the_input(self):
40
+ target = SimpleNamespace(type="region", input="chr13:101", resolved="chr13:101:A>T")
41
+
42
+ self.assertEqual(self._target_cell(target), "chr13:101")
@@ -32,12 +32,15 @@ def format_variant_results(data: GetVariantResponse):
32
32
  alternate = ", ".join(variant.alternate) if variant and variant.alternate else ""
33
33
  quality = f"{variant.quality:.4f}" if variant and variant.quality is not None else ""
34
34
  annotations = _format_annotations(item.attachments)
35
+ # A BRaVa target counts one allele (chr:pos:ref>alt in `resolved`); show it, since the
36
+ # Alt column lists every ALT of a multi-allelic record.
37
+ target_label = item.target.resolved if item.target.type == "brava" and item.target.resolved else item.target.input
35
38
 
36
39
  if not samples:
37
- table.add_row(item.target.input, accession, position, reference, alternate, quality, "", "", "", annotations)
40
+ table.add_row(target_label, accession, position, reference, alternate, quality, "", "", "", annotations)
38
41
  else:
39
42
  for i, sample in enumerate(samples):
40
- target_col = item.target.input if i == 0 else ""
43
+ target_col = target_label if i == 0 else ""
41
44
  acc_col = accession if i == 0 else ""
42
45
  pos_col = position if i == 0 else ""
43
46
  ref_col = reference if i == 0 else ""
@@ -56,11 +59,11 @@ def format_variant_results(data: GetVariantResponse):
56
59
 
57
60
 
58
61
  def _format_annotations(attachments) -> str:
59
- """Summarize per-source attachment counts, e.g. "clinvar:1 gwas:5"."""
62
+ """Summarize per-source attachment counts, e.g. "clinvar:1 gwas:5 brava:2"."""
60
63
  if attachments is None:
61
64
  return ""
62
65
  parts = []
63
- for source in ("clinvar", "gwas"):
66
+ for source in ("clinvar", "gwas", "brava"):
64
67
  rows = getattr(attachments, source, None) or []
65
68
  if rows:
66
69
  parts.append(f"{source}:{len(rows)}")
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haplohub-cli
3
- Version: 3.2.1
3
+ Version: 3.3.0
4
4
  Summary: HaploHub Command Line Interface
5
5
  Author-email: Mike Polcari <mike@haplotype-labs.com>, Ilya Khrustalev <ilya@haplotype-labs.com>
6
6
  Requires-Python: >=3.10
7
7
  Description-Content-Type: text/markdown
8
+ Requires-Dist: certifi>=2026.10.19
8
9
  Requires-Dist: click>=8.1.8
9
- Requires-Dist: haplohub<4,>=3.1.0
10
+ Requires-Dist: haplohub<4,>=3.8.0
10
11
  Requires-Dist: pendulum>=3.0.0
11
12
  Requires-Dist: requests>=2.32.0
12
13
  Requires-Dist: rich>=13.9.4
@@ -53,6 +53,7 @@ haplohub_cli/commands/cohort/tests/test_delete.py
53
53
  haplohub_cli/commands/metadata/__init__.py
54
54
  haplohub_cli/commands/tests/__init__.py
55
55
  haplohub_cli/commands/tests/test_file.py
56
+ haplohub_cli/commands/tests/test_variant.py
56
57
  haplohub_cli/config/__init__.py
57
58
  haplohub_cli/config/config.py
58
59
  haplohub_cli/config/config_manager.py
@@ -83,6 +84,7 @@ haplohub_cli/formatters/utils.py
83
84
  haplohub_cli/formatters/variant.py
84
85
  haplohub_cli/formatters/tests/__init__.py
85
86
  haplohub_cli/formatters/tests/test_generic_table.py
87
+ haplohub_cli/formatters/tests/test_variant.py
86
88
  haplohub_cli/tests/__init__.py
87
89
  haplohub_cli/tests/test_cli.py
88
90
  haplohub_cli/types/__init__.py
@@ -1,5 +1,6 @@
1
+ certifi>=2026.10.19
1
2
  click>=8.1.8
2
- haplohub<4,>=3.1.0
3
+ haplohub<4,>=3.8.0
3
4
  pendulum>=3.0.0
4
5
  requests>=2.32.0
5
6
  rich>=13.9.4
@@ -41,6 +41,7 @@
41
41
  "haplohub_cli/commands/metadata/__init__.py",
42
42
  "haplohub_cli/commands/tests/__init__.py",
43
43
  "haplohub_cli/commands/tests/test_file.py",
44
+ "haplohub_cli/commands/tests/test_variant.py",
44
45
  "haplohub_cli/commands/variant.py",
45
46
  "haplohub_cli/commands/version.py",
46
47
  "haplohub_cli/config/__init__.py",
@@ -71,6 +72,7 @@
71
72
  "haplohub_cli/formatters/generic_table.py",
72
73
  "haplohub_cli/formatters/tests/__init__.py",
73
74
  "haplohub_cli/formatters/tests/test_generic_table.py",
75
+ "haplohub_cli/formatters/tests/test_variant.py",
74
76
  "haplohub_cli/formatters/utils.py",
75
77
  "haplohub_cli/formatters/variant.py",
76
78
  "haplohub_cli/settings.py",
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "3.3.0",
3
+ "distance": 0,
4
+ "node": "ga6eca03c932456a7e64d6f5eb18e50047a592d86",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-18"
8
+ }
@@ -9,8 +9,9 @@ authors = [
9
9
  requires-python = ">=3.10"
10
10
  dynamic = ["version"]
11
11
  dependencies = [
12
+ "certifi>=2026.10.19",
12
13
  "click>=8.1.8",
13
- "haplohub>=3.1.0,<4",
14
+ "haplohub>=3.8.0,<4",
14
15
  "pendulum>=3.0.0",
15
16
  "requests>=2.32.0",
16
17
  "rich>=13.9.4",