SeaWolf-AI commited on
Commit
ce3d03e
ยท
verified ยท
1 Parent(s): bb09ed0

guide: correct starters for molecule-endpoint and derived boards

Browse files
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} ์ œ์ถœ ๋ผˆ๋Œ€`,