diff --git a/R/greedyMix.R b/R/greedyMix.R index 9323899..4445e4b 100644 --- a/R/greedyMix.R +++ b/R/greedyMix.R @@ -1546,30 +1546,6 @@ greedyMix <- function( # %------------------------------------------------------- -# function pal = testaaPop(rivi) -# % pal=1, mik�li rivi alkaa jollain seuraavista -# % kirjainyhdistelmist? Pop, pop, POP. Kaikissa muissa -# % tapauksissa pal=0. - -# if length(rivi)<3 -# pal = 0; -# return -# end -# if (all(rivi(1:3)=='Pop') | ... -# all(rivi(1:3)=='pop') | ... -# all(rivi(1:3)=='POP')) -# pal = 1; -# return -# else -# pal = 0; -# return -# end - - - -# %---------------------------------------------------------------------------- - - # function dist2 = laskeOsaDist(inds2, dist, ninds) # % Muodostaa dist vektorista osavektorin, joka sis�lt�� yksil�iden inds2 # % v�liset et�isyydet. ninds=kaikkien yksil�iden lukum��r? diff --git a/R/testaaGenePopData.R b/R/testaaGenePopData.R index 5654dcf..7b3810d 100644 --- a/R/testaaGenePopData.R +++ b/R/testaaGenePopData.R @@ -17,7 +17,7 @@ testaaGenePopData <- function(tiedostonNimi) { if (line1 == -1 | line2 == -1 | line3 == -1) { stop('Incorrect file format 1168') } - if (testaaPop(line1) == 1 | testaaPop(line2) == 1) { # TODO: translate function + if (testaaPop(line1) == 1 | testaaPop(line2) == 1) { stop('Incorrect file format 1172') } if (testaaPop(line3) == 1) { diff --git a/R/testaaPop.R b/R/testaaPop.R new file mode 100644 index 0000000..37040fe --- /dev/null +++ b/R/testaaPop.R @@ -0,0 +1,27 @@ +#' @title Test population +#' @description Test a line in the population +#' @param rivi Line +#' @return pal +#' @export +testaaPop <- function(rivi) { + # pal=1, mik�li rivi alkaa jollain seuraavista + # kirjainyhdistelmist? Pop, pop, POP. Kaikissa muissa + # tapauksissa pal=0. + + if (length(rivi) < 3) { + pal <- 0 + return(pal) + } + if ( + all(rivi[1:3] == 'Pop') | + all(rivi[1:3] == 'pop') | + all(rivi(1:3)=='POP') + ) { + pal <- 1 + return(pal) + } else { + pal <- 0; + return(pal) + } + return(pal) +} \ No newline at end of file