Skip to content

Commit

Permalink
Improve search string parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
WhoisDonlee committed Apr 3, 2024
1 parent 94f1bf0 commit c7fdc8a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions search.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,25 @@ def parse_search(search) -> dict:
The main search parsing function, it calls all the other functions
and just adds all the metadata that is identified together
"""
# Ignore exon+number and strip whitespaces
search = re.sub(r'exon.*(?=:)', '', search).replace(" ", "")
result = parse_rs(search)

transcript = parse_transcript(search)
if transcript:
result.update(transcript)
result.update(parse_cdot(search))

else: # gene:cdot check
result.update(parse_gene_cdot(search))

# rename cdot to gene_cdot
# so there is a diff between transcript:cdot and gene:cdot
result["gene_cdot"] = result["cdot"]
del result["cdot"]
else: # gene:cdot check
try:
result.update(parse_gene_cdot(search))

# rename cdot to gene_cdot
# so there is a diff between transcript:cdot and gene:cdot
result["gene_cdot"] = result["cdot"]
del result["cdot"]
except Exception as e:
print(f"Invalid or missing result: {e}")

if "cdot_ref" in result:
result["ref"] = result["cdot_ref"]
Expand Down

0 comments on commit c7fdc8a

Please sign in to comment.