Conversation
… of IChemObject flag VISITED for safe parallelisation
Member
|
Looks ok but I really would not share a molecule in a parallel environment. So much of the rest of the toolkit depends on this not being the case and it's just useful to draw the line there. If you want to work on something in multiple thread makes a copy but mostly you should only really need parallelism for large sets of molecules. Any method which is too slow on a single molecule on modern hardware is likely not a useful method. |
johnmay
reviewed
Sep 1, 2025
| for (Object bond : bonds) { | ||
| nextAtom = ((IBond) bond).getOther(atom); | ||
| logger.debug("BreadthFirstSearch around atom " + (container.indexOf(atom) + 1)); | ||
| List<IBond> bonds = container.getConnectedBondsList(atom); |
Member
There was a problem hiding this comment.
You can now safely use for (IBond bond : atom.bonds())
johnmay
reviewed
Sep 1, 2025
| || nextAtom.getAtomicNumber() == IElement.N || nextAtom.getAtomicNumber() == IElement.O) | ||
| & !nextAtom.getFlag(IChemObject.VISITED)) { | ||
| //logger.debug("BDS> AtomNr:"+container.indexOf(nextAtom)+" maxBondOrder:"+container.getMaximumBondOrder(nextAtom)+" Aromatic:"+nextAtom.getFlag(CDKConstants.ISAROMATIC)+" FormalCharge:"+nextAtom.getFormalCharge()+" Charge:"+nextAtom.getCharge()+" Flag:"+nextAtom.getFlag(CDKConstants.VISITED)); | ||
| && !visited[container.indexOf(nextAtom)]) { |
johnmay
reviewed
Sep 1, 2025
| } | ||
| } else { | ||
| nextAtom.setFlag(IChemObject.VISITED, true); | ||
| visited[container.indexOf(nextAtom)] = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes LargestPiSystemDescriptor use an internal "visited" array instead of the IChemObject flag VISITED of the atoms for safe parallelisation over shared molecule instances.
Also, minor code improvements in exception handling and un-commented debug messages (and added a logger to the class, first of all).