Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optionally suppress console output #445

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/ga4gh/vrs/extras/vcf_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,18 @@ class SeqRepoProxyType(str, Enum):
show_default=True,
help="Require validation checks to pass in order to return a VRS object"
)
@click.option(
"--silent",
"-s",
is_flag=True,
default=False,
help="Suppress messages printed to stdout"
)
def annotate_click( # pylint: disable=too-many-arguments
vcf_in: str, vcf_out: Optional[str], vrs_pickle_out: Optional[str],
vrs_attributes: bool, seqrepo_dp_type: SeqRepoProxyType, seqrepo_root_dir: str,
seqrepo_base_url: str, assembly: str, skip_ref: bool, require_validation: bool
seqrepo_base_url: str, assembly: str, skip_ref: bool, require_validation: bool,
silent: bool,
) -> None:
"""Annotate VCF file via click

Expand All @@ -124,15 +132,17 @@ def annotate_click( # pylint: disable=too-many-arguments
start = timer()
msg = f"Annotating {vcf_in} with the VCF Annotator..."
_logger.info(msg)
click.echo(msg)
if not silent:
click.echo(msg)
annotator.annotate(
vcf_in, vcf_out=vcf_out, vrs_pickle_out=vrs_pickle_out,
vrs_attributes=vrs_attributes, assembly=assembly,
compute_for_ref=(not skip_ref), require_validation=require_validation
)
end = timer()
msg = f"VCF Annotator finished in {(end - start):.5f} seconds"
_logger.info(msg)
if not silent:
_logger.info(msg)
click.echo(msg)

class VCFAnnotator: # pylint: disable=too-few-public-methods
Expand Down