Skip to content

Commit cabe0d1

Browse files
committed
restoring banned units
1 parent 483c5cd commit cabe0d1

File tree

1 file changed

+19
-45
lines changed

1 file changed

+19
-45
lines changed

components/dataloader/CompoundGetter.tsx

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@ import LigandContext from "../../context/LigandContext";
44
import Link from "next/link";
55
import FAQComp from "../ui-comps/FAQComp";
66

7-
// whitelist from your counts, filtered by count > 500
8-
const VALID_COMBOS: Record<string, string[]> = {
9-
B: ["IC50", "Ki", "Potency", "EC50"], // Binding
10-
F: ["Potency", "IC50", "EC50", "ED50", "AC50", "XC50"], // Functional
11-
ADMET: ["IC50"],
12-
T: ["IC50"],
13-
// P, U have no units with count > 500 -> all units disabled
14-
};
15-
16-
const ALL_UNITS = ["Ki", "IC50", "XC50", "EC50", "AC50", "Kd", "Potency", "ED50"];
17-
187
export default function CompoundGetter() {
198
const [unit, setUnit] = useState("Ki");
20-
const [binding, setBinding] = useState<keyof typeof VALID_COMBOS | string>("B");
9+
const [binding, setBinding] = useState("B");
2110
const { target, setTarget } = useContext(TargetContext);
2211
const { ligand, setLigand } = useContext(LigandContext);
2312
const [ligandSearch, setLigandSearch] = useState(false);
@@ -29,7 +18,7 @@ export default function CompoundGetter() {
2918
setLoading(true);
3019

3120
const chembl_url = "https://www.ebi.ac.uk";
32-
const results: any[] = [{}];
21+
const results = [{}];
3322

3423
let nextUrl = chembl_url + url;
3524

@@ -51,19 +40,17 @@ export default function CompoundGetter() {
5140
getFullActivityData(
5241
`/chembl/api/data/activity?format=json&target_chembl_id=${target.target_id}&type=${unit}&target_organism=Homo%20sapiens&assay_type=${binding}&relation==`,
5342
).then((data) => {
54-
data.map((x: any) => {
43+
data.map((x) => {
5544
x[unit] = x["standard_value"];
5645
x["id"] = x["molecule_chembl_id"];
5746
delete x["standard_value"];
5847
return x;
5948
});
6049
setLigand(data);
6150
});
62-
setTarget({ ...target, activity_columns: [unit], data_source: "chembl" });
51+
setTarget({ ...target, activity_columns: [unit], data_source: "chembl"});
6352
}
6453

65-
const allowedUnits = VALID_COMBOS[binding] ?? [];
66-
6754
return (
6855
<div
6956
style={{
@@ -87,20 +74,11 @@ export default function CompoundGetter() {
8774
. Since, Binding Assays are more prevalent with Ki being the preferred
8875
unit, they are the default.
8976
</FAQComp>
90-
9177
<label htmlFor="input-assay-type">Assay Type</label>
9278
<select
93-
id="input-assay-type"
9479
className="input"
95-
value={binding}
9680
onChange={(e) => {
97-
const newBinding = e.target.value;
98-
setBinding(newBinding);
99-
100-
const newAllowed = VALID_COMBOS[newBinding] ?? [];
101-
if (!newAllowed.includes(unit) && newAllowed.length > 0) {
102-
setUnit(newAllowed[0]);
103-
}
81+
setBinding(e.target.value);
10482
}}
10583
>
10684
<option value="B">B (Binding)</option>
@@ -110,29 +88,25 @@ export default function CompoundGetter() {
11088
<option value="P">P (Physiochemical)</option>
11189
<option value="U">U (Unclassified)</option>
11290
</select>
113-
11491
<label htmlFor="input-unit">Unit Type</label>
11592
<select
116-
id="input-unit"
11793
className="input"
118-
value={unit}
119-
onChange={(e) => setUnit(e.target.value)}
94+
onChange={(e) => {
95+
setUnit(e.target.value);
96+
}}
12097
>
121-
{ALL_UNITS.map((u) => (
122-
<option
123-
key={u}
124-
value={u}
125-
disabled={!allowedUnits.includes(u)}
126-
>
127-
{u}
128-
</option>
129-
))}
98+
<option value="Ki">Ki</option>
99+
<option value="IC50">IC50</option>
100+
<option value="XC50">XC50</option>
101+
<option value="EC50">EC50</option>
102+
<option value="AC50">AC50</option>
103+
<option value="Kd">Kd</option>
104+
<option value="Potency">Potency</option>
105+
<option value="ED50">ED50</option>
130106
</select>
131-
132107
<button className="button" onClick={hehe}>
133108
Fetch Data
134109
</button>
135-
136110
{loading && (
137111
<div>
138112
<progress
@@ -141,13 +115,13 @@ export default function CompoundGetter() {
141115
max={100}
142116
style={{ width: "100%", marginBottom: "10px" }}
143117
></progress>
144-
<br />
118+
<br></br>
145119
<span style={{ textAlign: "center" }}>
146120
{Math.min(progress, 100).toFixed(2)} %
147121
</span>
148122
</div>
149123
)}
150-
<br />
124+
<br></br>
151125
{ligand.length > 0 ? (
152126
<div style={{ marginTop: "10px" }}>
153127
<Link className="button" href="/tools/preprocess/">
@@ -162,4 +136,4 @@ export default function CompoundGetter() {
162136
)}
163137
</div>
164138
);
165-
}
139+
}

0 commit comments

Comments
 (0)