mojaie / MolecularGraph.jl

Graph-based molecule modeling toolkit for cheminformatics
MIT License
189 stars 27 forks source link

RDKit GetMolFrags equivalent? #73

Closed longemen3000 closed 1 year ago

longemen3000 commented 2 years ago

hi, i'm trying to use this library to implement an UNIFAC group fragmenter (based on https://github.com/simonmb/fragmentation_algorithm/blob/master/fragmenter.py). looking at the code, the only function to do so that i couldn't find in this library (and not depend on RDKit) is rdkit.Chem.GetMolFrags https://www.rdkit.org/docs/source/rdkit.Chem.rdmolops.html . Does MolecularGraph have some equivalent method?

mojaie commented 2 years ago

Thank you for your comment. I guess MolecularGraph.Graph.connectedcomponents is what you want.

using MolecularGraph
using MolecularGraph.Graph

mol = smilestomol("CC(=O)[O-].[NH3+]C")
mol = removehydrogens(mol)
connectedcomponents(mol)

output:

2-element Vector{Set{Int64}}:
 Set([5, 6])
 Set([4, 2, 3, 1])

There are more graph topology-related functions in MolecularGraph.Graph https://github.com/mojaie/MolecularGraph.jl/tree/master/src/graph