fixProblem: Clean Up a Control Stream

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

These functions are used to re-write a control stream for NONR(checkrunno=TRUE,...).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
fixProblem(x,run)
fixFile(x,run)
explicitPath(x)
extractPath(x)
resolve(file,dir)
scavenge(expr,lines)
extfile(ctlfile,dir,extreg,...)
tabfile(ctlfile,dir,tabreg='(?<!par)\\.tab',...)
parfile(ctlfile,dir,parreg='par\\.tab',...)
msffile(ctlfile,dir,msfreg='^(?!\\$MSFI).*\\.msf',...)

Arguments

x

character vector, i.e. read from control stream file

run

run designator to substitute at predefined locations

file

an absolute or relative filepath

dir

a directory

expr

a regular expression to locate relevant lines

lines

lines in which to search for expr

ctlfile

character vector representing the control stream

extreg

a regular expression to locate an arbitrary file

tabreg

a regular expression to locate the ‘.TAB’ file

parreg

a regular expression to locate the ‘par.TAB’ file

msfreg

a regular expression to locate the ‘.MSF’ file

...

ignored

Details

fixProblem tries to substitute the run name in the NONMEM $PROBLEM statement with the current run name. It looks for any number of leading spaces, and then RUN or RUN\# (optional). The next space delimited word is replaced.

fixFile tries to replace the run name in filenames ending in ‘.msf’, ‘par.tab’, or ‘.tab’. Currently it relies on dirname and basename, which use the same file separator on 'Nix and Windows. basename fails if there is no path separator, e.g., FILE=40.tab. fixFile pre-processes its argument with explicitPath, as a work-around. Lines containing ‘MSFI’ formerly were coerced using explicit paths, but are now ignored.

explicitPath finds lines that contain ‘.tab’ or ‘.msf’ but not ‘/’. It tries to place ‘./’ before ‘run.msf’ or ‘run.tab’.

extractPath’ isolates the file portion of a line of text. The file portion consists of a sequence of nonspace characters following ‘MSF=’, ‘MSFO=’, or ‘FILE=’. Spaces may occur before and after the equality sign. This function is currently used by runNonmem to locate the tabfile, parfile, and msffile.

resolve does nothing to absolute filepaths in file, but expresses others (those beginning with ‘.’) relative to dir.

tabfile, parfile, and msffile calculate corresponding filepaths from their arguments, relying on extfile as the common engine.

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
prob <- c(
	'$  1000 desc',
	'$1000 desc',
	'$RUN1000 desc',
	'$ RUN#1000 desc',
	'$ RUN# 1000 desc'
)
fixProblem(prob,2000)
msf <- c(
	'$EST MAXEVAL=9999 MSF=../1000.MSF',#standard
	'$EST MAXEVAL=9999 msf=../1000.MSF',#case change
	'$EST MAXEVAL=9999 MSF =  ../1000.MSF',#one or two spaces
	'$EST MAXEVAL=9999 MSFO=../1000.MSF',#optional O
	'$EST MAXEVAL=9999 MSF=../1000.msf',#case change
	'$EST MAXEVAL=9999 MSF=../1000.msf INTER',#trailing text
	'$EST MAXEVAL=9999 MSF=../1000/1000.msf',#non-target path elements
	'$EST MAXEVAL=9999 MSF=1000.msf',#no path
	'$MSFI 1000.MSF',#non-target file name
	'$INPUT etc'#non-target
)
fixFile(msf,2000)
tab <- c(
	'ONEHEADER NOPRINT FILE=../1000.TAB',
	'ONEHEADER NOPRINT FILE  = ../1000.TAB',
	'ONEHEADER NOPRINT FILE=../1000par.TAB',
	'ONEHEADER NOPRINT file=../1000par.tab',
	'ONEHEADER NOPRINT file=../1000par.tab',
	'ONEHEADER NOPRINT file= 1000par.tab',
	'ONEHEADER NOPRINT FILE=../1000.TAB',
	'ONEHEADER NOPRINT FILE=~/1000.TAB',
	'ONEHEADER NOPRINT FILE=~/example.tab'
)
fixFile(tab,2000)
files <- c(
	'1000.msf',
	'1000.tab',
	'./1000.tab',
	'../1000.tab',
	'$TABLE EVID FILE=1000.tab',
	'$TABLE EVID FILE=1000par.tab',
	'$MSFI 1000.msf'
)
explicitPath(files)
extractPath(msf)
extractPath(tab)
resolve('./file.ext',dir='project/pk')
resolve('../file.ext',dir='project/pk/')
scavenge('.tab',lines=c('text file.TAB','text file.csv'))
ctlfile <- c('text file=../100.tab etc','text file=../100par.tab etc','text file=../100.msf etc')
tabfile(ctlfile,dir='projectdir/100')
parfile(ctlfile,dir='projectdir/100')
msffile(ctlfile,dir='projectdir/100')

metrumrg documentation built on May 2, 2019, 5:55 p.m.