mojaie / MolecularGraph.jl

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

Add reactions #61

Closed hhaensel closed 2 years ago

hhaensel commented 2 years ago

It would be a great thing to also cover reactions in your package.

I've written a very simple parser to decompose a V2000 reaction file into its reactands and products for the beginning

function parserxn(rxn::AbstractString)
    parts = split(rxn, r"\$MOL\r?\n")
    (ne, np) = parse.(Int, split(split(first(parts), r"\r?\n")[end-1]))
    ee = parts[2:1 + ne]
    pp = parts[(2 + ne):(1 + ne + np)]
    ee, pp
end

For a correct implementation, one would need, of course, to define a reaction type and also cover the V3000 format.