Closed akulmehta closed 2 years ago
The hydrogens explicitly stored in source file will be displayed in viewer or editor. You may manually clear them with the following code:
var mol = Kekule.IO.loadFormatData(data, Kekule.IO.DataFormat.MOL);
mol.clearExplicitBondHydrogens();
Note the clearExplicitBondHydrogens
method only clears hydrogen atoms connected with simple single bond. The one connected with stereo bond (e.g., the ones with wedge bonds in your image) will be preservered to keep the stereo information.
I am on version 0.9.5.20022100
and I get an error in console:
Here is my code:
import {renderSingleMolecule} from './renderSingleMolecule.js';
function renderMolecules() {
let molFiles = document.querySelectorAll('.mol_file');
molFiles.forEach(molFile => {
let id = molFile.dataset.id;
let file = molFile.textContent;
let mol = Kekule.IO.loadFormatData(file, Kekule.IO.DataFormat.MOL);
mol.clearExplicitBondHydrogens();
renderSingleMolecule(id, mol);
})
}
renderSingleMolecule.js:
export function renderSingleMolecule(id = '', mol) {
var renderType = Kekule.Render.RendererType.R2D//R3D // do 2D or 3D drawing
var is3D = (renderType === Kekule.Render.RendererType.R3D);
// parent HTML element, we will draw inside it
var parentElem = document.getElementById(`linkerstructurediv${id}`);
let width = parentElem.style.width ?? '350px';
let height = parentElem.style.height ?? '350px';
// clear parent elem
Kekule.DomUtils.clearChildContent(parentElem);
var chemViewer = new Kekule.ChemWidget.Viewer(document);
chemViewer.setDimension(width, height)
.setEnableToolbar(false)
.setAutofit(true)
.setRenderType(Kekule.Render.RendererType.R2D)
.appendToElem(parentElem).setChemObj(mol)
}
Any help is appreciated.
The clearExplicitBondHydrogens
method is introduced after version 0.9.5, please use the files in the /dist directory of this repo to overwrite the ones downloaded by npm manually, :).
Thanks it's working now. I thought it was a version issue but just didn't know there was a newer version as the release version in the repo still shows 0.9.3
I am loading the structure from a mol file for e.g. the following mol file is for biotin:
The structure draws with the alkyl hydrogens as circled in red in the image below, creating clutter for larger structures:![image](https://user-images.githubusercontent.com/42812604/127700236-f304cd82-9722-478f-8dfb-a08a6b631b72.png)
Is there a way to draw the structure without these alkyl hydrogens?