-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui updates and scaff_net does not work for now
- Loading branch information
1 parent
62078be
commit 92e358b
Showing
8 changed files
with
204 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { useForm } from "react-hook-form" | ||
import RDKitContext from "../../../context/RDKitContext" | ||
import { useContext } from "react" | ||
|
||
type ScaffoldNetParams = { | ||
includeGenericScaffolds: boolean | ||
includeGenericBondScaffolds: boolean | ||
includeScaffoldsWithoutAttachments: boolean | ||
includeScaffoldsWithAttachments: boolean | ||
keepOnlyFirstFragment: boolean | ||
pruneBeforeFragmenting: boolean | ||
flattenIsotopes: boolean | ||
flattenChirality: boolean | ||
flattenKeepLargest: boolean | ||
collectMolCounts: boolean | ||
bondBreakersRxns: string | ||
} | ||
|
||
export default function ScaffoldSettings(){ | ||
const { rdkit } = useContext(RDKitContext); | ||
const { register, handleSubmit, watch, formState: { errors }, } = useForm<ScaffoldNetParams>(); | ||
|
||
const onSubmit = (data: ScaffoldNetParams) => { | ||
console.log(data); | ||
try{ | ||
var scaffold_net_ins = new rdkit.ScaffoldNetwork(); | ||
scaffold_net_ins.update_scaffold_params(true, true, true, true, true, true, true, true, true, true, []); | ||
}catch(e){ | ||
console.log(e); | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<form className="ml-forms" onSubmit={handleSubmit(onSubmit)}> | ||
<label> | ||
<input type="checkbox" name="includeGenericScaffolds" {...register("includeGenericScaffolds")} defaultChecked/> | ||
includeGenericScaffolds | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="includeGenericBondScaffolds" {...register("includeGenericBondScaffolds")} defaultChecked/> | ||
includeGenericBondScaffolds | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="includeScaffoldsWithoutAttachments" {...register("includeScaffoldsWithoutAttachments")} defaultChecked/> | ||
includeScaffoldsWithoutAttachments | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="includeScaffoldsWithAttachments" {...register("includeScaffoldsWithAttachments")} defaultChecked/> | ||
includeScaffoldsWithAttachments | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="keepOnlyFirstFragment" {...register("keepOnlyFirstFragment")} defaultChecked/> | ||
keepOnlyFirstFragment | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="pruneBeforeFragmenting" {...register("pruneBeforeFragmenting")} defaultChecked/> | ||
pruneBeforeFragmenting | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="flattenIsotopes" {...register("flattenIsotopes")} defaultChecked/> | ||
flattenIsotopes | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="flattenChirality" {...register("flattenChirality")} defaultChecked/> | ||
flattenChirality | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="flattenKeepLargest" {...register("flattenKeepLargest")} defaultChecked/> | ||
flattenKeepLargest | ||
</label> | ||
|
||
<label> | ||
<input type="checkbox" name="collectMolCounts" {...register("collectMolCounts")} defaultChecked/> | ||
collectMolCounts | ||
</label> | ||
|
||
<label> | ||
bondBreakersRxns | ||
<input className = "input" type="text" name="bondBreakersRxns" {...register("bondBreakersRxns")}/> | ||
</label> | ||
|
||
<input type="submit" className = "button" value="Run Network"/> | ||
</form> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
|
||
export default function Screenshotter({ svgRef }) { | ||
const handleConvertAndDownload = (type) => { | ||
if (svgRef.current) { | ||
const svgNode = svgRef.current; | ||
|
||
if (type === 'png') { | ||
const canvas = document.createElement('canvas'); | ||
const context = canvas.getContext('2d'); | ||
|
||
const bbox = svgNode.getBBox(); | ||
|
||
canvas.width = bbox.width + 100; | ||
canvas.height = bbox.height + 100; | ||
|
||
const data = new XMLSerializer().serializeToString(svgNode); | ||
const img = new Image(); | ||
img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(data))); | ||
|
||
img.onload = () => { | ||
if (context) { | ||
context.drawImage(img, 0, 0); | ||
|
||
const pngDataUrl = canvas.toDataURL('image/png'); | ||
|
||
const downloadLink = document.createElement('a'); | ||
downloadLink.download = 'image.png'; | ||
downloadLink.href = pngDataUrl; | ||
downloadLink.style.display = 'none'; | ||
|
||
document.body.appendChild(downloadLink); | ||
downloadLink.click(); | ||
document.body.removeChild(downloadLink); | ||
} | ||
}; | ||
} else if (type === 'svg') { | ||
const svgData = new XMLSerializer().serializeToString(svgNode); | ||
const blob = new Blob([svgData], { type: 'image/svg+xml' }); | ||
const url = URL.createObjectURL(blob); | ||
|
||
const downloadLink = document.createElement('a'); | ||
downloadLink.download = 'image.svg'; | ||
downloadLink.href = url; | ||
downloadLink.style.display = 'none'; | ||
|
||
document.body.appendChild(downloadLink); | ||
downloadLink.click(); | ||
document.body.removeChild(downloadLink); | ||
|
||
URL.revokeObjectURL(url); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<details open = {false}> | ||
<summary>Download chart as image</summary> | ||
<button className='button' onClick={() => handleConvertAndDownload('png')}> | ||
Download PNG | ||
</button> | ||
| ||
<button className='button' onClick={() => handleConvertAndDownload('svg')}> | ||
Download SVG | ||
</button> | ||
</details> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters