Skip to content

Establish an API for VariantLookup classes #88

Description

@msto

There has been lengthy discussion over what an appropriate API for the VariantLookup functionality should look like.

Currently, VariantLookup is an ABC with two concrete implementations - one for file-based lookups and one for cached, in-memory lookups.

An initial refactoring was begun in #62, to permit the user to interact with Primer3 without direct use of a VariantLookup.

In the course of #71, there was additional discussion over how we might want to expose (or hide) the various implementations.

An API that hides the details of implementation from the user might look as follows, making the current ABC and implementations hidden and storing the lookup as an attribute on a public class.

class VariantLookup:
    def __init__(...):
        ...
        self._lookup: _VariantLookup
        if cached:
            self._lookup = _InMemoryLookup()
        else:
            self._lookup = _DiskBasedLookup()
            
    def query(...):
        return self._lookup.query(...)

class _VariantLookup(ABC):
    ...

class _InMemoryLookup(_VariantLookup):
    ...

class _DiskBasedLookup(_VariantLookup):
    ...

Other points to take into consideration - we should be cautious of the constraints imposed by a common constructor since there will be some parameters specific to each concrete implementation1, and we should establish an initial set of parameters and methods that are universal (e.g. close())2.

Footnotes

  1. https://github.com/fulcrumgenomics/prymer/pull/71#discussion_r1805044436

  2. https://github.com/fulcrumgenomics/prymer/pull/71#pullrequestreview-2434670717

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions