Skip to content

fix(search): SMILES auto-detection and citations search button#803

Open
vcnainala wants to merge 2 commits into
developmentfrom
fix/search-query-detection
Open

fix(search): SMILES auto-detection and citations search button#803
vcnainala wants to merge 2 commits into
developmentfrom
fix/search-query-detection

Conversation

@vcnainala

@vcnainala vcnainala commented Jun 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix citations tab on the welcome page: the Search button used tagType=citation while Enter, example links, and SearchMolecule expect tagType=citations.
  • Fix SMILES auto-detection for ring notation (e.g. C1CCCCC1): queries were misclassified as molecular formulas and returned no results because molecular_formula = 'C1CCCCC1' never matches real data.
  • Add looksLikeMolecularFormula() to reject SMILES-like chains where the same element appears in consecutive tokens, while still accepting condensed formulas such as C6H12 and C6H12O6.
  • Add unit tests covering query type detection for SMILES, molecular formulas, CNP identifiers, and plain text.

Test plan

  • ./vendor/bin/phpunit tests/Unit/SearchMoleculeQueryTypeTest.php
  • ./vendor/bin/pint --test on changed PHP files
  • Search /search?q=C1CCCCC1 and confirm cyclohexane (and substructure matches) are returned
  • On the welcome page citations tab, click Search with a DOI and confirm results load (same as pressing Enter)
  • Confirm /search?q=C6H12 still performs molecular formula search

Resolves

Closes #754

vcnainala added 2 commits June 7, 2026 16:58
Align the citations tab search button with Enter key handling and the
backend tag handler by using tagType=citations and activeTab=citations.
Ring-closure SMILES such as C1CCCCC1 were misclassified as molecular
formulas because the element-token regex matched before the SMILES check.
Reject consecutive same-element tokens so these queries use RDKit search.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 6.39%. Comparing base (a4c26c6) to head (55320fb).
⚠️ Report is 4 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff                @@
##             development    #803      +/-   ##
================================================
+ Coverage           6.14%   6.39%   +0.24%     
- Complexity          1736    1741       +5     
================================================
  Files                227     227              
  Lines               8945    8973      +28     
================================================
+ Hits                 550     574      +24     
- Misses              8395    8399       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants