Skip to content

Commit 3c1537a

Browse files
authored
Merge pull request #95 from VariantEffect/ashsny/target-gene-reference-fix
Fix ongoing 500s and broken homepage search links by updating target organism search .to match new schema.
2 parents 8faeffc + ce09750 commit 3c1537a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/mavedb/lib/score_sets.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from mavedb.models.score_set import ScoreSet
2626
from mavedb.models.target_accession import TargetAccession
2727
from mavedb.models.target_gene import TargetGene
28+
from mavedb.models.target_sequence import TargetSequence
2829
from mavedb.models.user import User
2930
from mavedb.view_models.search import ScoreSetsSearch
3031

@@ -55,7 +56,14 @@ def search_score_sets(db: Session, owner: Optional[User], search: ScoreSetsSearc
5556
ScoreSet.target_genes.any(func.lower(TargetGene.name).contains(lower_search_text)),
5657
ScoreSet.target_genes.any(func.lower(TargetGene.category).contains(lower_search_text)),
5758
ScoreSet.keyword_objs.any(func.lower(Keyword.text).contains(lower_search_text)),
58-
# TODO Add: ORGANISM_NAME UNIPROT, ENSEMBL, REFSEQ, LICENSE, plus TAX_ID if numeric
59+
ScoreSet.target_genes.any(
60+
TargetGene.target_sequence.has(
61+
TargetSequence.reference.has(
62+
func.lower(ReferenceGenome.organism_name).contains(lower_search_text)
63+
)
64+
)
65+
),
66+
# TODO(#94): add UNIPROT, ENSEMBL, REFSEQ, LICENSE, plus TAX_ID if numeric
5967
ScoreSet.publication_identifiers.any(
6068
func.lower(PublicationIdentifier.identifier).contains(lower_search_text)
6169
),
@@ -82,7 +90,9 @@ def search_score_sets(db: Session, owner: Optional[User], search: ScoreSetsSearc
8290
if search.target_organism_names:
8391
query = query.filter(
8492
ScoreSet.target_genes.any(
85-
TargetGene.reference.any(ReferenceGenome.organism_name.in_(search.target_organism_names))
93+
TargetGene.target_sequence.has(
94+
TargetSequence.reference.has(ReferenceGenome.organism_name.in_(search.target_organism_names))
95+
)
8696
)
8797
)
8898

0 commit comments

Comments
 (0)