Spaces:
Running
Running
push new db or demo version
Browse files- requirements.txt +1 -2
- src/static/main.js +5 -0
- src/static/main.min.js +1 -1
requirements.txt
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
-
chem-mrl>=0.6.
|
| 2 |
-
datasets
|
| 3 |
gradio[mcp]>=4.0.0
|
| 4 |
transformers>=4.30.0
|
| 5 |
torch>=2.0.0
|
|
|
|
| 1 |
+
chem-mrl>=0.6.3
|
|
|
|
| 2 |
gradio[mcp]>=4.0.0
|
| 3 |
transformers>=4.30.0
|
| 4 |
torch>=2.0.0
|
src/static/main.js
CHANGED
|
@@ -26,6 +26,9 @@ const SMILES_INPUT_SELECTOR = "#smiles_input textarea, #smiles_input input";
|
|
| 26 |
/** @const {string} CSS selector for the Gradio Mol file input element */
|
| 27 |
const MOL_INPUT_SELECTOR = "#mol_input textarea, #mol_input input";
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
/** @const {number} Delay for paste event handling (ms) */
|
| 30 |
const PASTE_DELAY = 50;
|
| 31 |
|
|
@@ -47,6 +50,8 @@ function initializeChemWriter() {
|
|
| 47 |
setupSmilesTextboxEventListeners();
|
| 48 |
setupChemWriterEventListeners();
|
| 49 |
editor.setSMILES(DEFAULT_SMILES);
|
|
|
|
|
|
|
| 50 |
console.log("ChemWriter initialized successfully");
|
| 51 |
} catch (error) {
|
| 52 |
console.error("Error initializing ChemWriter:", error);
|
|
|
|
| 26 |
/** @const {string} CSS selector for the Gradio Mol file input element */
|
| 27 |
const MOL_INPUT_SELECTOR = "#mol_input textarea, #mol_input input";
|
| 28 |
|
| 29 |
+
/** @const {string} CSS selector for the Gradio search button */
|
| 30 |
+
const SEARCH_BUTTON_SELECTOR = "#search_btn";
|
| 31 |
+
|
| 32 |
/** @const {number} Delay for paste event handling (ms) */
|
| 33 |
const PASTE_DELAY = 50;
|
| 34 |
|
|
|
|
| 50 |
setupSmilesTextboxEventListeners();
|
| 51 |
setupChemWriterEventListeners();
|
| 52 |
editor.setSMILES(DEFAULT_SMILES);
|
| 53 |
+
// search after the rest of the gradio components load
|
| 54 |
+
setTimeout(() => document.getElementById("search_btn")?.click(), 500);
|
| 55 |
console.log("ChemWriter initialized successfully");
|
| 56 |
} catch (error) {
|
| 57 |
console.error("Error initializing ChemWriter:", error);
|
src/static/main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
function initializeChemWriter(){try{setupSmilesTextboxEventListeners(),setupChemWriterEventListeners(),editor.setSMILES(DEFAULT_SMILES)}catch(e){}}function updateGradioTextbox(){try{const e=document.querySelector(MOL_INPUT_SELECTOR),t=editor?.getMolfile();e.value=t,GRADIO_CHANGE_EVENTS.forEach((t=>{const i=new Event(t,{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}))}catch(e){}}function updateChemWriterFromTextbox(e){try{e=e.trim(),editor?.setSMILES(e)}catch(e){}}function setupSmilesTextboxEventListeners(){const e=document.querySelector(SMILES_INPUT_SELECTOR);e&&(e.addEventListener("input",handleTextboxChange),e.addEventListener("change",handleTextboxChange),e.addEventListener("paste",handleTextboxPaste))}function setupChemWriterEventListeners(){window.addEventListener("resize",(()=>editor.jd())),editor.addEventListener("document-edited",updateGradioTextbox)}function handleTextboxChange(e){updateChemWriterFromTextbox(e.target.value)}function handleTextboxPaste(e){setTimeout((()=>{updateChemWriterFromTextbox(e.target.value)}),50)}function initializeWhenReady(){chemwriter=window?.chemwriter,chemwriter?.System?.De(),editor=chemwriter?.components?.editor,void 0!==chemwriter?.System?.De&&void 0!==editor?chemwriter.System.ready(initializeChemWriter):setTimeout(initializeWhenReady,250)}let editor=null,chemwriter=null;const DEFAULT_SMILES="CN(C)CCC1=CNC2=C1C(=CC=C2)OP(=O)(O)O",SMILES_INPUT_SELECTOR="#smiles_input textarea, #smiles_input input",MOL_INPUT_SELECTOR="#mol_input textarea, #mol_input input",PASTE_DELAY=50,INIT_RETRY_DELAY=250,GRADIO_CHANGE_EVENTS=["input","change"];window.setCWSmiles=function(e){updateChemWriterFromTextbox(e)},window.clearCW=function(){editor.setMolfile("\nCWRITER06142521562D\nCreated with ChemWriter - https://chemwriter.com\n 0 0 0 0 0 0 0 0 0 0999 V2000\nM END")},initializeWhenReady();
|
|
|
|
| 1 |
+
function initializeChemWriter(){try{setupSmilesTextboxEventListeners(),setupChemWriterEventListeners(),editor.setSMILES(DEFAULT_SMILES),setTimeout((()=>document.getElementById("search_btn")?.click()),500)}catch(e){}}function updateGradioTextbox(){try{const e=document.querySelector(MOL_INPUT_SELECTOR),t=editor?.getMolfile();e.value=t,GRADIO_CHANGE_EVENTS.forEach((t=>{const i=new Event(t,{bubbles:!0,cancelable:!0});e.dispatchEvent(i)}))}catch(e){}}function updateChemWriterFromTextbox(e){try{e=e.trim(),editor?.setSMILES(e)}catch(e){}}function setupSmilesTextboxEventListeners(){const e=document.querySelector(SMILES_INPUT_SELECTOR);e&&(e.addEventListener("input",handleTextboxChange),e.addEventListener("change",handleTextboxChange),e.addEventListener("paste",handleTextboxPaste))}function setupChemWriterEventListeners(){window.addEventListener("resize",(()=>editor.jd())),editor.addEventListener("document-edited",updateGradioTextbox)}function handleTextboxChange(e){updateChemWriterFromTextbox(e.target.value)}function handleTextboxPaste(e){setTimeout((()=>{updateChemWriterFromTextbox(e.target.value)}),50)}function initializeWhenReady(){chemwriter=window?.chemwriter,chemwriter?.System?.De(),editor=chemwriter?.components?.editor,void 0!==chemwriter?.System?.De&&void 0!==editor?chemwriter.System.ready(initializeChemWriter):setTimeout(initializeWhenReady,250)}let editor=null,chemwriter=null;const DEFAULT_SMILES="CN(C)CCC1=CNC2=C1C(=CC=C2)OP(=O)(O)O",SMILES_INPUT_SELECTOR="#smiles_input textarea, #smiles_input input",MOL_INPUT_SELECTOR="#mol_input textarea, #mol_input input",SEARCH_BUTTON_SELECTOR="#search_btn",PASTE_DELAY=50,INIT_RETRY_DELAY=250,GRADIO_CHANGE_EVENTS=["input","change"];window.setCWSmiles=function(e){updateChemWriterFromTextbox(e)},window.clearCW=function(){editor.setMolfile("\nCWRITER06142521562D\nCreated with ChemWriter - https://chemwriter.com\n 0 0 0 0 0 0 0 0 0 0999 V2000\nM END")},initializeWhenReady();
|