Skip to content

Connectivity checker should partition Sgroups correctly and it can be optimised #815

@johnmay

Description

@johnmay

The connectivity checker can be use to split a molecule by breaking bonds. We should document and test this use case more, one corner case not currently handled is the Sgroups. We need to check if a split molecule can inherit and Sgroup correctly.

Also an optimisation is to avoid the copy if there is only a single component. This is now super simple as the SDG seems to depend on some invariant that the molecule but not the atoms/bonds got copied so that needs to be investigated.

    public static IAtomContainerSet partitionIntoMolecules(IAtomContainer container) {
        ConnectedComponents cc = new ConnectedComponents(GraphUtil.toAdjList(container));
        if (cc.nComponents() == 1) {
            IAtomContainerSet acset = container.getBuilder().newInstance(IAtomContainerSet.class);
            acset.addAtomContainer(container);
            return acset;
        }
        return partitionIntoMolecules(container, cc.components());
    }

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