Spaces:
Running
Running
guide: correct starters for molecule-endpoint and derived boards
Browse files- data/selectivity_card.json +3 -1
- data/solubility_card.json +3 -1
- data/withdrawal_card.json +3 -1
- index.html +111 -0
data/selectivity_card.json
CHANGED
|
@@ -44,5 +44,7 @@
|
|
| 44 |
"answer_grade_note": "์์๋ฃ๋ ๊ณต๊ฐ์ง๋ง ๋ ๋ถ๋ฌธ์ ๊ฒน์ณ ๋ง๋ ์ด ํ๋ณธ์ ์ฐ๋ฆฌ ๊ฒ์ด๋ค",
|
| 45 |
"source": "ChEMBL_37 ์ฌํ๋ ์ด์
ยท hERG x ํ์ 19์ข
",
|
| 46 |
"axis": "K",
|
| 47 |
-
"built": "2026-08-23"
|
|
|
|
|
|
|
| 48 |
}
|
|
|
|
| 44 |
"answer_grade_note": "์์๋ฃ๋ ๊ณต๊ฐ์ง๋ง ๋ ๋ถ๋ฌธ์ ๊ฒน์ณ ๋ง๋ ์ด ํ๋ณธ์ ์ฐ๋ฆฌ ๊ฒ์ด๋ค",
|
| 45 |
"source": "ChEMBL_37 ์ฌํ๋ ์ด์
ยท hERG x ํ์ 19์ข
",
|
| 46 |
"axis": "K",
|
| 47 |
+
"built": "2026-08-23",
|
| 48 |
+
"query_kind": "derived",
|
| 49 |
+
"query_note": "๋จ์ผ ์ธก์ ์ด ์๋๋ผ ๋ ๊ฐ์ ์ฐจ์ด๋ค. ์์ ์ญ = ํ์ ํ์ฑ(p) - hERG ํ์ฑ(p). ๊ฐ ํ์ ๊ณผ hERG(CHEMBL240) ํ์ฑ์ ๋ฐ๋ก ๋ชจ์ ํํฉ๋ฌผ๋ณ๋ก ๋นผ์ ๋ง๋ ๋ค. ์ค์ธก์์ ์์ชฝ์ ๋ฐ๋ก ์์ธกํด ๋นผ๋ ์ชฝ์ด ์ฐจ์ด๋ฅผ ์ง์ ํ์ตํ๋ ๊ฒ๋ณด๋ค ์ข์๋ค."
|
| 50 |
}
|
data/solubility_card.json
CHANGED
|
@@ -39,5 +39,7 @@
|
|
| 39 |
"answer_grade": "P2",
|
| 40 |
"answer_grade_note": "์์๋ฃ๋ ๊ณต๊ฐ์ง๋ง ์ด์ธ์ด ์ ๋ณ๊ณผ ๋ชฐ๋๋ ํ์ฐ์ด ์ฐ๋ฆฌ ํ๋ณธ์ ๋ง๋ ๋ค. ๊ณต๊ฐ DB ๋ฅผ ๊ทธ๋๋ก ์กฐํํด์๋ ๊ฐ์ ๊ฐ์ด ๋์ค์ง ์๋๋ค",
|
| 41 |
"source": "ChEMBL_37 ์ฌํ๋ ์ด์
",
|
| 42 |
-
"built": "2026-08-22"
|
|
|
|
|
|
|
| 43 |
}
|
|
|
|
| 39 |
"answer_grade": "P2",
|
| 40 |
"answer_grade_note": "์์๋ฃ๋ ๊ณต๊ฐ์ง๋ง ์ด์ธ์ด ์ ๋ณ๊ณผ ๋ชฐ๋๋ ํ์ฐ์ด ์ฐ๋ฆฌ ํ๋ณธ์ ๋ง๋ ๋ค. ๊ณต๊ฐ DB ๋ฅผ ๊ทธ๋๋ก ์กฐํํด์๋ ๊ฐ์ ๊ฐ์ด ๋์ค์ง ์๋๋ค",
|
| 41 |
"source": "ChEMBL_37 ์ฌํ๋ ์ด์
",
|
| 42 |
+
"built": "2026-08-22",
|
| 43 |
+
"stype": "Solubility",
|
| 44 |
+
"query_note": "ChEMBL activity ์๋ํฌ์ธํธ์์ standard_type=Solubility ๋ก ๋ฐ๋, ๊ฐ์ ์ด๋ฆ ์๋ ๋จ๋ฐฑ์ง ์ฉํด๋๊น์ง ์์ฌ ์์ด assay ์ค๋ช
์ผ๋ก ๊ฑธ๋ฌ์ผ ํ๋ค."
|
| 45 |
}
|
data/withdrawal_card.json
CHANGED
|
@@ -40,5 +40,7 @@
|
|
| 40 |
"answer_grade": "P1",
|
| 41 |
"answer_grade_note": "ํด์ถ ๊ธฐ๋ก์ ๊ณต๊ฐ ์๋ฃ๋ค. ์กฐํ ๋ฐฉ์ด๋ 8์กฐ๊ฐ ๋ด๋นํ๋ค",
|
| 42 |
"source": "ChEMBL_37 ์น์ธยทํด์ถ ๊ธฐ๋ก",
|
| 43 |
-
"built": "2026-08-22"
|
|
|
|
|
|
|
| 44 |
}
|
|
|
|
| 40 |
"answer_grade": "P1",
|
| 41 |
"answer_grade_note": "ํด์ถ ๊ธฐ๋ก์ ๊ณต๊ฐ ์๋ฃ๋ค. ์กฐํ ๋ฐฉ์ด๋ 8์กฐ๊ฐ ๋ด๋นํ๋ค",
|
| 42 |
"source": "ChEMBL_37 ์น์ธยทํด์ถ ๊ธฐ๋ก",
|
| 43 |
+
"built": "2026-08-22",
|
| 44 |
+
"query_kind": "molecule",
|
| 45 |
+
"query_note": "ํ์ฑ ์กฐํ๊ฐ ์๋๋ค. ChEMBL molecule ์๋ํฌ์ธํธ์์ ์น์ธ ์๋ถ์๋ฅผ ๋ฐ์ withdrawn_flag ๋ก ๋ผ๋ฒจ์ ๋ง๋ ๋ค (first_approval ์๋ Small molecule ๋ง)."
|
| 46 |
}
|
index.html
CHANGED
|
@@ -592,6 +592,11 @@ function starterFor(b){
|
|
| 592 |
์ฐธ๊ฐ์์๊ฒ ์ฃผ๊ณ ์์๋ค. ๊ทธ๋๋ก ๋๋ฆฌ๋ฉด ๋น ํ๋ จ์
์ด ๋์จ๋ค. */
|
| 593 |
const isChembl=/^CHEMBL[0-9]+$/.test(String(b.target||""));
|
| 594 |
const stype=b.stype||b.type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
if(!isChembl && !b.stype) return starterNoChembl(b);
|
| 596 |
const q=[` q = {"standard_type": "${stype}", "standard_relation": "=",`];
|
| 597 |
if(isChembl) q.push(` "target_chembl_id": "${b.target}",`);
|
|
@@ -658,6 +663,112 @@ b.clip?` if ${b.clip[0]} <= float(np.median(v["p"])) <= ${b.clip[1]}} #
|
|
| 658 |
/* ChEMBL ์์ ๋์ค์ง ์๋ ๋ถ๋ฌธ. ์กฐํ๋ฌธ์ ์ง์ด๋ด์ง ์๊ณ , ์๋ฃ๊ฐ ์ด๋ ์๋์ง ๋ฐํ๋ค.
|
| 659 |
ํ๋ จ ๋ผ๋ฒจ์ ์ฐ๋ฆฌ๊ฐ ๋ง๋ ํ๋ณธ์ด๋ฏ๋ก ๋์ ๋ง๋ค์ด ์ค ์ ์๋ค - ๊ท์น ๊ทธ๋๋ก,
|
| 660 |
์ฐธ๊ฐ์๊ฐ ๊ณต๊ฐ ์๋ฃ๋ฅผ ์ง์ ํ๋ ์ด์
ํ๋ค. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
function starterNoChembl(b){
|
| 662 |
return [
|
| 663 |
`# ${b.board} ์ ์ถ ๋ผ๋`,
|
|
|
|
| 592 |
์ฐธ๊ฐ์์๊ฒ ์ฃผ๊ณ ์์๋ค. ๊ทธ๋๋ก ๋๋ฆฌ๋ฉด ๋น ํ๋ จ์
์ด ๋์จ๋ค. */
|
| 593 |
const isChembl=/^CHEMBL[0-9]+$/.test(String(b.target||""));
|
| 594 |
const stype=b.stype||b.type;
|
| 595 |
+
/* ํ์ฑ ์กฐํ๋ก ๋ง๋ค์ด์ง์ง ์๋ ๋ถ๋ฌธ์ด ๋ ์ข
๋ฅ ๋ ์๋ค. ์น์ธยทํด์ถ ๋ถ๋ฌธ์ molecule
|
| 596 |
+
์๋ํฌ์ธํธ๋ฅผ ์ฐ๊ณ , ์์ ์ญ ๋ถ๋ฌธ์ ๋ ๊ฐ์ ์ฐจ์ด๋ค. ์ด ์
์ ํ ๋ฉ์ด๋ฆฌ๋ก ๋ฌถ์ด
|
| 597 |
+
"ChEMBL ์์ ๋์ค์ง ์๋๋ค"๊ณ ์ ์ผ๋ฉด ์ฌ์ค์ด ์๋ ์๋ด๊ฐ ๋๋ค - ์
๋ค ChEMBL ์ด๋ค. */
|
| 598 |
+
if(b.query_kind==="molecule") return starterMolecule(b);
|
| 599 |
+
if(b.query_kind==="derived") return starterDerived(b);
|
| 600 |
if(!isChembl && !b.stype) return starterNoChembl(b);
|
| 601 |
const q=[` q = {"standard_type": "${stype}", "standard_relation": "=",`];
|
| 602 |
if(isChembl) q.push(` "target_chembl_id": "${b.target}",`);
|
|
|
|
| 663 |
/* ChEMBL ์์ ๋์ค์ง ์๋ ๋ถ๋ฌธ. ์กฐํ๋ฌธ์ ์ง์ด๋ด์ง ์๊ณ , ์๋ฃ๊ฐ ์ด๋ ์๋์ง ๋ฐํ๋ค.
|
| 664 |
ํ๋ จ ๋ผ๋ฒจ์ ์ฐ๋ฆฌ๊ฐ ๋ง๋ ํ๋ณธ์ด๋ฏ๋ก ๋์ ๋ง๋ค์ด ์ค ์ ์๋ค - ๊ท์น ๊ทธ๋๋ก,
|
| 665 |
์ฐธ๊ฐ์๊ฐ ๊ณต๊ฐ ์๋ฃ๋ฅผ ์ง์ ํ๋ ์ด์
ํ๋ค. */
|
| 666 |
+
function starterMolecule(b){
|
| 667 |
+
/* ์น์ธยทํด์ถ ๋ถ๋ฌธ. ํ์ฑ ์กฐํ๊ฐ ์๋๋ผ molecule ์๋ํฌ์ธํธ์์ ์น์ธ ์๋ถ์๋ฅผ ๋ฐ๋๋ค. */
|
| 668 |
+
return [
|
| 669 |
+
`# ${b.board} ์ ์ถ ๋ผ๋`,
|
| 670 |
+
`#`,
|
| 671 |
+
`# ${b.query_note||"ํ์ฑ ์กฐํ๊ฐ ์๋๋ผ molecule ์๋ํฌ์ธํธ๋ฅผ ์ด๋ค."}`,
|
| 672 |
+
``,
|
| 673 |
+
`import json, requests, numpy as np`,
|
| 674 |
+
`from rdkit import Chem`,
|
| 675 |
+
`from rdkit.Chem import rdFingerprintGenerator`,
|
| 676 |
+
`import lightgbm as lgb`,
|
| 677 |
+
``,
|
| 678 |
+
`# 1) ์น์ธ ์๋ถ์ ๋ชฉ๋ก (ํ์ฑ์ด ์๋๋ผ ๋ถ์ ์์ฒด๋ฅผ ๋ฐ๋๋ค)`,
|
| 679 |
+
`API = "https://www.ebi.ac.uk/chembl/api/data/molecule.json"`,
|
| 680 |
+
`rows, off = [], 0`,
|
| 681 |
+
`while True:`,
|
| 682 |
+
` q = {"max_phase": 4, "molecule_type": "Small molecule",`,
|
| 683 |
+
` "limit": 1000, "offset": off}`,
|
| 684 |
+
` d = requests.get(API, params=q, timeout=180).json()`,
|
| 685 |
+
` rows += d["molecules"]; off += 1000`,
|
| 686 |
+
` if off >= d["page_meta"]["total_count"]: break`,
|
| 687 |
+
``,
|
| 688 |
+
`# 2) ๋ผ๋ฒจ โ withdrawn_flag`,
|
| 689 |
+
`pairs = []`,
|
| 690 |
+
`for m in rows:`,
|
| 691 |
+
` s = (m.get("molecule_structures") or {}).get("canonical_smiles")`,
|
| 692 |
+
` if not (s and m.get("first_approval")): continue`,
|
| 693 |
+
` pairs.append((s, 1 if m.get("withdrawn_flag") else 0, m["first_approval"]))`,
|
| 694 |
+
`# โ
์ํ ํํฉ๋ฌผ๊ณผ ๊ฒน์น์ง ์๊ฒ ๊ตฌ์ฑํ ๊ฒ. ์น์ธ ์ฐ๋๋ก ๋น๊ต๊ตฐ์ ๋ง์ถ๋ฉด ๋ฌ๋ ฅ์ด ๋ต์ ์ค๋ค.`,
|
| 695 |
+
``,
|
| 696 |
+
`gen = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)`,
|
| 697 |
+
`mols = [Chem.MolFromSmiles(s) for s, _, _ in pairs]`,
|
| 698 |
+
`X = np.array([gen.GetFingerprintAsNumPy(m) for m in mols if m is not None])`,
|
| 699 |
+
`Y = np.array([y for (s, y, _), m in zip(pairs, mols) if m is not None])`,
|
| 700 |
+
`model = lgb.LGBMClassifier(n_estimators=500, learning_rate=0.05).fit(X, Y)`,
|
| 701 |
+
``,
|
| 702 |
+
`test = json.load(open("${b.board.toLowerCase()}_test.json", encoding="utf-8"))`,
|
| 703 |
+
`Xt = np.array([gen.GetFingerprintAsNumPy(Chem.MolFromSmiles(c["smiles"]))`,
|
| 704 |
+
` for c in test["compounds"]])`,
|
| 705 |
+
`p = model.predict_proba(Xt)[:, 1]`,
|
| 706 |
+
`with open("predictions.csv", "w") as f:`,
|
| 707 |
+
` f.write("compound_id,prediction\n")`,
|
| 708 |
+
` for c, v in zip(test["compounds"], p):`,
|
| 709 |
+
` f.write("%s,%.4f\n" % (c["compound_id"], v))`
|
| 710 |
+
].join("\n");
|
| 711 |
+
}
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
function starterDerived(b){
|
| 715 |
+
/* ์์ ์ญ ๋ถ๋ฌธ. ๋จ์ผ ์ธก์ ์ด ์๋๋ผ ๋ ๊ฐ์ ์ฐจ์ด๋ค. */
|
| 716 |
+
return [
|
| 717 |
+
`# ${b.board} ์ ์ถ ๋ผ๋`,
|
| 718 |
+
`#`,
|
| 719 |
+
`# ${b.query_note||"๋ ๊ฐ์ ์ฐจ์ด๋ก ๋ง๋ค์ด์ง๋ ๋ถ๋ฌธ์ด๋ค."}`,
|
| 720 |
+
`#`,
|
| 721 |
+
`# ์ค์ธก ์ฐธ๊ณ : ์์ชฝ์ ๋ฐ๋ก ์์ธกํด ๋นผ๋ ์ชฝ์ด, ์ฐจ์ด๋ฅผ ์ง์ ํ์ตํ๋ ๊ฒ๋ณด๋ค ์ข์๋ค.`,
|
| 722 |
+
``,
|
| 723 |
+
`import json, math, requests, numpy as np`,
|
| 724 |
+
`from rdkit import Chem`,
|
| 725 |
+
`from rdkit.Chem import rdFingerprintGenerator`,
|
| 726 |
+
`import lightgbm as lgb`,
|
| 727 |
+
``,
|
| 728 |
+
`API = "https://www.ebi.ac.uk/chembl/api/data/activity.json"`,
|
| 729 |
+
``,
|
| 730 |
+
`def pull(target):`,
|
| 731 |
+
` rows, off = [], 0`,
|
| 732 |
+
` while True:`,
|
| 733 |
+
` q = {"target_chembl_id": target, "standard_type": "IC50",`,
|
| 734 |
+
` "standard_relation": "=", "limit": 1000, "offset": off}`,
|
| 735 |
+
` d = requests.get(API, params=q, timeout=120).json()`,
|
| 736 |
+
` rows += d["activities"]; off += 1000`,
|
| 737 |
+
` if off >= d["page_meta"]["total_count"]: break`,
|
| 738 |
+
` rec = {}`,
|
| 739 |
+
` for r in rows:`,
|
| 740 |
+
` s, v, u = r["canonical_smiles"], r["standard_value"], r["standard_units"]`,
|
| 741 |
+
` if not (s and v and u == "nM") or float(v) <= 0: continue`,
|
| 742 |
+
` m = Chem.MolFromSmiles(s)`,
|
| 743 |
+
` if m is None: continue`,
|
| 744 |
+
` rec.setdefault(Chem.MolToInchiKey(m), {"m": m, "p": []})`,
|
| 745 |
+
` rec[Chem.MolToInchiKey(m)]["p"].append(9.0 - math.log10(float(v)))`,
|
| 746 |
+
` return rec`,
|
| 747 |
+
``,
|
| 748 |
+
`herg = pull("CHEMBL240") # ์ฌ์ฅ ์ชฝ`,
|
| 749 |
+
`tgt = pull("CHEMBL_ํ์ _ID") # โ ์ด ๋ถ๋ฌธ์ ํ์ ์ผ๋ก ๋ฐ๊พผ๋ค`,
|
| 750 |
+
``,
|
| 751 |
+
`# ์์ ์ญ = ํ์ ํ์ฑ - hERG ํ์ฑ. ๊ฐ๊ฐ ์์ธก๊ธฐ๋ฅผ ๋ง๋ค๊ณ ์์ธก๊ฐ์ ๋บ๋ค.`,
|
| 752 |
+
`gen = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)`,
|
| 753 |
+
``,
|
| 754 |
+
`def fit(rec):`,
|
| 755 |
+
` X = np.array([gen.GetFingerprintAsNumPy(v["m"]) for v in rec.values()])`,
|
| 756 |
+
` Y = np.array([float(np.median(v["p"])) for v in rec.values()])`,
|
| 757 |
+
` return lgb.LGBMRegressor(n_estimators=500, learning_rate=0.05).fit(X, Y)`,
|
| 758 |
+
``,
|
| 759 |
+
`m_t, m_h = fit(tgt), fit(herg)`,
|
| 760 |
+
`test = json.load(open("${b.board.toLowerCase()}_test.json", encoding="utf-8"))`,
|
| 761 |
+
`Xt = np.array([gen.GetFingerprintAsNumPy(Chem.MolFromSmiles(c["smiles"]))`,
|
| 762 |
+
` for c in test["compounds"]])`,
|
| 763 |
+
`p = m_t.predict(Xt) - m_h.predict(Xt)`,
|
| 764 |
+
`with open("predictions.csv", "w") as f:`,
|
| 765 |
+
` f.write("compound_id,prediction\n")`,
|
| 766 |
+
` for c, v in zip(test["compounds"], p):`,
|
| 767 |
+
` f.write("%s,%.4f\n" % (c["compound_id"], v))`
|
| 768 |
+
].join("\n");
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
|
| 772 |
function starterNoChembl(b){
|
| 773 |
return [
|
| 774 |
`# ${b.board} ์ ์ถ ๋ผ๋`,
|