Skip to content

Commit

Permalink
Merge branch 'main' into click-options
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Sep 3, 2024
2 parents 1e20932 + 70332f1 commit d749fed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
33 changes: 21 additions & 12 deletions src/ga4gh/vrs/extras/vcf_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
import pickle
from enum import Enum
from typing import Dict, List, Optional
from timeit import default_timer as timer

import click
Expand Down Expand Up @@ -107,10 +106,18 @@ class SeqRepoProxyType(str, Enum):
default=False,
help="Require validation checks to pass to annotate a record with 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: pathlib.Path, vcf_out: Optional[pathlib.Path], vrs_pickle_out: Optional[pathlib.Path],
vcf_in: pathlib.Path, vcf_out: pathlib.Path | None, vrs_pickle_out: pathlib.Path | None,
vrs_attributes: bool, seqrepo_dp_type: SeqRepoProxyType, seqrepo_root_dir: pathlib.Path,
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:
"""Extract VRS objects from VCF located at VCF_IN.
Expand All @@ -122,15 +129,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(
str(vcf_in.absolute()), vcf_out=vcf_out_str, vrs_pickle_out=vrs_pkl_out_str,
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 Expand Up @@ -173,8 +182,8 @@ def __init__(self, seqrepo_dp_type: SeqRepoProxyType = SeqRepoProxyType.LOCAL,

@use_ga4gh_compute_identifier_when(VrsObjectIdentifierIs.MISSING)
def annotate( # pylint: disable=too-many-arguments,too-many-locals
self, vcf_in: str, vcf_out: Optional[str] = None,
vrs_pickle_out: Optional[str] = None, vrs_attributes: bool = False,
self, vcf_in: str, vcf_out: str | None = None,
vrs_pickle_out: str | None = None, vrs_attributes: bool = False,
assembly: str = "GRCh38", compute_for_ref: bool = True,
require_validation: bool = True
) -> None:
Expand Down Expand Up @@ -271,8 +280,8 @@ def annotate( # pylint: disable=too-many-arguments,too-many-locals
pickle.dump(vrs_data, wf)

def _get_vrs_object( # pylint: disable=too-many-arguments,too-many-locals
self, vcf_coords: str, vrs_data: Dict, vrs_field_data: Dict, assembly: str,
vrs_data_key: Optional[str] = None, output_pickle: bool = True,
self, vcf_coords: str, vrs_data: dict, vrs_field_data: dict, assembly: str,
vrs_data_key: str | None = None, output_pickle: bool = True,
output_vcf: bool = False, vrs_attributes: bool = False,
require_validation: bool = True
) -> None:
Expand Down Expand Up @@ -350,11 +359,11 @@ def _get_vrs_object( # pylint: disable=too-many-arguments,too-many-locals
vrs_field_data[self.VRS_STATES_FIELD].append(alt)

def _get_vrs_data( # pylint: disable=too-many-arguments,too-many-locals
self, record: pysam.VariantRecord, vrs_data: Dict, assembly: str, # pylint: disable=no-member
additional_info_fields: List[str], vrs_attributes: bool = False,
self, record: pysam.VariantRecord, vrs_data: dict, assembly: str, # pylint: disable=no-member
additional_info_fields: list[str], vrs_attributes: bool = False,
output_pickle: bool = True, output_vcf: bool = True,
compute_for_ref: bool = True, require_validation: bool = True
) -> Dict:
) -> dict:
"""Get VRS data for record's reference and alt alleles.
:param pysam.VariantRecord record: A row in the VCF file
Expand Down
2 changes: 1 addition & 1 deletion submodules/vrs
Submodule vrs updated 68 files
+1 −1 .requirements.txt
+0 −27 docs/source/concepts/MolecularVariation/DerivativeMolecule.rst
+0 −16 docs/source/concepts/MolecularVariation/Terminus.rst
+0 −21 docs/source/concepts/SequenceReference.rst
+0 −32 docs/source/concepts/SystemicVariation/CopyNumber.rst
+4 −5 docs/source/concepts/index.rst
+3 −3 docs/source/concepts/location/SequenceLocation.rst
+2 −3 docs/source/concepts/location/index.rst
+1 −1 docs/source/concepts/molecular_variation/Adjacency.rst
+0 −0 docs/source/concepts/molecular_variation/Allele.rst
+0 −0 docs/source/concepts/molecular_variation/CisPhasedBlock.rst
+15 −0 docs/source/concepts/molecular_variation/DerivativeMolecule.rst
+0 −0 docs/source/concepts/molecular_variation/SequenceTerminus.rst
+6 −3 docs/source/concepts/molecular_variation/index.rst
+0 −0 docs/source/concepts/sequence_expression/LengthExpression.rst
+0 −0 docs/source/concepts/sequence_expression/LiteralSequenceExpression.rst
+0 −0 docs/source/concepts/sequence_expression/ReferenceLengthExpression.rst
+7 −2 docs/source/concepts/sequence_expression/index.rst
+41 −0 docs/source/concepts/systemic_variation/CopyNumber.rst
+14 −4 docs/source/concepts/systemic_variation/index.rst
+0 −93 examples/sv_derivative_molecule.yaml
+78 −0 examples/sv_derivative_sequence.yaml
+1 −1 examples/terminal_breakend.yaml
+0 −1 schema/core-im
+0 −1 schema/data-types
+1 −0 schema/gks-common
+0 −0 schema/gks-domain-entities
+60 −56 schema/vrs/def/Adjacency.rst
+56 −52 schema/vrs/def/Allele.rst
+56 −52 schema/vrs/def/CisPhasedBlock.rst
+52 −48 schema/vrs/def/CopyNumber.rst
+56 −52 schema/vrs/def/CopyNumberChange.rst
+56 −52 schema/vrs/def/CopyNumberCount.rst
+0 −58 schema/vrs/def/DerivativeMolecule.rst
+58 −0 schema/vrs/def/DerivativeSequence.rst
+0 −29 schema/vrs/def/Expression.rst
+46 −42 schema/vrs/def/Ga4ghIdentifiableObject.rst
+44 −40 schema/vrs/def/LengthExpression.rst
+44 −40 schema/vrs/def/LiteralSequenceExpression.rst
+52 −48 schema/vrs/def/ReferenceLengthExpression.rst
+41 −37 schema/vrs/def/SequenceExpression.rst
+60 −56 schema/vrs/def/SequenceLocation.rst
+53 −49 schema/vrs/def/SequenceReference.rst
+58 −0 schema/vrs/def/SequenceTerminus.rst
+0 −54 schema/vrs/def/Terminus.rst
+0 −50 schema/vrs/def/TraversalBlock.rst
+3 −0 schema/vrs/def/ValueObject.rst
+48 −44 schema/vrs/def/Variation.rst
+14 −5 schema/vrs/json/Adjacency
+12 −4 schema/vrs/json/Allele
+12 −4 schema/vrs/json/CisPhasedBlock
+24 −6 schema/vrs/json/CopyNumberChange
+12 −4 schema/vrs/json/CopyNumberCount
+30 −17 schema/vrs/json/DerivativeSequence
+0 −38 schema/vrs/json/Expression
+10 −2 schema/vrs/json/LengthExpression
+10 −2 schema/vrs/json/LiteralSequenceExpression
+2 −2 schema/vrs/json/MolecularVariation
+10 −2 schema/vrs/json/ReferenceLengthExpression
+11 −3 schema/vrs/json/SequenceLocation
+10 −2 schema/vrs/json/SequenceReference
+19 −11 schema/vrs/json/SequenceTerminus
+0 −80 schema/vrs/json/TraversalBlock
+2 −2 schema/vrs/json/Variation
+60 −117 schema/vrs/vrs-source.yaml
+1 −1 submodules/gks-common
+4 −4 tests/test_definitions.yaml
+80 −92 validation/models.yaml

0 comments on commit d749fed

Please sign in to comment.