Skip to content

Commit e78017e

Browse files
authored
Merge branch 'main' into vcf-data-types
2 parents d86cafe + 92d0c09 commit e78017e

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ This section is intended for developers who contribute to VRS-Python.
194194

195195
### Installing for development
196196

197-
Fork the repo at <https://github.com/ga4gh/vrs-python/> and initialize a development environment.
197+
[Fork the GitHub repo](https://github.com/ga4gh/vrs-python/fork).
198+
199+
Then, clone your fork and initialize a development environment:
198200

199201
```shell
200202
git clone --recurse-submodules git@github.com:YOUR_GITHUB_ID/vrs-python.git

src/ga4gh/vrs/extras/annotator/cli.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import requests
1515

1616
from ga4gh.vrs.dataproxy import create_dataproxy
17-
from ga4gh.vrs.extras.annotator.vcf import VcfAnnotator
17+
from ga4gh.vrs.extras.annotator.vcf import VcfAnnotator, VcfAnnotatorArgsError
1818

1919
_logger = logging.getLogger(__name__)
2020

@@ -187,16 +187,24 @@ def _annotate_vcf_cli(
187187
_logger.info(msg)
188188
if not silent:
189189
click.echo(msg)
190-
annotator.annotate(
191-
vcf_in.absolute(),
192-
output_vcf_path=vcf_out,
193-
vrs_attributes=vrs_attributes,
194-
assembly=assembly,
195-
compute_for_ref=(not skip_ref),
196-
require_validation=require_validation,
197-
output_pkl_path=pkl_out,
198-
output_ndjson_path=ndjson_out,
199-
)
190+
try:
191+
annotator.annotate(
192+
vcf_in.absolute(),
193+
output_vcf_path=vcf_out,
194+
vrs_attributes=vrs_attributes,
195+
assembly=assembly,
196+
compute_for_ref=(not skip_ref),
197+
require_validation=require_validation,
198+
output_pkl_path=pkl_out,
199+
output_ndjson_path=ndjson_out,
200+
)
201+
except VcfAnnotatorArgsError:
202+
msg = "No VCF, PKL, or NDJSON output path provided -- must set at least one of --vcf_out, --pkl_out, or --ndjson_out"
203+
if not silent:
204+
click.echo(msg)
205+
_logger.exception(msg)
206+
exit(1)
207+
200208
end = timer()
201209
msg = f"VCF Annotator finished in {(end - start):.5f} seconds"
202210
_logger.info(msg)

src/ga4gh/vrs/extras/annotator/vcf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class VcfAnnotatorError(Exception):
2323
"""Custom exceptions for VCF Annotator tool"""
2424

2525

26+
class VcfAnnotatorArgsError(VcfAnnotatorError):
27+
"""Raise for improper args passed to VCF annotator"""
28+
29+
2630
class FieldName(str, Enum):
2731
"""Define VCF field names for VRS annotations"""
2832

@@ -477,15 +481,15 @@ def raise_for_output_args(self, output_vcf_path: Path | None, **kwargs) -> None:
477481
:param output_vcf_path: VCF output path arg passed to `annotate()`
478482
:kwparam output_pkl_path: optional path to PKL output
479483
:kwparam output_ndjson_path: optional path to NDJSON output
480-
:raise VCFAnnotatorError: if no output args are shown
484+
:raise VCFAnnotatorArgsError: if no output args are given
481485
"""
482486
if (
483487
output_vcf_path is None
484488
and kwargs.get(self.pkl_arg_name) is None
485489
and kwargs.get(self.ndjson_arg_name) is None
486490
):
487491
msg = f"No VCF, PKL, or NDJSON output path provided -- must pass at least one of `output_vcf_path`, `{self.pkl_arg_name}`, `{self.ndjson_arg_name}` to annotate()."
488-
raise VcfAnnotatorError(msg)
492+
raise VcfAnnotatorArgsError(msg)
489493

490494
def on_vrs_object(
491495
self,

0 commit comments

Comments
 (0)