## Load sample data
library(ChemmineR)
data(sdfsample); sdfset <- sdfsample
## Not run: write.SDF(sdfset, "test.sdf")
#
# ## Define descriptor set in a simple function
# desc <- function(sdfset) {
# cbind(SDFID=sdfid(sdfset),
# # datablock2ma(datablocklist=datablock(sdfset)),
# MW=MW(sdfset),
# groups(sdfset),
# # AP=sdf2ap(sdfset, type="character"),
# rings(sdfset, type="count", upper=6, arom=TRUE)
# )
# }
#
# ## Run sdfStream with desc function and write results to a file called 'matrix.xls'
# sdfStream(input="test.sdf", output="matrix.xls", append=FALSE, fct=desc, Nlines=1000)
#
# ## Same as before but starting in SD file at line number 950
# sdfStream(input="test.sdf", output="matrix.xls", append=FALSE, fct=desc, Nlines=1000, startline=950)
#
# ## Select molecules from SD File using line index from sdfStream
# indexDF <- read.delim("matrix.xls", row.names=1)[,1:4]
# indexDFsub <- indexDF[indexDF$MW < 400, ] # Selects molecules with MW < 400
# sdfset <- read.SDFindex(file="test.sdf", index=indexDFsub, type="SDFset")
#
# ## Write result directly to SD file without storing larger numbers of molecules in memory
# read.SDFindex(file="test.sdf", index=indexDFsub, type="file", outfile="sub.sdf")
#
# ## Read atom pair string representation from file into APset
# apset <- read.AP(file="matrix.xls", colid="AP")
# cid(apsdf) <- as.character(indexDF$SDFID)
# ## End(Not run)
Run the code above in your browser using DataLab