Learn R Programming

CHNOSZ (version 0.9-5)

util.data: Modify the Thermodynamic Database

Description

These functions add species to or alter properties of species in the thermodynamic database (thermo$obigt) or in the buffer definition table (thermo$buffer).

Usage

add.obigt(file = system.file("extdata/OBIGT-2.csv", 
    package = "CHNOSZ"), force = FALSE)
  mod.obigt(species, ..., missingvalues = NA)
  add.protein(file="protein.csv")
  change(name, ...)

Arguments

file
character, path to a file.
force
logical, force replacement of already existing species?
...
character or numeric, properties of species to modify in the thermodynamic database.
species
character, formulas or names of species to modify or add to the thermodynamic database.
missingvalues
numeric, values to assign to undefined properties.
name
character or numeric, name (or numeric index) of species or name of buffer to be modified.

Side Effects

These functions can modify the obigt, protein and buffer dataframes in the global thermo list.

Details

add.obigt and add.protein read data from the specified file and add it to either thermo$protein or thermo$obigt, as appropriate. Set force to TRUE to replace species that exist in the thermodynamic database (each unique combination of a name and a state in the database is considered to be a unique species). force, if not specified, reverts to TRUE if the file is left at its default. The default supplementary thermodynamic database (extdata/OBIGT-2.csv) is used in the example calculations in the help page for diagram and also in anim.TCA.

mod.obigt changes one or more of the properties of one or more species or adds species to the thermodynamic database. These changes are lost if you reload the database by calling data(thermo) or if you quit the Rsession without saving it. To modify the properties of species, give the names in the species argument and supply other arguments: if one of these arguments is state, species in those states will be updated. Additional arguments refer to the name of the property(s) to be updated and correspond to the column names of thermo$obigt (the names of the properties are matched to any part of compound column names, such as z.T). The values provided should be in the units specifed in the documentation for the thermo data object. To add species, supply the new names in species and provide an argument named formula with the corresponding chemical formulas. Additional arguments refer to any of the properties you wish to specify. Properties that are not specified are assigned the value of missingvalues which is NA by default (however if state is missing it is set to the value of thermo$opt$state). The values returned (invisible-y) by mod.obigt are the rownumbers of the affected species.

change is a wrapper function to mod.obigt and mod.buffer. The name provided in the argument refers to the name or numeric index of the species to update or add using mod.obigt, unless the name begins with an underscore character, in which case the remaining part of the name (after the underscore) is passed to mod.buffer. The arguments in ... are sent without change to the subordinate function.

See Also

mod.buffer for updated the list of available buffers.

Examples

Run this code
data(thermo)
  ## modify/add species
  info(t <- info("alanine","cr"))
  mod.obigt("alanine",state="cr",G=0,H=0,S=0)
  # now the values of G, H, and S are inconsistent
  # with the elemental composition of alanine
  info(t)
  # add a species
  mod.obigt("myspecies",formula="CHNOSZ",G=0,H=0)
  info(t <- info("myspecies"))

Run the code above in your browser using DataLab