fix Reaction cord

This commit is contained in:
2025-08-04 16:10:57 +08:00
parent eadf4820c3
commit e3eb7aeeec
3 changed files with 11 additions and 6 deletions

View File

@ -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("成功查询物质基本信息,正在获取更多数据。")