Skip to content

Commit

Permalink
#4973 - Connection between molecule and monomer lost after opening an…
Browse files Browse the repository at this point in the history
…d saving to ket

- fixed monomer atoms ids mapping during struct clone
  • Loading branch information
rrodionov91 committed Jul 3, 2024
1 parent 692f0c6 commit b77e708
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ export class MonomerMicromolecule extends SGroup {
return { position: this.pp, atomId: sgroupContractedPosition.atomId };
}

public static clone(monomerMicromolecule: MonomerMicromolecule) {
public static clone(
monomerMicromolecule: MonomerMicromolecule,
atomIdMap?: Map<number, number>,
) {
const monomerMicromoleculeClone = new MonomerMicromolecule(
monomerMicromolecule.type,
monomerMicromolecule.monomer,
);
monomerMicromoleculeClone.pp = monomerMicromolecule.pp;
monomerMicromoleculeClone.atoms = monomerMicromolecule.atoms;
monomerMicromoleculeClone.atoms = atomIdMap
? monomerMicromolecule.atoms.map((elem) => atomIdMap.get(elem))
: monomerMicromolecule.atoms;

return monomerMicromoleculeClone;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-core/src/domain/entities/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class Struct {

sg =
oldSgroup instanceof MonomerMicromolecule
? MonomerMicromolecule.clone(oldSgroup)
? MonomerMicromolecule.clone(oldSgroup, aidMap!)
: SGroup.clone(sg, aidMap!);

const id = cp.sgroups.add(sg);
Expand Down

0 comments on commit b77e708

Please sign in to comment.