Skip to content

Wrong mapping with copyMoleculeByAtoms #58

@lpatiny

Description

@lpatiny

@thsa

Related to #57

If a molecule contains hydrogen and we replace one of the hydrogens by a 'X' (not the first one, the second one), after copyMoleculeByAtoms the new position of the 'X' is not the one that is specified in the atomMap.

import OCL from 'openchemlib';

import { initOCL } from '../src';

initOCL(OCL);

const molecule = OCL.Molecule.fromSmiles('C');
molecule.addImplicitHydrogens();
molecule.setAtomicNo(2, 153); // we set a 'X' as atom

const copy = new OCL.Molecule(0, 0);
copy.setFragment(false);
const atomMap = [];
molecule.copyMoleculeByAtoms(
  copy,
  [true, true, true, false, false],
  true,
  atomMap,
);

console.log(copy.getAllAtoms()); // returns 1

console.log(atomMap); // returns [ 0, 1, 2, -1, -1 ]

console.log(copy.getAtomicNo(1)); // returns 153, should be 1
console.log(copy.getAtomicNo(2)); // returns -1, should be 153 based on atomMap

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions