Skip to content

Commit 5028cca

Browse files
committed
adjusting colors
1 parent 9ee40ff commit 5028cca

File tree

3 files changed

+83
-54
lines changed

3 files changed

+83
-54
lines changed

bedhost/routers/bed_api.py

Lines changed: 80 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,11 @@ def get_regions_for_bedfile(
356356
)
357357
@count_requests(usage_data, event="bed_search")
358358
async def text_to_bed_search(
359-
query: str, genome: Optional[str] = "hg38", limit: int = 10, offset: int = 0
359+
query: str,
360+
genome: Optional[Union[str, None]] = None,
361+
assay: Optional[Union[str, None]] = None,
362+
limit: int = 10,
363+
offset: int = 0,
360364
):
361365
"""
362366
Search for a BedFile by a text query.
@@ -368,65 +372,90 @@ async def text_to_bed_search(
368372
_LOGGER.info(
369373
f"Searching for: '{query}' with limit='{limit}' and offset='{offset}' and genome='{genome}'"
370374
)
371-
372-
# results_sql = bbagent.bed.sql_search(
373-
# query, limit=round(limit / 2, 0), offset=round(offset / 2, 0)
374-
# )
375375
#
376-
# if results_sql.count > results_sql.offset:
377-
# qdrant_offset = offset - results_sql.offset
378-
# else:
379-
# qdrant_offset = offset - results_sql.count
376+
# # results_sql = bbagent.bed.sql_search(
377+
# # query, limit=round(limit / 2, 0), offset=round(offset / 2, 0)
378+
# # )
379+
# #
380+
# # if results_sql.count > results_sql.offset:
381+
# # qdrant_offset = offset - results_sql.offset
382+
# # else:
383+
# # qdrant_offset = offset - results_sql.count
384+
# #
385+
# # results_qdr = bbagent.bed.text_to_bed_search(
386+
# # query, limit=limit, offset=qdrant_offset - 1 if qdrant_offset > 0 else 0
387+
# # )
388+
# #
389+
# # results = BedListSearchResult(
390+
# # count=results_qdr.count,
391+
# # limit=limit,
392+
# # offset=offset,
393+
# # results=(results_sql.results + results_qdr.results)[0:limit],
394+
# # )
395+
# query = query.strip()
380396
#
381-
# results_qdr = bbagent.bed.text_to_bed_search(
382-
# query, limit=limit, offset=qdrant_offset - 1 if qdrant_offset > 0 else 0
383-
# )
397+
# if not genome or genome == "hg38":
398+
# spaceless_query = query.replace(" ", "")
399+
# if len(spaceless_query) == 32 and spaceless_query == query:
400+
# try:
401+
# similar_results = bbagent.bed.get_neighbours(
402+
# query, limit=limit, offset=offset
403+
# )
384404
#
385-
# results = BedListSearchResult(
386-
# count=results_qdr.count,
387-
# limit=limit,
388-
# offset=offset,
389-
# results=(results_sql.results + results_qdr.results)[0:limit],
390-
# )
391-
query = query.strip()
392-
393-
if not genome or genome == "hg38":
394-
spaceless_query = query.replace(" ", "")
395-
if len(spaceless_query) == 32 and spaceless_query == query:
396-
try:
397-
similar_results = bbagent.bed.get_neighbours(
398-
query, limit=limit, offset=offset
399-
)
400-
401-
if similar_results.results and offset == 0:
402-
403-
result = QdrantSearchResult(
404-
id=query,
405-
payload={},
406-
score=1.0,
407-
metadata=bbagent.bed.get(query),
408-
)
409-
410-
similar_results.results.insert(0, result)
411-
return similar_results
412-
except Exception as _:
413-
pass
414-
415-
results = bbagent.bed.text_to_bed_search(
416-
query,
417-
limit=limit,
418-
offset=offset,
419-
)
420-
else:
421-
results = bbagent.bed.sql_search(
422-
query, limit=limit, offset=offset, genome=genome
423-
)
405+
# if similar_results.results and offset == 0:
406+
#
407+
# result = QdrantSearchResult(
408+
# id=query,
409+
# payload={},
410+
# score=1.0,
411+
# metadata=bbagent.bed.get(query),
412+
# )
413+
#
414+
# similar_results.results.insert(0, result)
415+
# return similar_results
416+
# except Exception as _:
417+
# pass
418+
419+
results = bbagent.bed.comp_search(
420+
query,
421+
genome_alias=genome,
422+
assay=assay,
423+
limit=limit,
424+
offset=offset,
425+
)
426+
# else:
427+
# results = bbagent.bed.sql_search(
428+
# query, limit=limit, offset=offset, genome=genome
429+
# )
424430

425431
if results:
426432
return results
427433
raise HTTPException(status_code=404, detail="No records found")
428434

429435

436+
@router.post(
437+
"/search/exact",
438+
summary="Search for exact match of metadata in bed files",
439+
tags=["search"],
440+
response_model=BedListSearchResult,
441+
response_model_by_alias=False,
442+
)
443+
async def text_to_bed_search(
444+
query: str,
445+
genome: Optional[Union[str, None]] = None,
446+
assay: Optional[Union[str, None]] = None,
447+
limit: int = 10,
448+
offset: int = 0,
449+
):
450+
bbagent.bed.sql_search(
451+
query=query,
452+
genome=genome,
453+
assay=assay,
454+
limit=limit,
455+
offset=offset,
456+
)
457+
458+
430459
@router.post(
431460
"/search/bed",
432461
summary="Search for similar bed files",

deployment/config/api-dev.bedbase.org.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ database:
99
port: 5432
1010
password: $POSTGRES_PASSWORD
1111
user: $POSTGRES_USER
12-
database: bedbase2
12+
database: bedbase
1313
qdrant:
1414
host: $QDRANT_HOST
1515
port: 6333

requirements/requirements-all.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# bbconf @ git+https://github.com/databio/bbconf.git@dev#egg=bbconf
2-
bbconf>=0.11.4
1+
bbconf @ git+https://github.com/databio/bbconf.git@comp_search#egg=bbconf
2+
# bbconf>=0.11.4
33
fastapi>=0.103.0
44
logmuse>=0.2.7
55
markdown

0 commit comments

Comments
 (0)