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

[Optimization] Profile and optimize https://api.outbreak.info/genomics/lineage-mutations #62

Open
flaneuse opened this issue Dec 2, 2022 · 2 comments
Assignees
Labels

Comments

@flaneuse
Copy link
Contributor

flaneuse commented Dec 2, 2022

See #61, #63

@newgene
Copy link
Contributor

newgene commented Jan 17, 2023

Let's start with this one. Many of these heavy query handlers use create_nested_mutation_query function to construct an ES query:

def create_nested_mutation_query(location_id = None, lineages = [], mutations = []):
# For multiple lineages and mutations: (Lineage 1 AND mutation 1 AND mutation 2..) OR (Lineage 2 AND mutation 1 AND mutation 2..) ...

Given this issue #59, this function needs to be changed to this:

def create_nested_mutation_query(location_id = None, lineages = [], mutations = [], genes=[]):
  • Let's confirm the logic here for each filter when passed with multiple values:

    • lineages --> OR
    • mutations --> AND (based on the current implementation, but should it be an OR?)
    • genes --> Should it be an AND or OR here?
  • Any other potential filtering field we might need from any handler?

@flaneuse
Copy link
Contributor Author

It should be:

  • lineages combined by OR
  • mutations combined by AND
  • genes combined by AND

For instance: the query:
lineages=["BA.1", "BA.5"], mutations=["S:E484K", "S:N501Y"], genes=["Orf1a", "S", N"]

would distribute the mutations to each of the lineages:

  1. filter records with `(pangolin_lineage == "BA.1" & mutations.mutation == "S:E484K" & mutations.mutation == "S:N501Y") | (pangolin_lineage == "BA.5" & mutations.mutation == "S:E484K" & mutations.mutation == "S:N501Y")"
  2. after identifying those records, collect the mutations objects and filter out gene == Orf1a | gene == S | gene == N
  3. using only those records, count mutations.mutation.

@gkarthik had proposed changing the combination of lineages and mutations to be more generic, however: #55

It's more work, but it'd be useful to make it more generic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants