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

Add callback support for VCF annotator #474

Open
jsstevenson opened this issue Dec 24, 2024 · 1 comment · May be fixed by #502
Open

Add callback support for VCF annotator #474

jsstevenson opened this issue Dec 24, 2024 · 1 comment · May be fixed by #502
Labels
enhancement New feature or request

Comments

@jsstevenson
Copy link
Contributor

jsstevenson commented Dec 24, 2024

Second, this may be an opportunity to improve the relationship between AnyVar and vrs-python. The AnyVar VcfRegistrar extends VCFAnnotator and overrides the internal _get_vrs_object() method. The only reason for doing so is to integrate with the AnyVar object store. But then AnyVar does not actually re-implement all the vrs-python functionality, which means there will be continual drift between the two implementations. It seems like whether you annotate a VCF with VRS IDs directly in vrs-python or via AnyVar that the behavior and result should be the same. That would make the tools easier to adopt and use. So perhaps a re-design of the vrs-python VCFAnnotator to provide a listener or callback. For example:

class VCFAnnotator:
  # ...existing implementation...

  def on_vrs_object(self, vcf_coords: str, vrs_object: VrsObject) -> bool:
    """Called for each calculated VRS object prior to it being added to the VCF file.
    :param vcf_coords: The VCF coordinates of the VRS object
    :param vrs_object: The computed VRS object
    :return:  True if the VRS object should be added to the output VCF, False otherwise
    """
    return True

# And in AnyVar
class VcfRegistrar(VCFAnnotator):
  def on_vrs_object(self, vcf_coords: str, vrs_object: VrsObject) -> bool:
    self.av.put_object(vrs_object)
    return True

originally posted by @ehclark in #470 (comment)

@jsstevenson jsstevenson added the enhancement New feature or request label Dec 24, 2024
@jsstevenson
Copy link
Contributor Author

One additional thought here -- we currently package a PKL dump directly into the annotator class, but it seems like this is the kind of thing that would make more sense as an optional side-effect like Eugene is describing above. I'd have to think a bit more about the mechanics of passing in a file on the basis of each annotate() call (maybe it's just gotta be in **kwargs), but we could probably just define helper functions for pkl, json, ndjson and plug them all in for the CLI as optional outputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant