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

Wrong mapping with copyMoleculeByAtoms #58

Open
lpatiny opened this issue Jan 26, 2020 · 2 comments
Open

Wrong mapping with copyMoleculeByAtoms #58

lpatiny opened this issue Jan 26, 2020 · 2 comments

Comments

@lpatiny
Copy link

lpatiny commented Jan 26, 2020

@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
@thsa
Copy link
Contributor

thsa commented Jan 26, 2020 via email

@lpatiny
Copy link
Author

lpatiny commented Jan 26, 2020

Thanks for the explanation. And the ensureHelperArrays does not provide any mapping array that would allow to track the atoms during this ordering ?

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

No branches or pull requests

2 participants