Skip to content

Commit 314f57b

Browse files
authored
Merge pull request #89 from mpi2/remove-equation
Get rid of `EquationMap.conf` and functions that process this file
2 parents c894556 + 03f4fda commit 314f57b

File tree

3 files changed

+1
-34552
lines changed

3 files changed

+1
-34552
lines changed

Late adults stats pipeline/DRrequiredAgeing/DRrequiredAgeingPackage/R/main.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ mainAgeing = function(file = NULL ,
9898
# Config files
9999
message0('Loading configuration ...')
100100
methodmap = readConf('MethodMap.conf')
101-
equationmap = readConf('EquationMap.conf')
102101
CategoryMap = readConf('CategoryMap.conf')
103102
MergeCategoryParameters = read.csv(file = file.path(local(), 'MergeParameterList.txt'))
104103
initial = readConf('Initialize.conf')
@@ -802,8 +801,7 @@ mainAgeing = function(file = NULL ,
802801
data = a@datasetPL
803802
) <= .2 &&
804803
EnoughWeightForTheSexGenInteraction(a@datasetPL) ,
805-
getEquation(var = parameter,
806-
equationMap = equationmap),
804+
'withWeight',
807805
'withoutWeight'
808806
)
809807
} else{

Late adults stats pipeline/DRrequiredAgeing/DRrequiredAgeingPackage/R/sideFunctions.R

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -576,26 +576,6 @@ getMethodi = function(var,
576576
return(method)
577577
}
578578

579-
# Equation map
580-
getEquation = function(var,
581-
equationMap = NULL)
582-
{
583-
matched001 = sapply(names(equationMap), grepl, var)
584-
if (sum(matched001) > 0) {
585-
if (sum(matched001) > 1) {
586-
equationMapReduced = equationMap[matched001]
587-
mappedPatternLengths = nchar(names(equationMapReduced))
588-
equation =
589-
unlist(equationMapReduced[which(mappedPatternLengths == max(mappedPatternLengths))])
590-
} else {
591-
equation = unlist(equationMap[matched001])
592-
}
593-
} else{
594-
equation = 'withWeight'
595-
}
596-
return(equation)
597-
}
598-
599579
local = function(x=NULL){
600580
r= system.file("extdata", package = "DRrequiredAgeing")
601581
return(r)
@@ -4029,64 +4009,6 @@ requiredDataColumns = function(x){
40294009
return(ColumnsList)
40304010
}
40314011

4032-
updateEquationMap = function(updatePackage = TRUE) {
4033-
# Extract Centers name from the skip list
4034-
metapars = read.csv(file = file.path(local(), 'metadataParameters.csv'))
4035-
centers = lapply(strsplit(
4036-
metapars$parameter_stable_id,
4037-
split = '_',
4038-
fixed = TRUE
4039-
), function(x) {
4040-
return (x[1])
4041-
})
4042-
centers = unique(unlist(centers))
4043-
4044-
# Extract parameters from the method map
4045-
methodmap = readConf('EquationMap.conf')
4046-
orgparsColon = paste(names(methodmap), methodmap, sep = ':')
4047-
orgpars = paste(names(methodmap), methodmap, sep = '_')
4048-
parameters = lapply(strsplit(orgpars,
4049-
split = '_',
4050-
fixed = TRUE), function(x) {
4051-
if (length(x) <= 5) {
4052-
r = c()
4053-
for (i in 1:6) {
4054-
y = x
4055-
y[length(y) - 1] = paste(paste0('00', i, collapse = ''), y[length(y)], sep=':',collapse = ':')
4056-
r = c(r, paste(y[-c(1,length(y))], sep = '_', collapse = '_'))
4057-
}
4058-
return (r)
4059-
} else{
4060-
return(NULL)
4061-
}
4062-
})
4063-
parameters = unlist(parameters)
4064-
4065-
#combine two lists
4066-
#r = apply(expand.grid(centers, parameters), 1, paste, collapse = "_")
4067-
r = as.vector(outer(centers, parameters, paste, sep="_"))
4068-
r = unique(c(orgparsColon, sort(r)))
4069-
if (updatePackage) {
4070-
write.table(
4071-
r,
4072-
file = system.file("extdata", "EquationMap.conf", package = "DRrequiredAgeing"),
4073-
row.names = FALSE,
4074-
col.names = FALSE,
4075-
quote = FALSE
4076-
)
4077-
} else{
4078-
write.table(
4079-
r,
4080-
file = file.path(getwd(), "EquationMap.conf"),
4081-
row.names = FALSE,
4082-
col.names = FALSE,
4083-
quote = FALSE
4084-
)
4085-
}
4086-
gc()
4087-
return(invisible(r))
4088-
}
4089-
40904012
updateMethodMap = function(updatePackage = TRUE) {
40914013
# Extract Centers name from the skip list
40924014
metapars = read.csv(file = file.path(local(), 'metadataParameters.csv'))
@@ -4262,10 +4184,6 @@ updateImpress = function(updateImpressFileInThePackage = FALSE,
42624184
updateMethodMap(updateImpressFileInThePackage)
42634185
}
42644186
###################################################
4265-
if(updateEquationMapHuristic){
4266-
updateEquationMap(updateImpressFileInThePackage)
4267-
}
4268-
###################################################
42694187
return(invisible(list(
42704188
categories = outP, dfObject = df
42714189
)))

0 commit comments

Comments
 (0)