Actelion / openchemlib

Open source Java-based chemistry library
Other
88 stars 30 forks source link

Bug in copyMoleculeByAtoms when H are mapped #97

Open lpatiny opened 1 year ago

lpatiny commented 1 year ago

Sorry for the javascript example ...

It seems there is a bug in copyMoleculeByAtoms when we have recognizeDelocalizedBonds:true and one of the mapped atom in an hydrogen. The atomMap is correct but the hydrogen is not copied.


import OCL from 'openchemlib'
const { Molecule } = OCL

const molecule = Molecule.fromSmiles('C')
molecule.addImplicitHydrogens()
const atomMap = []
const atomMask = [true, true, false, false, false]

let fragment = new Molecule(0, 0)
molecule.copyMoleculeByAtoms(fragment, atomMask, false, atomMap);
console.log(fragment.getAllAtoms(), atomMap) // 2 [ 0, 1, -1, -1, -1 ]

fragment = new Molecule(0, 0)
molecule.copyMoleculeByAtoms(fragment, atomMask, true, atomMap);
// if recognizeDelocalizedBonds is true we have the atomMap but the fragment do not contain the H it points to incorrect atom. We have a mapping to 0 and 1 but only atom 0 exists.
console.log(fragment.getAllAtoms(), atomMap) // 1 [ 0, 1, -1, -1, -1 ]
thsa commented 1 year ago

This is the expected behaviour:


Von: Luc Patiny @.> Gesendet: Montag, 31. Juli 2023 13:34 An: Actelion/openchemlib @.> Cc: Subscribed @.***> Betreff: [Actelion/openchemlib] Bug in copyMoleculeByAtoms when H are mapped (Issue #97)

Sorry for the javascript example ...

It seems there is a bug in copyMoleculeByAtoms when we have recognizeDelocalizedBonds:true and one of the mapped atom in an hydrogen. The atomMap is correct but the hydrogen is not copied.

import OCL from 'openchemlib' const { Molecule } = OCL

const molecule = Molecule.fromSmiles('C') molecule.addImplicitHydrogens() const atomMap = [] const atomMask = [true, true, false, false, false]

let fragment = new Molecule(0, 0) molecule.copyMoleculeByAtoms(fragment, atomMask, false, atomMap); console.log(fragment.getAllAtoms(), atomMap) // 2 [ 0, 1, -1, -1, -1 ]

fragment = new Molecule(0, 0) molecule.copyMoleculeByAtoms(fragment, atomMask, true, atomMap); // if recognizeDelocalizedBonds is true the atomMap is correct but the fragment do not contain the H as is wrong console.log(fragment.getAllAtoms(), atomMap) // 1 [ 0, 1, -1, -1, -1 ]

— Reply to this email directly, view it on GitHubhttps://github.com/Actelion/openchemlib/issues/97, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACNFEBVOBQC4GOWPLZRBS2LXS6J6BANCNFSM6AAAAAA26D3QSU. You are receiving this because you are subscribed to this thread.Message ID: @.***>


The information of this email and in any file transmitted with it is strictly confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any copying, distribution or any other use of this email is prohibited and may be unlawful. In such case, you should please notify the sender immediately and destroy this email. The content of this email is not legally binding unless confirmed by letter. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of the sender's company.