Molecule I/O
SDFile reader
MolecularGraph.sdfilereader
— Methodsdfilereader(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
MolecularGraph.sdftomol
— Methodsdftomol(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.
SDFile writer
MolecularGraph.sdfilewriter
— Methodsdfilewriter(io::IO, mols)
sdfilewriter(filename::AbstractString, mols)
Write molecule data to the output stream as a SDFile format file.
SMILES/SMARTS
MolecularGraph.smartstomol
— Methodsmartstomol(smarts::AbstractString) -> QueryMol{SmartsAtom,SmartsBond}
Parse SMARTS string into QueryMol
object.
MolecularGraph.smilestomol
— Methodsmilestomol(smiles::AbstractString) -> GraphMol{SmilesAtom,SmilesBond}
Parse SMILES string into GraphMol
object.