2525from mavedb .models .score_set import ScoreSet
2626from mavedb .models .target_accession import TargetAccession
2727from mavedb .models .target_gene import TargetGene
28+ from mavedb .models .target_sequence import TargetSequence
2829from mavedb .models .user import User
2930from 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