Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5990 – Extend Ketcher API to allow updating monomers library #6020

Conversation

svvald
Copy link
Collaborator

@svvald svvald commented Nov 27, 2024

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

@svvald svvald force-pushed the 5990-extend-ketcher-api-with-a-function-to-update-monomers-library branch from 2f8753f to 8185dac Compare November 29, 2024 10:33
@svvald svvald force-pushed the 5990-extend-ketcher-api-with-a-function-to-update-monomers-library branch from e8de89e to 97a27ba Compare December 2, 2024 16:13
existingMonomerRefIndex
];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
delete this._monomersLibraryParsedJson![existingMonomerIdToUse];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to write

if (!this._monomersLibraryParsedJson) {
  return
}

Than use several times non-null assertion


if (!editor) {
throw new Error(
'Updating monomer library in small molecules mode is not allowed, please switch to macromolecules mode',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can store libraries somewhere and use them on macro mode initialization stage

public updateMonomersLibrary(rawMonomersData: string | JSON) {
const editor = CoreEditor.provideEditorInstance();

ketcherProvider.getKetcher();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this call?

Comment on lines +70 to +72
let persistentMonomersLibrary: MonomerItemType[] = [];
let persistentMonomersLibraryParsedJson: IKetMacromoleculesContent | null =
null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we can allow to call api several times and update library several times consequently? In this case we need to store array of libraries

@svvald svvald merged commit ec99d8f into master Dec 3, 2024
5 checks passed
@svvald svvald deleted the 5990-extend-ketcher-api-with-a-function-to-update-monomers-library branch December 3, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend Ketcher API with a function to update monomers library
2 participants