Defines functions demos examples

Documented in demos examples

# CHNOSZ/examples.R
# run examples from the help files, 
# and a function containing extra examples

examples <- function(do.png=FALSE) {
  # run all the examples in CHNOSZ documentation
  .ptime <- proc.time()
  topics <- c("thermo", "examples",
    "util.array", "util.blast", "util.data", "util.expression",
    "util.fasta", "util.formula", "util.matrix", "util.misc", "util.seq", "util.units",
    "util.water", "taxonomy", "info", "protein.info", "hkf", "water", "IAPWS95", "subcrt",
    "makeup", "basis", "swap.basis", "species", "affinity", "equil.boltzmann", 
    "diagram", "buffer", "nonideal", "add.protein", "protein", "ionize.aa", "more.aa", "read.expr",
    "anim", "objective", "revisit", "transfer", "EOSregress", "wjd")
  plot.it <- FALSE
  else if(do.png) plot.it <- TRUE
  for(i in 1:length(topics)) {
    if(plot.it) png(paste(topics[i],"%d.png",sep=""),width=500,height=500,pointsize=12)
    myargs <- list(topic=topics[i],ask=FALSE)
    if(plot.it) dev.off()
  if(is.character(do.png)) dev.off()
  cat("Time elapsed: ", proc.time() - .ptime, "\n")

demos <- function(which=c("sources", "protein.equil", "affinity", "NaCl", "density", 
  "ORP", "revisit", "findit", "ionize", "buffer", "protbuff", "yeastgfp", "mosaic",
  "copper", "solubility", "wjd", "dehydration", "bugstab", "Shh", "activity_ratios",
  "adenine"), to.file=FALSE) {
  # run one or more demos from CHNOSZ with ask=FALSE, and return the value of the last one
  for(i in 1:length(which)) {
    # say something so the user sees where we are
    if(which[i]=="dehydration" & !to.file) {
      message("demos: skipping dehydration demo as to.file is FALSE")
    } else message(paste("demos: running '", which[i], "'", sep=""))
    if(to.file & !which[i]=="dehydration") {
      if(which[i]=="bugstab") png(paste(which[i], "%d.png", sep=""), width=700, height=500, pointsize=12)
      else png(paste(which[i], "%d.png", sep=""), width=500, height=500, pointsize=12)
    out <- demo(which[i], package="CHNOSZ", character.only=TRUE, echo=FALSE, ask=FALSE)
    if(to.file & !which[i]=="dehydration") dev.off()

Try the CHNOSZ package in your browser

Any scripts or data that you put into this service are public.

CHNOSZ documentation built on July 27, 2017, 3:01 a.m.