From e3eb7aeeec9d67d271fcfca30705db3fce226ca6 Mon Sep 17 00:00:00 2001 From: flt6 <1404262047@qq.com> Date: Mon, 4 Aug 2025 16:10:57 +0800 Subject: [PATCH] fix Reaction cord --- .gitignore | 4 +++- cord/pyproject.toml | 3 +-- mw_tool/main.py | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 53c67e9..9b9be86 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ __pycache__ *.mp3 *.mp4 *.log -test \ No newline at end of file +test +.venv +uv.lock \ No newline at end of file diff --git a/cord/pyproject.toml b/cord/pyproject.toml index a63ea70..1ecab29 100644 --- a/cord/pyproject.toml +++ b/cord/pyproject.toml @@ -1,8 +1,7 @@ [project] -name = "tmp2" +name = "Reaction-Cord" version = "0.1.0" description = "Add your description here" -readme = "README.md" requires-python = ">=3.10" dependencies = [ "matplotlib>=3.10.5", diff --git a/mw_tool/main.py b/mw_tool/main.py index 2d2b024..319d686 100644 --- a/mw_tool/main.py +++ b/mw_tool/main.py @@ -25,14 +25,18 @@ def search_compound(query): except Exception: st.error("使用smiles精确查询失败") # 尝试通过化学式搜索 + if not (isinstance(compounds, list) and len(compounds) != 0): + # 尝试通过名称搜索 + try: + compounds = pcp.get_compounds(query, 'name', listkey_count=3) + except Exception: + st.error("使用名称查询失败") + if not (isinstance(compounds, list) and len(compounds) != 0): try: compounds = pcp.get_compounds(query, 'formula', listkey_count=3) except Exception: st.error("使用化学式精确查询失败") - if not (isinstance(compounds, list) and len(compounds) != 0): - # 尝试通过名称搜索 - compounds = pcp.get_compounds(query, 'name', listkey_count=3) if isinstance(compounds, list) and len(compounds) > 0: st.info("成功查询物质基本信息,正在获取更多数据。")