Skip to content

Commit

Permalink
feat: Option to specify hose codes min / maxSphereSize in TopicMolecule
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatiny committed May 8, 2024
1 parent 4c4321b commit 8e75bd5
Show file tree
Hide file tree
Showing 4 changed files with 530 additions and 12 deletions.
5 changes: 4 additions & 1 deletion src/topic/TopicMolecule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Molecule } from 'openchemlib';

import { getConnectivityMatrix } from '../util/getConnectivityMatrix.js';

import { HoseCodesOptions } from './HoseCodesOptions.js';
import { getCanonizedDiaIDs } from './getCanonizedDiaIDs';
import { getCanonizedHoseCodes } from './getCanonizedHoseCodes';
import { getDiaIDsAndInfo } from './getDiaIDsAndInfo';
Expand All @@ -24,11 +25,13 @@ export class TopicMolecule {
private readonly originalMolecule: Molecule;
molecule: Molecule;
idCode: string;
options: HoseCodesOptions;

private cache: any;

Check warning on line 30 in src/topic/TopicMolecule.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected any. Specify a different type

constructor(molecule: Molecule) {
constructor(molecule: Molecule, options: HoseCodesOptions = {}) {
this.originalMolecule = molecule;
this.options = options;
this.idCode = molecule.getIDCode();
this.molecule = this.originalMolecule.getCompactCopy();
this.molecule.ensureHelperArrays(
Expand Down
13 changes: 13 additions & 0 deletions src/topic/__tests__/TopicMolecule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ describe('TopicMolecule', () => {
expect(hoses).toMatchSnapshot();
expect(hoses[3]).toStrictEqual(hoses[4]);
expect(hoses).toMatchSnapshot();
expect(hoses[0]).toHaveLength(5);
});

it('ethanol with max sphere size', () => {
const molecule = Molecule.fromSmiles('CCO');
const topicMolecule = new TopicMolecule(molecule, { maxSphereSize: 5 });

const hoses = topicMolecule.hoseCodes;
expect(hoses).toHaveLength(9);
expect(hoses).toMatchSnapshot();
expect(hoses[3]).toStrictEqual(hoses[4]);
expect(hoses).toMatchSnapshot();
expect(hoses[3]).toHaveLength(6);
});

it('2-chlorobutane', () => {
Expand Down
Loading

0 comments on commit 8e75bd5

Please # to comment.