'start'
'#Copyright (c) 2009, 2010 Sebastien Bihorel'
'#All rights reserved.'
'#'
'#This file is part of scaRabee.'
'#'
'#    scaRabee is free software: you can redistribute it and/or modify'
'#    it under the terms of the GNU General Public License as published by'
'#    the Free Software Foundation, either version 3 of the License, or'
'#    (at your option) any later version.'
'#'
'#    scaRabee is distributed in the hope that it will be useful,'
'#    but WITHOUT ANY WARRANTY; without even the implied warranty of'
'#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the'
'#    GNU General Public License for more details.'
'#'
'#    You should have received a copy of the GNU General Public License'
'#    along with scaRabee.  If not, see <http://www.gnu.org/licenses/>.'
'#'
'@newline@'
'secondary <- function(x=NULL){'
'  #'
'  # AIM: Compute secondary parameters'
'  #'
'  # INPUT: x - data frame containing primary model parameters (model,'
'  #            delays, variability, initial conditions)'
'@newline@'
'  # Initializes vector of secondary parameters'
'  secparam <- c()'
'@newline@'
'  # Extracts primary parameters'
'  parms <- c(get.param.data(x=x,which=\'value\',type=\'P\'),'
'             get.param.data(x=x,which=\'value\',type=\'L\'),'
'             get.param.data(x=x,which=\'value\',type=\'IC\'),'
'             get.param.data(x=x,which=\'value\',type=\'V\'))'
'  names(parms) <- c(get.param.data(x=x,which=\'names\',type=\'P\'),'
'                    get.param.data(x=x,which=\'names\',type=\'L\'),'
'                    get.param.data(x=x,which=\'names\',type=\'IC\'),'
'                    get.param.data(x=x,which=\'names\',type=\'V\'))'
'@newline@'
'  sec <- with(as.list(parms),{'
'  #########################################################################'
'  #                        USER CODE STARTS HERE'
'  #########################################################################'
'@newline@'
'  # User-defined secondary parameters'
'  # example'
'  # sec <- c(\'t1/2\'=log(2)*CL/V,'
'  #          \'Q\'=k12*Vt)'
'@newline@'
'  sec <- c()'
'@newline@'
'  #########################################################################'
'  #                         USER CODE ENDS HERE'
'  #########################################################################'
'    return(sec)}'
'  )'
'@newline@'
'  if (is.null(names(sec)) & !is.null(sec))'
'    stop(\'sec: Please provide names for all elements.\','
'         call.=FALSE)'
'@newline@'
'  if (any(names(sec)==\'\'))'
'    stop(\'sec: Please provide names for all elements.\','
'         call.=FALSE)'
'@newline@'
'  # Checks that names and secparam have the same dimensions:'
'  names <- names(sec)'
'  secparam <- as.vector(sec)'
'@newline@'
'  if (length(names)!=length(secparam))'
'    stop(paste(\'secondary: Secondary parameter variables names and\','
'               \'secparam should have the same dimension\'),'
'         call.=FALSE)'
'@newline@'
'  if (!is.null(secparam))'
'    secparam <- transpose(secparam)'
'@newline@'
'  if (!is.null(names))'
'    names <- transpose(names)'
'@newline@'
'  varargout <- list(secparam=secparam,'
'                    names=names)'
'@newline@'
'  return(varargout)'
'@newline@'
'}'
'@newline@'