Molecule I/O

SDFile reader

MolecularGraph.sdfilereaderMethod
sdfilereader(file::IO)
sdfilereader(path::AbstractString)

Read SDFile data from input stream (or a file path as a string) and return a lazy iterator that yields molecule objects.

sdfilereader does not stop and raise errors when an erroneous or incompatible SDFile block is read but produces an error message and yields an empty molecule. If this behavior is not desirable, you can use the customized supplier function instead of default supplier nohaltsupplier

function customsupplier()
    mol = try
        parse(SDFile, block)
    catch e
        throw(ErrorException("incompatible molecule found, aborting..."))
    end
end

function sdfilereader(file::IO)
    return SDFileReader(eachline(file), customsupplier)
end
source
MolecularGraph.sdftomolMethod
sdftomol(lines) -> GraphMol{SDFileAtom,SDFileBond}
sdftomol(file::IO) -> GraphMol{SDFileAtom,SDFileBond}
sdftomol(path::AbstractString) -> GraphMol{SDFileAtom,SDFileBond}

Read a SDFile(.sdf or .mol) and parse it into a molecule object. The given argument should be a file input stream, a file path as a string or an iterator that yields each sdfile text lines.

source

SDFile writer

MolecularGraph.sdfilewriterMethod
sdfilewriter(io::IO, mols)
sdfilewriter(filename::AbstractString, mols)

Write molecule data to the output stream as a SDFile format file.

source

SMILES/SMARTS