Skip to content

Commit

Permalink
feat(molecule-service): suppress missing labels
Browse files Browse the repository at this point in the history
  • Loading branch information
bence-valent committed Mar 18, 2024
1 parent bb97824 commit 2a4c432
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ export const representationMapper = {
inchiKey: 'InChIKey',
molecularFormula: 'MolecularFormula'
} as const;

export const moleculeToSVGOptions = {
suppressChiralText: true,
suppressCIPParity: true,
suppressESR: true
};
14 changes: 10 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
representationTypes,
type RepresentationType,
representationMapper,
basePath
basePath,
moleculeToSVGOptions
} from './constants';
import { Molecule as MoleculeService } from 'openchemlib/minimal';
import { Molecule as MoleculeService, type IMoleculeToSVGOptions } from 'openchemlib/minimal';

export type Molecule = Record<RepresentationType, string>;
export type MoleculeStorage = Molecule[];
Expand Down Expand Up @@ -61,8 +62,13 @@ export function getUrlFromId(id: number) {
return `${basePath}/cid/${id}/property/${representations},Complexity/JSON`;
}

export function getSVGFromSmiles(smiles: string, width = 250, height = 128) {
return MoleculeService.fromSmiles(smiles).toSVG(width, height);
export function getSVGFromSmiles(
smiles: string,
width = 250,
height = 128,
options: IMoleculeToSVGOptions = moleculeToSVGOptions
) {
return MoleculeService.fromSmiles(smiles).toSVG(width, height, undefined, options);
}

export async function copyToClipboard(molecule: Molecule, representation: RepresentationType) {
Expand Down

0 comments on commit 2a4c432

Please sign in to comment.