Skip to content

Commit

Permalink
fix(ncbi_type_material): Update type material designation in general …
Browse files Browse the repository at this point in the history
…search.
  • Loading branch information
aaronmussig committed Sep 3, 2024
1 parent 39fa6d3 commit f4650c6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions api/controller/search.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import re
import shlex
from typing import List

import sqlalchemy as sa
from sqlalchemy.orm import Session
from typing import List

from api.db.models import GtdbSearchMtView
from api.exceptions import HttpBadRequest
Expand Down Expand Up @@ -83,7 +83,7 @@ def search_gtdb(request: SearchGtdbRequest, db: Session) -> SearchGtdbResponse:
GtdbSearchMtView.ncbi_genbank_assembly_accession,
GtdbSearchMtView.ncbi_type_material_designation,
GtdbSearchMtView.gtdb_representative]).
where(sa.or_(*where_clause))
where(sa.or_(*where_clause))
)

# Filters
Expand Down Expand Up @@ -152,18 +152,26 @@ def search_gtdb(request: SearchGtdbRequest, db: Session) -> SearchGtdbResponse:
# if len(list(survey_hits)) > 0:
# out_survey = request.search # TODO: ??

ncbi_type_material_categories = frozenset({
'assembly from type material',
'assembly designated as neotype',
'assembly designated as reftype',
'assembly designated as neotype',
})

# Apply filters and create objects
out_rows = list()
for hit in all_rows:
out_rows.append(
SearchGtdbRow(gid=hit.id_at_source,
accession=hit.id_at_source,
ncbiOrgName=hit.ncbi_organism_name,
ncbiTaxonomy=hit.ncbi_taxonomy,
gtdbTaxonomy=hit.gtdb_taxonomy,
isGtdbSpeciesRep=hit.gtdb_representative is True,
isNcbiTypeMaterial=hit.ncbi_type_material_designation is not None
)
SearchGtdbRow(
gid=hit.id_at_source,
accession=hit.id_at_source,
ncbiOrgName=hit.ncbi_organism_name,
ncbiTaxonomy=hit.ncbi_taxonomy,
gtdbTaxonomy=hit.gtdb_taxonomy,
isGtdbSpeciesRep=hit.gtdb_representative is True,
isNcbiTypeMaterial=hit.ncbi_type_material_designation in ncbi_type_material_categories
)
)

return SearchGtdbResponse(rows=out_rows, totalRows=total_rows)

0 comments on commit f4650c6

Please sign in to comment.