write.SDF {ChemmineR} | R Documentation

## SDF export function

### Description

Writes one or many molecules stored in a `SDFset`, `SDFstr` or `SDF` object to SD file.

### Usage

    write.SDF(sdf, file, cid = FALSE, ...)

### Arguments

`sdf` | object of class `SDFset`, `SDFstr` or `SDF`
`file` | name of SD file to write to
`cid` | if `cid = TRUE` and an `SDFset` object is provide as input, then the compound IDs in the ID slot of the `SDFset` are used for compound naming
`...` | the optional arguments of the `sdf2str` function can be provided here, including `head, ab, bb, db`; details are provided in the help page for the `sdf2str` function

### Details

If the `write.SDF` function is supplied with an `SDFset` object, then it uses internally the `sdf2str` function to allow customizing the resulting SD file. For this all optional arguments of the `sdf2str` function can be passed on to `write.SDF`.

### Author(s)

Thomas Girke

### References

SDF format definition: http://www.symyx.com/downloads/public/ctfile/ctfile.jsp

### See Also

Import function: `read.SDFset`, `read.SDFstr`

### Examples

    ## Instance of SDFset class
    data(sdfsample); sdfset <- sdfsample

    ## Write objects of classes SDFset/SDFstr/SDF to file
    # write.SDF(sdfset[1:4], file="sub.sdf")

    ## Example for writing customized SDFset to file containing
    ## ChemmineR signature, IDs from SDFset and no data block
    # write.SDF(sdfset[1:4], file="sub.sdf", sig=TRUE, cid=TRUE, db=NULL)

    ## Example for injecting a custom matrix/data frame into the data block of an
    ## SDFset and then writing it to an SD file
    props <- data.frame(MF=MF(sdfset), MW=MW(sdfset), atomcountMA(sdfset))
    datablock(sdfset) <- props
    view(sdfset[1:4])
    # write.SDF(sdfset[1:4], file="sub.sdf", sig=TRUE, cid=TRUE)

[Package ChemmineR version 3.44.0 Index]