Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +296 -613
index.html
CHANGED
|
@@ -8,7 +8,6 @@
|
|
| 8 |
<script src="https://3dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.min.js"></script>
|
| 10 |
|
| 11 |
-
|
| 12 |
<style>
|
| 13 |
*{margin:0;padding:0;box-sizing:border-box}
|
| 14 |
|
|
@@ -262,47 +261,48 @@ label{font-size:11px;color:var(--text2);display:block;margin-bottom:6px;font-fam
|
|
| 262 |
}
|
| 263 |
@keyframes sp{to{transform:rotate(360deg)}}
|
| 264 |
|
| 265 |
-
/*
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
border
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
border
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
.
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
.
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
padding:
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
.
|
| 304 |
-
|
| 305 |
-
|
|
|
|
| 306 |
|
| 307 |
/* INTERACTION TABLE */
|
| 308 |
.interaction-table{width:100%;border-collapse:collapse;font-family:'Space Mono',monospace;font-size:11px}
|
|
@@ -375,7 +375,7 @@ input[type=range]::-webkit-slider-thumb{
|
|
| 375 |
<div class="tabs">
|
| 376 |
<button class="tab active" data-tab="protein">𧬠Protein</button>
|
| 377 |
<button class="tab" data-tab="molecule">π Molecule</button>
|
| 378 |
-
<button class="tab" data-tab="draw">βοΈ
|
| 379 |
<button class="tab" data-tab="docking">π― Docking</button>
|
| 380 |
<button class="tab" data-tab="sequence">π¬ Sequence</button>
|
| 381 |
<button class="tab" data-tab="ai">π€ AI</button>
|
|
@@ -523,61 +523,61 @@ input[type=range]::-webkit-slider-thumb{
|
|
| 523 |
</div>
|
| 524 |
</div>
|
| 525 |
|
| 526 |
-
<!-- βββββββββββββββ
|
| 527 |
<div id="draw-panel" class="panel">
|
| 528 |
<div class="grid2">
|
| 529 |
<div>
|
| 530 |
<div class="card">
|
| 531 |
-
<div class="card-title">
|
| 532 |
-
<div class="alert alert-info">
|
| 533 |
-
|
| 534 |
-
<!--
|
| 535 |
-
<
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
<
|
| 539 |
-
<
|
| 540 |
-
<
|
| 541 |
-
<span class="etool" id="bond-double" onclick="setBondOrder(2)">= Double</span>
|
| 542 |
-
<span class="etool" id="bond-triple" onclick="setBondOrder(3)">β‘ Triple</span>
|
| 543 |
-
<span class="etool" id="bond-aromatic" onclick="setBondOrder(1.5)">⬑ Aromatic</span>
|
| 544 |
-
</div>
|
| 545 |
-
<div class="element-row">
|
| 546 |
-
<span style="color:var(--text3);font-size:10px;font-family:'Space Mono',monospace;margin-right:4px;line-height:2">Element:</span>
|
| 547 |
-
<span class="elem-btn active" id="elem-C" onclick="setElement('C')">C</span>
|
| 548 |
-
<span class="elem-btn" id="elem-N" onclick="setElement('N')">N</span>
|
| 549 |
-
<span class="elem-btn" id="elem-O" onclick="setElement('O')">O</span>
|
| 550 |
-
<span class="elem-btn" id="elem-S" onclick="setElement('S')">S</span>
|
| 551 |
-
<span class="elem-btn" id="elem-P" onclick="setElement('P')">P</span>
|
| 552 |
-
<span class="elem-btn" id="elem-F" onclick="setElement('F')">F</span>
|
| 553 |
-
<span class="elem-btn" id="elem-Cl" onclick="setElement('Cl')">Cl</span>
|
| 554 |
-
<span class="elem-btn" id="elem-Br" onclick="setElement('Br')">Br</span>
|
| 555 |
-
<span class="elem-btn" id="elem-I" onclick="setElement('I')">I</span>
|
| 556 |
-
<span class="elem-btn" id="elem-H" onclick="setElement('H')">H</span>
|
| 557 |
</div>
|
| 558 |
-
<
|
|
|
|
| 559 |
|
| 560 |
-
|
| 561 |
-
<div
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
<
|
| 567 |
-
|
| 568 |
-
|
|
|
|
| 569 |
</div>
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
<button class="btn btn-
|
| 573 |
-
<button class="btn
|
| 574 |
</div>
|
| 575 |
</div>
|
| 576 |
|
| 577 |
<div class="card">
|
| 578 |
-
<div class="card-title">
|
| 579 |
-
<div
|
| 580 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
</div>
|
| 582 |
</div>
|
| 583 |
|
|
@@ -594,6 +594,13 @@ input[type=range]::-webkit-slider-thumb{
|
|
| 594 |
<span class="chip" onclick="setStyle('draw','surface',this)">Surface</span>
|
| 595 |
</div>
|
| 596 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
</div>
|
| 598 |
</div>
|
| 599 |
</div>
|
|
@@ -823,7 +830,8 @@ input[type=range]::-webkit-slider-thumb{
|
|
| 823 |
</div>
|
| 824 |
</div>
|
| 825 |
|
| 826 |
-
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script>
|
|
|
|
| 827 |
// βββββββββββββββββββββββ STATE βββββββββββββββββββββββ
|
| 828 |
const S = {
|
| 829 |
proteinPDB:null, proteinId:null, proteinSrc:null,
|
|
@@ -832,7 +840,8 @@ const S = {
|
|
| 832 |
ragDocs:[], chatHistory:[],
|
| 833 |
apiKey:'', apiModel:'llama-3.1-8b-instant',
|
| 834 |
viewers:{protein:null,ligand:null,complex:null,draw:null,pred:null},
|
| 835 |
-
ramaChart:null
|
|
|
|
| 836 |
};
|
| 837 |
|
| 838 |
// βββββββββββββββββββββββ UTIL βββββββββββββββββββββββ
|
|
@@ -862,6 +871,11 @@ document.querySelectorAll('.tab').forEach(t=>{
|
|
| 862 |
document.querySelectorAll('.panel').forEach(x=>x.classList.remove('active'));
|
| 863 |
t.classList.add('active');
|
| 864 |
document.getElementById(t.dataset.tab+'-panel').classList.add('active');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 865 |
});
|
| 866 |
});
|
| 867 |
|
|
@@ -1093,6 +1107,199 @@ async function loadCID(cid){
|
|
| 1093 |
}catch(e){toast(`Error: ${e.message}`,'error');}
|
| 1094 |
}
|
| 1095 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1096 |
// βββββββββββββββββββββββ IUPAC β 3D (OpenMolecules / OPSIN cascade) βββββββββββββββββββββββ
|
| 1097 |
const IUPAC_SOURCES=['OPSIN','CIR','CACTUS','PubChem','Fallback'];
|
| 1098 |
|
|
@@ -1209,533 +1416,12 @@ function iupacFallback(name){
|
|
| 1209 |
return null;
|
| 1210 |
}
|
| 1211 |
|
| 1212 |
-
async function smilesLookupCID(smiles){
|
| 1213 |
-
try{
|
| 1214 |
-
const r=await fetch(`https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/${encodeURIComponent(smiles)}/cids/JSON`);
|
| 1215 |
-
if(r.ok){const d=await r.json();return d.IdentifierList?.CID?.[0]||null;}
|
| 1216 |
-
}catch{}
|
| 1217 |
-
return null;
|
| 1218 |
-
}
|
| 1219 |
-
|
| 1220 |
-
async function synthSDF(smiles,name){
|
| 1221 |
-
// Build a minimal SDF from SMILES atom parse
|
| 1222 |
-
const atoms=[];
|
| 1223 |
-
for(let i=0;i<smiles.length;i++){
|
| 1224 |
-
const c=smiles[i];
|
| 1225 |
-
if(c.match(/[A-Z]/)){
|
| 1226 |
-
let sym=c;
|
| 1227 |
-
if(i+1<smiles.length&&smiles[i+1].match(/[a-z]/)&&!smiles[i+1].match(/[cnops]/)){sym+=smiles[i+1];i++;}
|
| 1228 |
-
if(sym.match(/^(C|N|O|S|P|F|Cl|Br|I|H)$/)) atoms.push(sym);
|
| 1229 |
-
}else if(c.match(/[cnos]/)) atoms.push(c.toUpperCase()); // aromatic
|
| 1230 |
-
}
|
| 1231 |
-
if(atoms.length<3) atoms.push('C','C','C');
|
| 1232 |
-
const coords=atoms.map((_,i)=>{
|
| 1233 |
-
const a=(i/atoms.length)*Math.PI*2;
|
| 1234 |
-
return{x:Math.cos(a)*3+Math.sin(i*.7)*1,y:Math.sin(a)*3+Math.cos(i*.5)*1,z:Math.sin(i*1.2)*2};
|
| 1235 |
-
});
|
| 1236 |
-
let sdf=`${name.substring(0,40)}\n Generated\n\n`;
|
| 1237 |
-
sdf+=` ${String(coords.length).padStart(2)} 0 0 0 0 0 0 0 0999 V2000\n`;
|
| 1238 |
-
coords.forEach((c,i)=>{
|
| 1239 |
-
sdf+=`${c.x.toFixed(4).padStart(10)}${c.y.toFixed(4).padStart(10)}${c.z.toFixed(4).padStart(10)} ${(atoms[i]||'C').padEnd(3)} 0 0 0 0 0\n`;
|
| 1240 |
-
});
|
| 1241 |
-
sdf+='M END\n> <SMILES>\n'+smiles+'\n\n$$$$\n';
|
| 1242 |
-
const ec={};atoms.forEach(a=>{ec[a]=(ec[a]||0)+1;});
|
| 1243 |
-
const mw=atoms.reduce((s,a)=>s+({'C':12.011,'H':1.008,'N':14.007,'O':15.999,'S':32.065,'Cl':35.453,'F':18.998,'Br':79.904}[a]||12.011),0);
|
| 1244 |
-
const props={MolecularFormula:Object.entries(ec).map(([e,n])=>e+(n>1?n:'')).join(''),MolecularWeight:mw.toFixed(2),XLogP:'~1.5',HBondDonorCount:String(atoms.filter(a=>a==='O'||a==='N').length),HBondAcceptorCount:String(atoms.filter(a=>a==='O'||a==='N').length),RotatableBondCount:'3',HeavyAtomCount:String(atoms.length),TPSA:'β',CanonicalSMILES:smiles};
|
| 1245 |
-
initLigandViewer(sdf,props,'Synth');
|
| 1246 |
-
}
|
| 1247 |
-
|
| 1248 |
function ti(type){
|
| 1249 |
const map={aspirin:'2-acetoxybenzoic acid',caffeine:'1,3,7-trimethyl-3,7-dihydro-1H-purine-2,6-dione',ibuprofen:'2-(4-isobutylphenyl)propanoic acid',morphine:'(4R,4aR,7S,7aR,12bS)-3-methyl-2,3,4,4a,7,7a-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol',penicillin:'(2S,5R,6R)-3,3-dimethyl-7-oxo-6-[(phenylacetyl)amino]-4-thia-1-azabicyclo[3.2.0]heptane-2-carboxylic acid'};
|
| 1250 |
document.getElementById('iupac-input').value=map[type]||type;
|
| 1251 |
convertIUPAC();
|
| 1252 |
}
|
| 1253 |
|
| 1254 |
-
// βββββββββββββββββββββββ SELF-CONTAINED CHEM EDITOR βββββββββββββββββββββββ
|
| 1255 |
-
const CE = {
|
| 1256 |
-
atoms: [], // {id, x, y, element, selected}
|
| 1257 |
-
bonds: [], // {id, a, b, order} a/b = atom ids
|
| 1258 |
-
tool: 'bond', // bond | atom | select | erase
|
| 1259 |
-
element: 'C',
|
| 1260 |
-
bondOrder: 1,
|
| 1261 |
-
selectedAtom: null, // id of first atom when drawing bond
|
| 1262 |
-
dragging: null, // atom id being dragged
|
| 1263 |
-
dragOffset: {x:0,y:0},
|
| 1264 |
-
nextId: 1,
|
| 1265 |
-
canvas: null,
|
| 1266 |
-
ctx: null,
|
| 1267 |
-
dirty: true
|
| 1268 |
-
};
|
| 1269 |
-
|
| 1270 |
-
// Element colors (CPK-ish)
|
| 1271 |
-
const ELEM_COLOR = {C:'#e8edf8',N:'#7eb8ff',O:'#ff6b6b',S:'#ffd166',P:'#ff9b40',F:'#7effc4',Cl:'#7effc4',Br:'#c57c4e',I:'#9b59b6',H:'#aaaaaa'};
|
| 1272 |
-
const BOND_GAP = 3; // pixels gap for double/triple bonds
|
| 1273 |
-
|
| 1274 |
-
function ceInit(){
|
| 1275 |
-
CE.canvas = document.getElementById('chem-canvas');
|
| 1276 |
-
if(!CE.canvas) return;
|
| 1277 |
-
CE.ctx = CE.canvas.getContext('2d');
|
| 1278 |
-
resizeCeCanvas();
|
| 1279 |
-
|
| 1280 |
-
CE.canvas.addEventListener('mousedown', ceMouseDown);
|
| 1281 |
-
CE.canvas.addEventListener('mousemove', ceMouseMove);
|
| 1282 |
-
CE.canvas.addEventListener('mouseup', ceMouseUp);
|
| 1283 |
-
CE.canvas.addEventListener('contextmenu', ceRightClick);
|
| 1284 |
-
window.addEventListener('resize', resizeCeCanvas);
|
| 1285 |
-
ceRender();
|
| 1286 |
-
}
|
| 1287 |
-
|
| 1288 |
-
function resizeCeCanvas(){
|
| 1289 |
-
if(!CE.canvas) return;
|
| 1290 |
-
const rect = CE.canvas.parentElement.getBoundingClientRect();
|
| 1291 |
-
CE.canvas.width = Math.max(400, rect.width - 2);
|
| 1292 |
-
CE.canvas.height = 400;
|
| 1293 |
-
ceRender();
|
| 1294 |
-
}
|
| 1295 |
-
|
| 1296 |
-
function cePos(e){
|
| 1297 |
-
const r = CE.canvas.getBoundingClientRect();
|
| 1298 |
-
return { x: e.clientX - r.left, y: e.clientY - r.top };
|
| 1299 |
-
}
|
| 1300 |
-
|
| 1301 |
-
function atomAt(x, y, r=18){
|
| 1302 |
-
for(let i=CE.atoms.length-1;i>=0;i--){
|
| 1303 |
-
const a=CE.atoms[i];
|
| 1304 |
-
if(Math.hypot(a.x-x,a.y-y)<r) return a;
|
| 1305 |
-
}
|
| 1306 |
-
return null;
|
| 1307 |
-
}
|
| 1308 |
-
|
| 1309 |
-
function bondBetween(a,b){
|
| 1310 |
-
return CE.bonds.find(bd=>(bd.a===a&&bd.b===b)||(bd.a===b&&bd.b===a));
|
| 1311 |
-
}
|
| 1312 |
-
|
| 1313 |
-
function ceMouseDown(e){
|
| 1314 |
-
const p = cePos(e);
|
| 1315 |
-
const hit = atomAt(p.x, p.y);
|
| 1316 |
-
|
| 1317 |
-
if(CE.tool==='select'){
|
| 1318 |
-
if(hit){ CE.dragging=hit.id; CE.dragOffset={x:p.x-hit.x,y:p.y-hit.y}; }
|
| 1319 |
-
return;
|
| 1320 |
-
}
|
| 1321 |
-
if(CE.tool==='erase'){
|
| 1322 |
-
if(hit){ CE.atoms=CE.atoms.filter(a=>a.id!==hit.id); CE.bonds=CE.bonds.filter(b=>b.a!==hit.id&&b.b!==hit.id); ceRender(); }
|
| 1323 |
-
return;
|
| 1324 |
-
}
|
| 1325 |
-
if(CE.tool==='atom'){
|
| 1326 |
-
if(!hit){ addAtom(p.x,p.y,CE.element); ceRender(); }
|
| 1327 |
-
else{ hit.element=CE.element; ceRender(); }
|
| 1328 |
-
return;
|
| 1329 |
-
}
|
| 1330 |
-
// bond tool
|
| 1331 |
-
if(hit){
|
| 1332 |
-
if(CE.selectedAtom===null){ CE.selectedAtom=hit.id; hit.selected=true; }
|
| 1333 |
-
else if(CE.selectedAtom===hit.id){ CE.selectedAtom=null; hit.selected=false; }
|
| 1334 |
-
else{
|
| 1335 |
-
const existing=bondBetween(CE.selectedAtom,hit.id);
|
| 1336 |
-
if(existing){
|
| 1337 |
-
// cycle bond order
|
| 1338 |
-
if(existing.order===1) existing.order=2;
|
| 1339 |
-
else if(existing.order===2) existing.order=3;
|
| 1340 |
-
else existing.order=1;
|
| 1341 |
-
} else {
|
| 1342 |
-
CE.bonds.push({id:CE.nextId++,a:CE.selectedAtom,b:hit.id,order:CE.bondOrder});
|
| 1343 |
-
}
|
| 1344 |
-
const prev=CE.atoms.find(a=>a.id===CE.selectedAtom);
|
| 1345 |
-
if(prev) prev.selected=false;
|
| 1346 |
-
CE.selectedAtom=null;
|
| 1347 |
-
}
|
| 1348 |
-
} else {
|
| 1349 |
-
// place new atom and possibly connect
|
| 1350 |
-
const newAtom = addAtom(p.x,p.y,CE.element);
|
| 1351 |
-
if(CE.selectedAtom!==null){
|
| 1352 |
-
CE.bonds.push({id:CE.nextId++,a:CE.selectedAtom,b:newAtom.id,order:CE.bondOrder});
|
| 1353 |
-
const prev=CE.atoms.find(a=>a.id===CE.selectedAtom);
|
| 1354 |
-
if(prev) prev.selected=false;
|
| 1355 |
-
}
|
| 1356 |
-
CE.selectedAtom=newAtom.id;
|
| 1357 |
-
newAtom.selected=true;
|
| 1358 |
-
}
|
| 1359 |
-
ceRender();
|
| 1360 |
-
}
|
| 1361 |
-
|
| 1362 |
-
function ceMouseMove(e){
|
| 1363 |
-
if(CE.dragging!==null){
|
| 1364 |
-
const p=cePos(e);
|
| 1365 |
-
const a=CE.atoms.find(x=>x.id===CE.dragging);
|
| 1366 |
-
if(a){ a.x=p.x-CE.dragOffset.x; a.y=p.y-CE.dragOffset.y; ceRender(); }
|
| 1367 |
-
}
|
| 1368 |
-
}
|
| 1369 |
-
function ceMouseUp(){ CE.dragging=null; }
|
| 1370 |
-
|
| 1371 |
-
function ceRightClick(e){
|
| 1372 |
-
e.preventDefault();
|
| 1373 |
-
const p=cePos(e);
|
| 1374 |
-
const hit=atomAt(p.x,p.y);
|
| 1375 |
-
if(hit){ CE.atoms=CE.atoms.filter(a=>a.id!==hit.id); CE.bonds=CE.bonds.filter(b=>b.a!==hit.id&&b.b!==hit.id); ceRender(); }
|
| 1376 |
-
}
|
| 1377 |
-
|
| 1378 |
-
function addAtom(x,y,el){
|
| 1379 |
-
const a={id:CE.nextId++,x,y,element:el,selected:false};
|
| 1380 |
-
CE.atoms.push(a); return a;
|
| 1381 |
-
}
|
| 1382 |
-
|
| 1383 |
-
function ceRender(){
|
| 1384 |
-
if(!CE.ctx) return;
|
| 1385 |
-
const ctx=CE.ctx, W=CE.canvas.width, H=CE.canvas.height;
|
| 1386 |
-
ctx.clearRect(0,0,W,H);
|
| 1387 |
-
ctx.fillStyle='#0a0d17'; ctx.fillRect(0,0,W,H);
|
| 1388 |
-
|
| 1389 |
-
// grid dots
|
| 1390 |
-
ctx.fillStyle='rgba(255,255,255,0.04)';
|
| 1391 |
-
for(let gx=20;gx<W;gx+=20) for(let gy=20;gy<H;gy+=20){ ctx.beginPath();ctx.arc(gx,gy,1,0,Math.PI*2);ctx.fill(); }
|
| 1392 |
-
|
| 1393 |
-
// Draw bonds
|
| 1394 |
-
CE.bonds.forEach(bd=>{
|
| 1395 |
-
const a=CE.atoms.find(x=>x.id===bd.a), b=CE.atoms.find(x=>x.id===bd.b);
|
| 1396 |
-
if(!a||!b) return;
|
| 1397 |
-
drawBond(ctx,a,b,bd.order);
|
| 1398 |
-
});
|
| 1399 |
-
|
| 1400 |
-
// Draw first-atom selection line preview
|
| 1401 |
-
if(CE.selectedAtom!==null){
|
| 1402 |
-
const a=CE.atoms.find(x=>x.id===CE.selectedAtom);
|
| 1403 |
-
if(a){
|
| 1404 |
-
ctx.strokeStyle='rgba(0,240,255,0.3)';ctx.lineWidth=1;ctx.setLineDash([4,4]);
|
| 1405 |
-
ctx.beginPath();ctx.arc(a.x,a.y,22,0,Math.PI*2);ctx.stroke();
|
| 1406 |
-
ctx.setLineDash([]);
|
| 1407 |
-
}
|
| 1408 |
-
}
|
| 1409 |
-
|
| 1410 |
-
// Draw atoms
|
| 1411 |
-
CE.atoms.forEach(a=>drawAtom(ctx,a));
|
| 1412 |
-
}
|
| 1413 |
-
|
| 1414 |
-
function drawBond(ctx,a,b,order){
|
| 1415 |
-
const dx=b.x-a.x, dy=b.y-a.y, len=Math.hypot(dx,dy)||1;
|
| 1416 |
-
const ux=dx/len, uy=dy/len;
|
| 1417 |
-
const nx=-uy, ny=ux; // normal
|
| 1418 |
-
|
| 1419 |
-
const col= order===1.5 ? '#c084fc' : '#8892b0';
|
| 1420 |
-
ctx.strokeStyle=col; ctx.lineWidth=order===3?1.5:1.8; ctx.setLineDash([]);
|
| 1421 |
-
|
| 1422 |
-
if(order===1){
|
| 1423 |
-
drawLine(ctx,a.x,a.y,b.x,b.y);
|
| 1424 |
-
} else if(order===2){
|
| 1425 |
-
const g=BOND_GAP;
|
| 1426 |
-
drawLine(ctx,a.x+nx*g,a.y+ny*g,b.x+nx*g,b.y+ny*g);
|
| 1427 |
-
drawLine(ctx,a.x-nx*g,a.y-ny*g,b.x-nx*g,b.y-ny*g);
|
| 1428 |
-
} else if(order===3){
|
| 1429 |
-
const g=BOND_GAP*1.5;
|
| 1430 |
-
drawLine(ctx,a.x,a.y,b.x,b.y);
|
| 1431 |
-
drawLine(ctx,a.x+nx*g,a.y+ny*g,b.x+nx*g,b.y+ny*g);
|
| 1432 |
-
drawLine(ctx,a.x-nx*g,a.y-ny*g,b.x-nx*g,b.y-ny*g);
|
| 1433 |
-
} else { // aromatic 1.5
|
| 1434 |
-
ctx.setLineDash([]);
|
| 1435 |
-
drawLine(ctx,a.x+nx*BOND_GAP,a.y+ny*BOND_GAP,b.x+nx*BOND_GAP,b.y+ny*BOND_GAP);
|
| 1436 |
-
ctx.setLineDash([4,3]);
|
| 1437 |
-
drawLine(ctx,a.x-nx*BOND_GAP,a.y-ny*BOND_GAP,b.x-nx*BOND_GAP,b.y-ny*BOND_GAP);
|
| 1438 |
-
ctx.setLineDash([]);
|
| 1439 |
-
}
|
| 1440 |
-
}
|
| 1441 |
-
|
| 1442 |
-
function drawLine(ctx,x1,y1,x2,y2){
|
| 1443 |
-
ctx.beginPath(); ctx.moveTo(x1,y1); ctx.lineTo(x2,y2); ctx.stroke();
|
| 1444 |
-
}
|
| 1445 |
-
|
| 1446 |
-
function drawAtom(ctx,a){
|
| 1447 |
-
const showLabel = a.element!=='C' || CE.atoms.length<3;
|
| 1448 |
-
const col = ELEM_COLOR[a.element]||'#e8edf8';
|
| 1449 |
-
const r = 14;
|
| 1450 |
-
|
| 1451 |
-
if(a.selected){
|
| 1452 |
-
ctx.fillStyle='rgba(0,240,255,0.15)';
|
| 1453 |
-
ctx.beginPath(); ctx.arc(a.x,a.y,r+4,0,Math.PI*2); ctx.fill();
|
| 1454 |
-
}
|
| 1455 |
-
|
| 1456 |
-
if(showLabel || a.element!=='C'){
|
| 1457 |
-
ctx.fillStyle=a.selected?'rgba(30,42,64,0.95)':'rgba(10,13,23,0.85)';
|
| 1458 |
-
ctx.beginPath(); ctx.arc(a.x,a.y,r,0,Math.PI*2); ctx.fill();
|
| 1459 |
-
ctx.strokeStyle=a.selected?'var(--cyan)':col;
|
| 1460 |
-
ctx.lineWidth=1.5; ctx.stroke();
|
| 1461 |
-
ctx.fillStyle=col;
|
| 1462 |
-
ctx.font=`bold ${a.element.length>1?11:13}px 'Space Mono',monospace`;
|
| 1463 |
-
ctx.textAlign='center'; ctx.textBaseline='middle';
|
| 1464 |
-
ctx.fillText(a.element,a.x,a.y);
|
| 1465 |
-
} else {
|
| 1466 |
-
// Carbon: small dot
|
| 1467 |
-
ctx.fillStyle=a.selected?'#00f0ff':'rgba(138,146,176,0.5)';
|
| 1468 |
-
ctx.beginPath(); ctx.arc(a.x,a.y,3,0,Math.PI*2); ctx.fill();
|
| 1469 |
-
}
|
| 1470 |
-
}
|
| 1471 |
-
|
| 1472 |
-
function setEditorTool(t){
|
| 1473 |
-
CE.tool=t; CE.selectedAtom=null;
|
| 1474 |
-
CE.atoms.forEach(a=>a.selected=false);
|
| 1475 |
-
document.querySelectorAll('.etool[id^="tool-"]').forEach(el=>el.classList.remove('active'));
|
| 1476 |
-
const el=document.getElementById('tool-'+t); if(el) el.classList.add('active');
|
| 1477 |
-
CE.canvas.style.cursor=t==='erase'?'not-allowed':t==='select'?'default':'crosshair';
|
| 1478 |
-
ceRender();
|
| 1479 |
-
}
|
| 1480 |
-
|
| 1481 |
-
function setBondOrder(o){
|
| 1482 |
-
CE.bondOrder=o;
|
| 1483 |
-
document.querySelectorAll('.etool[id^="bond-"]').forEach(el=>el.classList.remove('active'));
|
| 1484 |
-
const map={1:'bond-single',2:'bond-double',3:'bond-triple',1.5:'bond-aromatic'};
|
| 1485 |
-
const el=document.getElementById(map[o]); if(el) el.classList.add('active');
|
| 1486 |
-
}
|
| 1487 |
-
|
| 1488 |
-
function setElement(el){
|
| 1489 |
-
CE.element=el;
|
| 1490 |
-
document.querySelectorAll('.elem-btn').forEach(e=>e.classList.remove('active'));
|
| 1491 |
-
const btn=document.getElementById('elem-'+el); if(btn) btn.classList.add('active');
|
| 1492 |
-
}
|
| 1493 |
-
|
| 1494 |
-
function editorClear(){
|
| 1495 |
-
CE.atoms=[]; CE.bonds=[]; CE.selectedAtom=null; CE.nextId=1; ceRender();
|
| 1496 |
-
document.getElementById('draw-smiles-out').innerHTML='';
|
| 1497 |
-
document.getElementById('draw-3d-status').innerHTML='';
|
| 1498 |
-
}
|
| 1499 |
-
|
| 1500 |
-
// Templates β pre-built molecules as atom/bond graphs
|
| 1501 |
-
function loadTemplate(name){
|
| 1502 |
-
editorClear();
|
| 1503 |
-
const W=CE.canvas.width, cx=W/2, cy=200;
|
| 1504 |
-
const templates={
|
| 1505 |
-
benzene:()=>{
|
| 1506 |
-
const r=65; const ids=[];
|
| 1507 |
-
for(let i=0;i<6;i++){
|
| 1508 |
-
const a=addAtom(cx+r*Math.cos(i*Math.PI/3-Math.PI/6),cy+r*Math.sin(i*Math.PI/3-Math.PI/6),'C');
|
| 1509 |
-
ids.push(a.id);
|
| 1510 |
-
}
|
| 1511 |
-
for(let i=0;i<6;i++) CE.bonds.push({id:CE.nextId++,a:ids[i],b:ids[(i+1)%6],order:i%2===0?1.5:1.5});
|
| 1512 |
-
},
|
| 1513 |
-
cyclohexane:()=>{
|
| 1514 |
-
const r=70; const ids=[];
|
| 1515 |
-
for(let i=0;i<6;i++){
|
| 1516 |
-
const a=addAtom(cx+r*Math.cos(i*Math.PI/3-Math.PI/6),cy+r*Math.sin(i*Math.PI/3-Math.PI/6),'C');
|
| 1517 |
-
ids.push(a.id);
|
| 1518 |
-
}
|
| 1519 |
-
for(let i=0;i<6;i++) CE.bonds.push({id:CE.nextId++,a:ids[i],b:ids[(i+1)%6],order:1});
|
| 1520 |
-
},
|
| 1521 |
-
naphthalene:()=>{
|
| 1522 |
-
// Two fused benzene rings
|
| 1523 |
-
const r=55,off=55; const ids=[];
|
| 1524 |
-
for(let i=0;i<6;i++){
|
| 1525 |
-
const a=addAtom(cx-off+r*Math.cos(i*Math.PI/3-Math.PI/6),cy+r*Math.sin(i*Math.PI/3-Math.PI/6),'C');
|
| 1526 |
-
ids.push(a.id);
|
| 1527 |
-
}
|
| 1528 |
-
for(let i=0;i<6;i++) CE.bonds.push({id:CE.nextId++,a:ids[i],b:ids[(i+1)%6],order:1.5});
|
| 1529 |
-
// second ring shares bond 0-5 (atoms at i=0 and i=5)
|
| 1530 |
-
const shared=[ids[0],ids[5]]; const ids2=[shared[1],shared[0]];
|
| 1531 |
-
for(let i=1;i<5;i++){
|
| 1532 |
-
const a=addAtom(cx+off+r*Math.cos(i*Math.PI/3-Math.PI/6),cy+r*Math.sin(i*Math.PI/3-Math.PI/6),'C');
|
| 1533 |
-
ids2.push(a.id);
|
| 1534 |
-
}
|
| 1535 |
-
ids2.push(ids2[0]); // close
|
| 1536 |
-
for(let i=0;i<ids2.length-1;i++) if(!bondBetween(ids2[i],ids2[i+1]))
|
| 1537 |
-
CE.bonds.push({id:CE.nextId++,a:ids2[i],b:ids2[i+1],order:1.5});
|
| 1538 |
-
},
|
| 1539 |
-
aspirin:()=>{
|
| 1540 |
-
// Benzene ring + carboxylic acid + acetate
|
| 1541 |
-
const r=55; const ids=[];
|
| 1542 |
-
for(let i=0;i<6;i++){
|
| 1543 |
-
const a=addAtom(cx-20+r*Math.cos(i*Math.PI/3-Math.PI/2),cy+r*Math.sin(i*Math.PI/3-Math.PI/2),'C');
|
| 1544 |
-
ids.push(a.id);
|
| 1545 |
-
}
|
| 1546 |
-
for(let i=0;i<6;i++) CE.bonds.push({id:CE.nextId++,a:ids[i],b:ids[(i+1)%6],order:1.5});
|
| 1547 |
-
// COOH at top
|
| 1548 |
-
const c1=addAtom(cx-20,cy-r-40,'C');
|
| 1549 |
-
const o1=addAtom(cx-20-30,cy-r-65,'O');
|
| 1550 |
-
const o2=addAtom(cx-20+30,cy-r-55,'O');
|
| 1551 |
-
CE.bonds.push({id:CE.nextId++,a:ids[0],b:c1.id,order:1});
|
| 1552 |
-
CE.bonds.push({id:CE.nextId++,a:c1.id,b:o1.id,order:2});
|
| 1553 |
-
CE.bonds.push({id:CE.nextId++,a:c1.id,b:o2.id,order:1});
|
| 1554 |
-
// OAc
|
| 1555 |
-
const oidx=1;
|
| 1556 |
-
const oa=addAtom(CE.atoms.find(a=>a.id===ids[oidx]).x+50,CE.atoms.find(a=>a.id===ids[oidx]).y,'O');
|
| 1557 |
-
const ca=addAtom(CE.atoms.find(a=>a.id===ids[oidx]).x+100,CE.atoms.find(a=>a.id===ids[oidx]).y-20,'C');
|
| 1558 |
-
const oa2=addAtom(CE.atoms.find(a=>a.id===ids[oidx]).x+130,CE.atoms.find(a=>a.id===ids[oidx]).y+20,'O');
|
| 1559 |
-
const cm=addAtom(CE.atoms.find(a=>a.id===ids[oidx]).x+140,CE.atoms.find(a=>a.id===ids[oidx]).y-55,'C');
|
| 1560 |
-
CE.bonds.push({id:CE.nextId++,a:ids[oidx],b:oa.id,order:1});
|
| 1561 |
-
CE.bonds.push({id:CE.nextId++,a:oa.id,b:ca.id,order:1});
|
| 1562 |
-
CE.bonds.push({id:CE.nextId++,a:ca.id,b:oa2.id,order:2});
|
| 1563 |
-
CE.bonds.push({id:CE.nextId++,a:ca.id,b:cm.id,order:1});
|
| 1564 |
-
},
|
| 1565 |
-
caffeine:()=>{
|
| 1566 |
-
// Purine-like: imidazole fused with pyrimidine
|
| 1567 |
-
const pts=[
|
| 1568 |
-
{x:cx-90,y:cy+20,el:'N'},{x:cx-50,y:cy-50,el:'C'},{x:cx,y:cy-70,el:'N'},
|
| 1569 |
-
{x:cx+50,y:cy-30,el:'C'},{x:cx+40,y:cy+40,el:'N'},{x:cx-20,y:cy+80,el:'C'},
|
| 1570 |
-
{x:cx-80,y:cy+75,el:'N'},{x:cx-10,y:cy+10,el:'C'},{x:cx+30,y:cy-5,el:'C'}
|
| 1571 |
-
];
|
| 1572 |
-
const bonds2=[[0,1,2],[1,2,1],[2,3,2],[3,4,1],[4,5,1],[5,6,1],[6,0,1],[3,8,1],[8,7,2],[7,0,1],[4,8,1]];
|
| 1573 |
-
const ids={}; pts.forEach((p,i)=>{ const a=addAtom(p.x,p.y,p.el); ids[i]=a.id; });
|
| 1574 |
-
bonds2.forEach(([a,b,o])=>CE.bonds.push({id:CE.nextId++,a:ids[a],b:ids[b],order:o}));
|
| 1575 |
-
// methyl groups
|
| 1576 |
-
[[0,cx-130,cy+5],[2,cx+5,cy-110],[6,cx-120,cy+105]].forEach(([ri,mx,my])=>{
|
| 1577 |
-
const m=addAtom(mx,my,'C'); CE.bonds.push({id:CE.nextId++,a:ids[ri],b:m.id,order:1});
|
| 1578 |
-
});
|
| 1579 |
-
// carbonyl oxygens on C at idx 1 and 5
|
| 1580 |
-
[[1,cx-55,cy-95],[5,cx-25,cy+125]].forEach(([ri,ox,oy])=>{
|
| 1581 |
-
const o=addAtom(ox,oy,'O'); CE.bonds.push({id:CE.nextId++,a:ids[ri],b:o.id,order:2});
|
| 1582 |
-
});
|
| 1583 |
-
},
|
| 1584 |
-
indole:()=>{
|
| 1585 |
-
// Benzene fused with pyrrole
|
| 1586 |
-
const r=55,off=48; const ids=[];
|
| 1587 |
-
for(let i=0;i<6;i++){
|
| 1588 |
-
const a=addAtom(cx-off+r*Math.cos(i*Math.PI/3-Math.PI/6),cy+r*Math.sin(i*Math.PI/3-Math.PI/6),'C');
|
| 1589 |
-
ids.push(a.id);
|
| 1590 |
-
}
|
| 1591 |
-
for(let i=0;i<6;i++) CE.bonds.push({id:CE.nextId++,a:ids[i],b:ids[(i+1)%6],order:1.5});
|
| 1592 |
-
// 5-membered ring sharing bond ids[0]-ids[5]
|
| 1593 |
-
const a7=addAtom(cx+off+45,cy-30,'C');
|
| 1594 |
-
const a8=addAtom(cx+off+55,cy+40,'N');
|
| 1595 |
-
CE.bonds.push({id:CE.nextId++,a:ids[0],b:a7.id,order:2});
|
| 1596 |
-
CE.bonds.push({id:CE.nextId++,a:a7.id,b:a8.id,order:1});
|
| 1597 |
-
CE.bonds.push({id:CE.nextId++,a:a8.id,b:ids[5],order:1});
|
| 1598 |
-
}
|
| 1599 |
-
};
|
| 1600 |
-
if(templates[name]) templates[name]();
|
| 1601 |
-
CE.selectedAtom=null; ceRender();
|
| 1602 |
-
toast(`${name} template loaded`,'success');
|
| 1603 |
-
}
|
| 1604 |
-
|
| 1605 |
-
// SMILES generation from the graph
|
| 1606 |
-
function editorGetSMILES(){
|
| 1607 |
-
if(CE.atoms.length===0){toast('Draw a structure first','warning');return null;}
|
| 1608 |
-
const smiles = graphToSMILES();
|
| 1609 |
-
document.getElementById('draw-smiles-out').innerHTML=`<div class="smiles-box">${smiles}</div>`;
|
| 1610 |
-
toast('SMILES generated','success');
|
| 1611 |
-
return smiles;
|
| 1612 |
-
}
|
| 1613 |
-
|
| 1614 |
-
function graphToSMILES(){
|
| 1615 |
-
if(CE.atoms.length===0) return '';
|
| 1616 |
-
// Build adjacency
|
| 1617 |
-
const adj={};
|
| 1618 |
-
CE.atoms.forEach(a=>{adj[a.id]=[];});
|
| 1619 |
-
CE.bonds.forEach(b=>{
|
| 1620 |
-
adj[b.a]?.push({to:b.b,order:b.order});
|
| 1621 |
-
adj[b.b]?.push({to:b.a,order:b.order});
|
| 1622 |
-
});
|
| 1623 |
-
|
| 1624 |
-
const bondSym={1:'-',2:'=',3:'#',1.5:':'};
|
| 1625 |
-
const visited=new Set();
|
| 1626 |
-
const ringMap={};
|
| 1627 |
-
let ringIdx=1;
|
| 1628 |
-
|
| 1629 |
-
// Detect ring closure bonds via DFS tree
|
| 1630 |
-
const parent={};
|
| 1631 |
-
const stack=[CE.atoms[0].id];
|
| 1632 |
-
const dfsOrder=[];
|
| 1633 |
-
const inStack=new Set();
|
| 1634 |
-
const backEdges=[];
|
| 1635 |
-
|
| 1636 |
-
function dfs(v,par){
|
| 1637 |
-
visited.add(v); dfsOrder.push(v); inStack.add(v);
|
| 1638 |
-
for(const {to,order} of (adj[v]||[])){
|
| 1639 |
-
if(to===par) continue;
|
| 1640 |
-
if(!visited.has(to)){ parent[to]=v; dfs(to,v); }
|
| 1641 |
-
else if(inStack.has(to)){
|
| 1642 |
-
// back edge - ring closure
|
| 1643 |
-
const key=[Math.min(v,to),Math.max(v,to)].join('-');
|
| 1644 |
-
if(!backEdges.find(e=>e.key===key)) backEdges.push({from:v,to,order,key});
|
| 1645 |
-
}
|
| 1646 |
-
}
|
| 1647 |
-
inStack.delete(v);
|
| 1648 |
-
}
|
| 1649 |
-
|
| 1650 |
-
visited.clear();
|
| 1651 |
-
CE.atoms.forEach(a=>{if(!visited.has(a.id)) dfs(a.id,-1);});
|
| 1652 |
-
|
| 1653 |
-
// Assign ring numbers
|
| 1654 |
-
const ringNums={};
|
| 1655 |
-
backEdges.forEach(e=>{
|
| 1656 |
-
const n=ringIdx++;
|
| 1657 |
-
ringNums[e.key]=n;
|
| 1658 |
-
});
|
| 1659 |
-
|
| 1660 |
-
function atomSMILES(id, fromId){
|
| 1661 |
-
const a=CE.atoms.find(x=>x.id===id);
|
| 1662 |
-
const el=a.element;
|
| 1663 |
-
let s='';
|
| 1664 |
-
// Check if organic subset
|
| 1665 |
-
const organic=['B','C','N','O','P','S','F','Cl','Br','I'];
|
| 1666 |
-
if(organic.includes(el)) s=el;
|
| 1667 |
-
else s='['+el+']';
|
| 1668 |
-
|
| 1669 |
-
// Ring closures
|
| 1670 |
-
for(const be of backEdges){
|
| 1671 |
-
if(be.from===id||be.to===id){
|
| 1672 |
-
const n=ringNums[be.key];
|
| 1673 |
-
const bsym=be.order===1?'':bondSym[be.order]||'';
|
| 1674 |
-
s+=bsym+(n>=10?'%'+n:n);
|
| 1675 |
-
}
|
| 1676 |
-
}
|
| 1677 |
-
return s;
|
| 1678 |
-
}
|
| 1679 |
-
|
| 1680 |
-
// DFS-based SMILES builder
|
| 1681 |
-
function buildSMILES(id, parId, usedEdges){
|
| 1682 |
-
let s=atomSMILES(id,parId);
|
| 1683 |
-
const neighbors=(adj[id]||[]).filter(({to})=>{
|
| 1684 |
-
if(to===parId) return false;
|
| 1685 |
-
const key=[Math.min(id,to),Math.max(id,to)].join('-');
|
| 1686 |
-
return !usedEdges.has(key) && !backEdges.find(e=>e.key===key);
|
| 1687 |
-
});
|
| 1688 |
-
if(neighbors.length===0) return s;
|
| 1689 |
-
const [first,...rest]=neighbors;
|
| 1690 |
-
for(const nb of rest){
|
| 1691 |
-
const key=[Math.min(id,nb.to),Math.max(id,nb.to)].join('-');
|
| 1692 |
-
usedEdges.add(key);
|
| 1693 |
-
const bsym=nb.order===1?'':bondSym[nb.order]||'';
|
| 1694 |
-
s+='('+bsym+buildSMILES(nb.to,id,usedEdges)+')';
|
| 1695 |
-
}
|
| 1696 |
-
const key=[Math.min(id,first.to),Math.max(id,first.to)].join('-');
|
| 1697 |
-
usedEdges.add(key);
|
| 1698 |
-
const bsym=first.order===1?'':bondSym[first.order]||'';
|
| 1699 |
-
s+=bsym+buildSMILES(first.to,id,usedEdges);
|
| 1700 |
-
return s;
|
| 1701 |
-
}
|
| 1702 |
-
|
| 1703 |
-
const usedEdges=new Set();
|
| 1704 |
-
let smiles=buildSMILES(CE.atoms[0].id,-1,usedEdges);
|
| 1705 |
-
|
| 1706 |
-
// Handle disconnected components
|
| 1707 |
-
CE.atoms.forEach(a=>{
|
| 1708 |
-
if(!smiles.includes(atomSMILES(a.id,-1).charAt(0))){
|
| 1709 |
-
smiles+='.'+buildSMILES(a.id,-1,usedEdges);
|
| 1710 |
-
}
|
| 1711 |
-
});
|
| 1712 |
-
|
| 1713 |
-
return smiles;
|
| 1714 |
-
}
|
| 1715 |
-
|
| 1716 |
-
async function editorLoad3D(){
|
| 1717 |
-
const smiles=editorGetSMILES();
|
| 1718 |
-
if(!smiles) return;
|
| 1719 |
-
toast('Finding 3D structureβ¦');
|
| 1720 |
-
document.getElementById('draw-3d-status').innerHTML='<div class="alert alert-info"><span class="spin"></span>Looking up in PubChemβ¦</div>';
|
| 1721 |
-
const cid=await smilesLookupCID(smiles);
|
| 1722 |
-
if(cid){
|
| 1723 |
-
await loadCID(cid);
|
| 1724 |
-
document.getElementById('draw-3d-status').innerHTML=`<div class="alert alert-success">β Loaded from PubChem (CID ${cid})</div>`;
|
| 1725 |
-
} else {
|
| 1726 |
-
await synthSDF(smiles,'DrawnMolecule');
|
| 1727 |
-
document.getElementById('draw-3d-status').innerHTML=`<div class="alert alert-success">β Generated 3D coordinates</div>`;
|
| 1728 |
-
}
|
| 1729 |
-
// Sync to draw viewer
|
| 1730 |
-
const dv=getViewer('draw');
|
| 1731 |
-
if(S.ligandSDF&&dv){
|
| 1732 |
-
dv.clear();dv.addModel(S.ligandSDF,'sdf');dv.setStyle({},{stick:{radius:.15},sphere:{scale:.25}});dv.zoomTo();dv.render();
|
| 1733 |
-
document.getElementById('dp').style.display='none';
|
| 1734 |
-
}
|
| 1735 |
-
}
|
| 1736 |
-
|
| 1737 |
-
// ββ Self-contained editor active ββ
|
| 1738 |
-
|
| 1739 |
// βββββββββββββββββββββββ DOCKING βββββββββββββββββββββββ
|
| 1740 |
function updateDockStatus(){
|
| 1741 |
const ps=document.getElementById('dk-prot-status');
|
|
@@ -2539,9 +2225,6 @@ window.addEventListener('load',()=>{
|
|
| 2539 |
// Pre-init all viewers
|
| 2540 |
['protein','ligand','complex','pred'].forEach(k=>getViewer(k));
|
| 2541 |
|
| 2542 |
-
// Init self-contained chem editor (no CDN)
|
| 2543 |
-
ceInit();
|
| 2544 |
-
|
| 2545 |
// Wire sequence live counter
|
| 2546 |
const seqTA = document.getElementById('seq-input');
|
| 2547 |
if(seqTA) seqTA.addEventListener('input', updateSeqInfo);
|
|
|
|
| 8 |
<script src="https://3dmol.csb.pitt.edu/build/3Dmol-min.js"></script>
|
| 9 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.0/chart.umd.min.js"></script>
|
| 10 |
|
|
|
|
| 11 |
<style>
|
| 12 |
*{margin:0;padding:0;box-sizing:border-box}
|
| 13 |
|
|
|
|
| 261 |
}
|
| 262 |
@keyframes sp{to{transform:rotate(360deg)}}
|
| 263 |
|
| 264 |
+
/* IFRAME for PubChem Sketcher */
|
| 265 |
+
.sketch-frame{
|
| 266 |
+
width:100%;
|
| 267 |
+
height:480px;
|
| 268 |
+
border:1px solid var(--border);
|
| 269 |
+
border-radius:12px;
|
| 270 |
+
background:#ffffff;
|
| 271 |
+
margin-bottom:14px;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/* MarVliew container */
|
| 275 |
+
.marvin-container{
|
| 276 |
+
width:100%;
|
| 277 |
+
height:480px;
|
| 278 |
+
border:1px solid var(--border);
|
| 279 |
+
border-radius:12px;
|
| 280 |
+
background:#ffffff;
|
| 281 |
+
margin-bottom:14px;
|
| 282 |
+
position:relative;
|
| 283 |
+
}
|
| 284 |
+
.marvin-container iframe{
|
| 285 |
+
width:100%;
|
| 286 |
+
height:100%;
|
| 287 |
+
border-radius:12px;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
/* MolView link styling */
|
| 291 |
+
.molview-link{
|
| 292 |
+
display:flex;
|
| 293 |
+
align-items:center;
|
| 294 |
+
justify-content:space-between;
|
| 295 |
+
background:var(--bg3);
|
| 296 |
+
border:1px solid var(--border);
|
| 297 |
+
border-radius:12px;
|
| 298 |
+
padding:16px;
|
| 299 |
+
margin-bottom:14px;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.molview-icon{
|
| 303 |
+
font-size:32px;
|
| 304 |
+
opacity:0.8;
|
| 305 |
+
}
|
| 306 |
|
| 307 |
/* INTERACTION TABLE */
|
| 308 |
.interaction-table{width:100%;border-collapse:collapse;font-family:'Space Mono',monospace;font-size:11px}
|
|
|
|
| 375 |
<div class="tabs">
|
| 376 |
<button class="tab active" data-tab="protein">𧬠Protein</button>
|
| 377 |
<button class="tab" data-tab="molecule">π Molecule</button>
|
| 378 |
+
<button class="tab" data-tab="draw">βοΈ Sketch</button>
|
| 379 |
<button class="tab" data-tab="docking">π― Docking</button>
|
| 380 |
<button class="tab" data-tab="sequence">π¬ Sequence</button>
|
| 381 |
<button class="tab" data-tab="ai">π€ AI</button>
|
|
|
|
| 523 |
</div>
|
| 524 |
</div>
|
| 525 |
|
| 526 |
+
<!-- βββββββββββββββ SKETCH PANEL βββββββββββββββ -->
|
| 527 |
<div id="draw-panel" class="panel">
|
| 528 |
<div class="grid2">
|
| 529 |
<div>
|
| 530 |
<div class="card">
|
| 531 |
+
<div class="card-title">PubChem Sketcher</div>
|
| 532 |
+
<div class="alert alert-info">Draw molecules directly in PubChem's online sketcher</div>
|
| 533 |
+
|
| 534 |
+
<!-- PubChem Sketcher Iframe -->
|
| 535 |
+
<iframe id="pubchem-sketch" class="sketch-frame" src="https://pubchem.ncbi.nlm.nih.gov/edit2/index.html" allow="clipboard-read; clipboard-write"></iframe>
|
| 536 |
+
|
| 537 |
+
<div style="display:flex;gap:8px;margin-top:12px;flex-wrap:wrap">
|
| 538 |
+
<button class="btn btn-primary" style="flex:1" onclick="getFromPubChemSketch()">π Get SMILES from Sketcher</button>
|
| 539 |
+
<button class="btn btn-success" style="flex:1" onclick="loadSketchAsLigand()">π¬ Load as Ligand</button>
|
| 540 |
+
<button class="btn" onclick="clearSketch()">π Clear</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 541 |
</div>
|
| 542 |
+
<div id="sketch-smiles-out" class="smiles-box" style="margin-top:10px;display:none"></div>
|
| 543 |
+
</div>
|
| 544 |
|
| 545 |
+
<div class="card">
|
| 546 |
+
<div class="card-title">Marvin JS (Alternative)</div>
|
| 547 |
+
<div class="alert alert-info">Advanced chemical editor from ChemAxon</div>
|
| 548 |
+
|
| 549 |
+
<!-- Marvin JS Container -->
|
| 550 |
+
<div id="marvin-container" class="marvin-container">
|
| 551 |
+
<div style="padding:40px;text-align:center;color:var(--text3)">
|
| 552 |
+
Loading Marvin JS...<br>
|
| 553 |
+
<span class="spin"></span>
|
| 554 |
+
</div>
|
| 555 |
</div>
|
| 556 |
+
|
| 557 |
+
<div style="display:flex;gap:8px;margin-top:12px">
|
| 558 |
+
<button class="btn btn-primary" style="flex:1" onclick="getFromMarvin()">π Get SMILES</button>
|
| 559 |
+
<button class="btn btn-success" style="flex:1" onclick="loadMarvinAsLigand()">π¬ Load as Ligand</button>
|
| 560 |
</div>
|
| 561 |
</div>
|
| 562 |
|
| 563 |
<div class="card">
|
| 564 |
+
<div class="card-title">MolView (External)</div>
|
| 565 |
+
<div class="molview-link">
|
| 566 |
+
<div>
|
| 567 |
+
<div style="font-weight:700;margin-bottom:4px">β MolView</div>
|
| 568 |
+
<div style="font-size:11px;color:var(--text2)">Open in new tab - draw, then export SMILES</div>
|
| 569 |
+
</div>
|
| 570 |
+
<div class="molview-icon">π</div>
|
| 571 |
+
</div>
|
| 572 |
+
<div class="row">
|
| 573 |
+
<input type="text" id="molview-smiles" placeholder="Paste SMILES from MolView">
|
| 574 |
+
<button class="btn btn-success" onclick="loadMolViewSMILES()">Load</button>
|
| 575 |
+
</div>
|
| 576 |
+
<div class="chips" style="margin-top:8px">
|
| 577 |
+
<span class="chip" onclick="window.open('https://molview.org', '_blank')">Open MolView β</span>
|
| 578 |
+
<span class="chip" onclick="document.getElementById('molview-smiles').value = 'c1ccccc1'">Benzene</span>
|
| 579 |
+
<span class="chip" onclick="document.getElementById('molview-smiles').value = 'CC(=O)Oc1ccccc1C(=O)O'">Aspirin</span>
|
| 580 |
+
</div>
|
| 581 |
</div>
|
| 582 |
</div>
|
| 583 |
|
|
|
|
| 594 |
<span class="chip" onclick="setStyle('draw','surface',this)">Surface</span>
|
| 595 |
</div>
|
| 596 |
</div>
|
| 597 |
+
|
| 598 |
+
<div class="card">
|
| 599 |
+
<div class="card-title">Recent Sketches</div>
|
| 600 |
+
<div id="recent-sketches">
|
| 601 |
+
<div class="alert alert-info">No recent sketches</div>
|
| 602 |
+
</div>
|
| 603 |
+
</div>
|
| 604 |
</div>
|
| 605 |
</div>
|
| 606 |
</div>
|
|
|
|
| 830 |
</div>
|
| 831 |
</div>
|
| 832 |
|
| 833 |
+
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script>
|
| 834 |
+
<script>
|
| 835 |
// βββββββββββββββββββββββ STATE βββββββββββββββββββββββ
|
| 836 |
const S = {
|
| 837 |
proteinPDB:null, proteinId:null, proteinSrc:null,
|
|
|
|
| 840 |
ragDocs:[], chatHistory:[],
|
| 841 |
apiKey:'', apiModel:'llama-3.1-8b-instant',
|
| 842 |
viewers:{protein:null,ligand:null,complex:null,draw:null,pred:null},
|
| 843 |
+
ramaChart:null,
|
| 844 |
+
recentSketches: [] // Store recent SMILES
|
| 845 |
};
|
| 846 |
|
| 847 |
// βββββββββββββββββββββββ UTIL βββββββββββββββββββββββ
|
|
|
|
| 871 |
document.querySelectorAll('.panel').forEach(x=>x.classList.remove('active'));
|
| 872 |
t.classList.add('active');
|
| 873 |
document.getElementById(t.dataset.tab+'-panel').classList.add('active');
|
| 874 |
+
|
| 875 |
+
// Initialize Marvin when sketch tab is opened
|
| 876 |
+
if(t.dataset.tab === 'draw') {
|
| 877 |
+
initMarvin();
|
| 878 |
+
}
|
| 879 |
});
|
| 880 |
});
|
| 881 |
|
|
|
|
| 1107 |
}catch(e){toast(`Error: ${e.message}`,'error');}
|
| 1108 |
}
|
| 1109 |
|
| 1110 |
+
// βββββββββββββββββββββββ SKETCHER INTEGRATIONS βββββββββββββββββββββββ
|
| 1111 |
+
|
| 1112 |
+
// PubChem Sketcher
|
| 1113 |
+
function getFromPubChemSketch() {
|
| 1114 |
+
const iframe = document.getElementById('pubchem-sketch');
|
| 1115 |
+
// Post message to PubChem sketcher to get SMILES
|
| 1116 |
+
iframe.contentWindow.postMessage({
|
| 1117 |
+
type: 'getSMILES'
|
| 1118 |
+
}, 'https://pubchem.ncbi.nlm.nih.gov');
|
| 1119 |
+
|
| 1120 |
+
toast('Requesting SMILES from sketcher...', 'info');
|
| 1121 |
+
|
| 1122 |
+
// Listen for response (one-time)
|
| 1123 |
+
window.addEventListener('message', function onSketchMessage(event) {
|
| 1124 |
+
if (event.origin !== 'https://pubchem.ncbi.nlm.nih.gov') return;
|
| 1125 |
+
|
| 1126 |
+
if (event.data && event.data.smiles) {
|
| 1127 |
+
const smiles = event.data.smiles;
|
| 1128 |
+
document.getElementById('sketch-smiles-out').style.display = 'block';
|
| 1129 |
+
document.getElementById('sketch-smiles-out').textContent = smiles;
|
| 1130 |
+
S.recentSketches.push(smiles);
|
| 1131 |
+
updateRecentSketches();
|
| 1132 |
+
toast('SMILES captured from sketcher', 'success');
|
| 1133 |
+
}
|
| 1134 |
+
window.removeEventListener('message', onSketchMessage);
|
| 1135 |
+
});
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
function loadSketchAsLigand() {
|
| 1139 |
+
const smiles = document.getElementById('sketch-smiles-out').textContent;
|
| 1140 |
+
if (!smiles || smiles === '') {
|
| 1141 |
+
toast('No SMILES available. Click "Get SMILES from Sketcher" first', 'warning');
|
| 1142 |
+
return;
|
| 1143 |
+
}
|
| 1144 |
+
loadFromSMILES(smiles, 'PubChem Sketch');
|
| 1145 |
+
}
|
| 1146 |
+
|
| 1147 |
+
function clearSketch() {
|
| 1148 |
+
document.getElementById('sketch-smiles-out').style.display = 'none';
|
| 1149 |
+
document.getElementById('sketch-smiles-out').textContent = '';
|
| 1150 |
+
// Reload iframe to clear sketcher
|
| 1151 |
+
document.getElementById('pubchem-sketch').src = 'https://pubchem.ncbi.nlm.nih.gov/edit2/index.html';
|
| 1152 |
+
}
|
| 1153 |
+
|
| 1154 |
+
// Marvin JS
|
| 1155 |
+
let marvinInstance = null;
|
| 1156 |
+
|
| 1157 |
+
function initMarvin() {
|
| 1158 |
+
const container = document.getElementById('marvin-container');
|
| 1159 |
+
|
| 1160 |
+
// Check if already loaded
|
| 1161 |
+
if (document.getElementById('marvin-iframe')) return;
|
| 1162 |
+
|
| 1163 |
+
// Create iframe for Marvin
|
| 1164 |
+
const iframe = document.createElement('iframe');
|
| 1165 |
+
iframe.id = 'marvin-iframe';
|
| 1166 |
+
iframe.src = 'https://marvinjs.chemicalize.com/editor.html';
|
| 1167 |
+
iframe.style.width = '100%';
|
| 1168 |
+
iframe.style.height = '100%';
|
| 1169 |
+
iframe.style.border = 'none';
|
| 1170 |
+
iframe.style.borderRadius = '12px';
|
| 1171 |
+
|
| 1172 |
+
container.innerHTML = '';
|
| 1173 |
+
container.appendChild(iframe);
|
| 1174 |
+
|
| 1175 |
+
iframe.onload = () => {
|
| 1176 |
+
toast('Marvin JS loaded', 'success');
|
| 1177 |
+
};
|
| 1178 |
+
}
|
| 1179 |
+
|
| 1180 |
+
function getFromMarvin() {
|
| 1181 |
+
const iframe = document.getElementById('marvin-iframe');
|
| 1182 |
+
if (!iframe) {
|
| 1183 |
+
toast('Marvin not loaded yet', 'warning');
|
| 1184 |
+
return;
|
| 1185 |
+
}
|
| 1186 |
+
|
| 1187 |
+
// Post message to Marvin to get SMILES
|
| 1188 |
+
iframe.contentWindow.postMessage({
|
| 1189 |
+
action: 'getSmiles'
|
| 1190 |
+
}, 'https://marvinjs.chemicalize.com');
|
| 1191 |
+
|
| 1192 |
+
window.addEventListener('message', function onMarvinMessage(event) {
|
| 1193 |
+
if (event.origin !== 'https://marvinjs.chemicalize.com') return;
|
| 1194 |
+
|
| 1195 |
+
if (event.data && event.data.smiles) {
|
| 1196 |
+
const smiles = event.data.smiles;
|
| 1197 |
+
document.getElementById('sketch-smiles-out').style.display = 'block';
|
| 1198 |
+
document.getElementById('sketch-smiles-out').textContent = smiles;
|
| 1199 |
+
S.recentSketches.push(smiles);
|
| 1200 |
+
updateRecentSketches();
|
| 1201 |
+
toast('SMILES captured from Marvin', 'success');
|
| 1202 |
+
}
|
| 1203 |
+
window.removeEventListener('message', onMarvinMessage);
|
| 1204 |
+
});
|
| 1205 |
+
}
|
| 1206 |
+
|
| 1207 |
+
function loadMarvinAsLigand() {
|
| 1208 |
+
getFromMarvin(); // This will capture SMILES and then we load it
|
| 1209 |
+
setTimeout(() => {
|
| 1210 |
+
const smiles = document.getElementById('sketch-smiles-out').textContent;
|
| 1211 |
+
if (smiles) loadFromSMILES(smiles, 'Marvin');
|
| 1212 |
+
}, 500);
|
| 1213 |
+
}
|
| 1214 |
+
|
| 1215 |
+
// MolView Integration
|
| 1216 |
+
function loadMolViewSMILES() {
|
| 1217 |
+
const smiles = document.getElementById('molview-smiles').value.trim();
|
| 1218 |
+
if (!smiles) {
|
| 1219 |
+
toast('Enter a SMILES string', 'warning');
|
| 1220 |
+
return;
|
| 1221 |
+
}
|
| 1222 |
+
loadFromSMILES(smiles, 'MolView');
|
| 1223 |
+
}
|
| 1224 |
+
|
| 1225 |
+
// Universal SMILES loader
|
| 1226 |
+
async function loadFromSMILES(smiles, source) {
|
| 1227 |
+
toast(`Converting SMILES from ${source}...`);
|
| 1228 |
+
|
| 1229 |
+
try {
|
| 1230 |
+
// First try PubChem lookup
|
| 1231 |
+
const cid = await smilesLookupCID(smiles);
|
| 1232 |
+
if (cid) {
|
| 1233 |
+
await loadCID(cid);
|
| 1234 |
+
toast(`Loaded from PubChem (CID: ${cid})`, 'success');
|
| 1235 |
+
return;
|
| 1236 |
+
}
|
| 1237 |
+
|
| 1238 |
+
// Fallback to synthetic SDF
|
| 1239 |
+
await synthSDF(smiles, 'Sketched');
|
| 1240 |
+
toast('Generated 3D structure from SMILES', 'success');
|
| 1241 |
+
|
| 1242 |
+
// Add to recent sketches
|
| 1243 |
+
S.recentSketches.push(smiles);
|
| 1244 |
+
updateRecentSketches();
|
| 1245 |
+
|
| 1246 |
+
} catch (e) {
|
| 1247 |
+
toast(`Error: ${e.message}`, 'error');
|
| 1248 |
+
}
|
| 1249 |
+
}
|
| 1250 |
+
|
| 1251 |
+
async function smilesLookupCID(smiles){
|
| 1252 |
+
try{
|
| 1253 |
+
const r=await fetch(`https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/${encodeURIComponent(smiles)}/cids/JSON`);
|
| 1254 |
+
if(r.ok){const d=await r.json();return d.IdentifierList?.CID?.[0]||null;}
|
| 1255 |
+
}catch{}
|
| 1256 |
+
return null;
|
| 1257 |
+
}
|
| 1258 |
+
|
| 1259 |
+
async function synthSDF(smiles,name){
|
| 1260 |
+
// Build a minimal SDF from SMILES atom parse
|
| 1261 |
+
const atoms=[];
|
| 1262 |
+
for(let i=0;i<smiles.length;i++){
|
| 1263 |
+
const c=smiles[i];
|
| 1264 |
+
if(c.match(/[A-Z]/)){
|
| 1265 |
+
let sym=c;
|
| 1266 |
+
if(i+1<smiles.length&&smiles[i+1].match(/[a-z]/)&&!smiles[i+1].match(/[cnops]/)){sym+=smiles[i+1];i++;}
|
| 1267 |
+
if(sym.match(/^(C|N|O|S|P|F|Cl|Br|I|H)$/)) atoms.push(sym);
|
| 1268 |
+
}else if(c.match(/[cnos]/)) atoms.push(c.toUpperCase()); // aromatic
|
| 1269 |
+
}
|
| 1270 |
+
if(atoms.length<3) atoms.push('C','C','C');
|
| 1271 |
+
const coords=atoms.map((_,i)=>{
|
| 1272 |
+
const a=(i/atoms.length)*Math.PI*2;
|
| 1273 |
+
return{x:Math.cos(a)*3+Math.sin(i*.7)*1,y:Math.sin(a)*3+Math.cos(i*.5)*1,z:Math.sin(i*1.2)*2};
|
| 1274 |
+
});
|
| 1275 |
+
let sdf=`${name.substring(0,40)}\n Generated\n\n`;
|
| 1276 |
+
sdf+=` ${String(coords.length).padStart(2)} 0 0 0 0 0 0 0 0999 V2000\n`;
|
| 1277 |
+
coords.forEach((c,i)=>{
|
| 1278 |
+
sdf+=`${c.x.toFixed(4).padStart(10)}${c.y.toFixed(4).padStart(10)}${c.z.toFixed(4).padStart(10)} ${(atoms[i]||'C').padEnd(3)} 0 0 0 0 0\n`;
|
| 1279 |
+
});
|
| 1280 |
+
sdf+='M END\n> <SMILES>\n'+smiles+'\n\n$$$$\n';
|
| 1281 |
+
const ec={};atoms.forEach(a=>{ec[a]=(ec[a]||0)+1;});
|
| 1282 |
+
const mw=atoms.reduce((s,a)=>s+({'C':12.011,'H':1.008,'N':14.007,'O':15.999,'S':32.065,'Cl':35.453,'F':18.998,'Br':79.904}[a]||12.011),0);
|
| 1283 |
+
const props={MolecularFormula:Object.entries(ec).map(([e,n])=>e+(n>1?n:'')).join(''),MolecularWeight:mw.toFixed(2),XLogP:'~1.5',HBondDonorCount:String(atoms.filter(a=>a==='O'||a==='N').length),HBondAcceptorCount:String(atoms.filter(a=>a==='O'||a==='N').length),RotatableBondCount:'3',HeavyAtomCount:String(atoms.length),TPSA:'β',CanonicalSMILES:smiles};
|
| 1284 |
+
initLigandViewer(sdf,props,'Synth');
|
| 1285 |
+
}
|
| 1286 |
+
|
| 1287 |
+
function updateRecentSketches() {
|
| 1288 |
+
const container = document.getElementById('recent-sketches');
|
| 1289 |
+
if (S.recentSketches.length === 0) {
|
| 1290 |
+
container.innerHTML = '<div class="alert alert-info">No recent sketches</div>';
|
| 1291 |
+
return;
|
| 1292 |
+
}
|
| 1293 |
+
|
| 1294 |
+
const recent = S.recentSketches.slice(-5).reverse();
|
| 1295 |
+
container.innerHTML = recent.map((smiles, i) => `
|
| 1296 |
+
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:8px;padding:8px;margin-bottom:6px;display:flex;justify-content:space-between;align-items:center">
|
| 1297 |
+
<span style="font-size:11px;font-family:'Space Mono',monospace;color:var(--yellow);max-width:200px;overflow:hidden;text-overflow:ellipsis">${smiles}</span>
|
| 1298 |
+
<button class="btn btn-sm" onclick="loadFromSMILES('${smiles}', 'Recent')">Load</button>
|
| 1299 |
+
</div>
|
| 1300 |
+
`).join('');
|
| 1301 |
+
}
|
| 1302 |
+
|
| 1303 |
// βββββββββββββββββββββββ IUPAC β 3D (OpenMolecules / OPSIN cascade) βββββββββββββββββββββββ
|
| 1304 |
const IUPAC_SOURCES=['OPSIN','CIR','CACTUS','PubChem','Fallback'];
|
| 1305 |
|
|
|
|
| 1416 |
return null;
|
| 1417 |
}
|
| 1418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1419 |
function ti(type){
|
| 1420 |
const map={aspirin:'2-acetoxybenzoic acid',caffeine:'1,3,7-trimethyl-3,7-dihydro-1H-purine-2,6-dione',ibuprofen:'2-(4-isobutylphenyl)propanoic acid',morphine:'(4R,4aR,7S,7aR,12bS)-3-methyl-2,3,4,4a,7,7a-hexahydro-1H-4,12-methanobenzofuro[3,2-e]isoquinoline-7,9-diol',penicillin:'(2S,5R,6R)-3,3-dimethyl-7-oxo-6-[(phenylacetyl)amino]-4-thia-1-azabicyclo[3.2.0]heptane-2-carboxylic acid'};
|
| 1421 |
document.getElementById('iupac-input').value=map[type]||type;
|
| 1422 |
convertIUPAC();
|
| 1423 |
}
|
| 1424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1425 |
// βββββββββββββββββββββββ DOCKING βββββββββββββββββββββββ
|
| 1426 |
function updateDockStatus(){
|
| 1427 |
const ps=document.getElementById('dk-prot-status');
|
|
|
|
| 2225 |
// Pre-init all viewers
|
| 2226 |
['protein','ligand','complex','pred'].forEach(k=>getViewer(k));
|
| 2227 |
|
|
|
|
|
|
|
|
|
|
| 2228 |
// Wire sequence live counter
|
| 2229 |
const seqTA = document.getElementById('seq-input');
|
| 2230 |
if(seqTA) seqTA.addEventListener('input', updateSeqInfo);
|