~ubuntu-branches/ubuntu/vivid/r-cran-readbrukerflexdata/vivid

« back to all changes in this revision

Viewing changes to R/sampleName-functions.R

  • Committer: Package Import Robot
  • Author(s): The Debichem Group
  • Date: 2013-04-28 21:12:31 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130428211231-z7cpxg3pk0rjvuva
Tags: 1.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#' ./Run2/2-100kDa/0_A1/1/1SLin/fid \cr
31
31
#' ./Run2/2-100kDa/0_B1/1/1SLin/fid \cr
32
32
#'
33
 
#' @param fidFile \code{character}, path to fid file 
 
33
#' @param fidFile \code{character}, path to fid file
34
34
#'  (e.g. \sQuote{Pankreas_HB_L_061019_A10/0_a19/1/1SLin/fid})
35
35
#'
36
36
#' @return
45
45
.sampleName <- function(fidFile) {
46
46
  # regular expression for directory separator (on unix: /+, on windows \+)
47
47
  # sadly .Platform$file.sep == "/" on both
48
 
  fidFile <- chartr(old="\\", new="/", x=fidFile);
 
48
  fidFile <- chartr(old="\\", new="/", x=fidFile)
49
49
 
50
50
  # create array of directories (each element == one directory)
51
 
  dirs <- strsplit(x=fidFile, split="/")[[1]];
52
 
 
53
 
  numDirs <- length(dirs);
54
 
 
55
 
  sampleName <- NA;
 
51
  dirs <- strsplit(x=fidFile, split="/")[[1]]
 
52
 
 
53
  numDirs <- length(dirs)
 
54
 
 
55
  sampleName <- NA
56
56
 
57
57
  if (numDirs > 4) {
58
 
    sampleName <- dirs[numDirs-4];
 
58
    sampleName <- dirs[numDirs-4]
59
59
 
60
60
    # -, : or something like that causes errors in names()
61
61
    # TODO: use make.names in future releases?
62
62
    sampleName <- gsub(pattern="[[:punct:]]|[[:space:]]", replacement="_",
63
 
                       x=sampleName);
64
 
  } 
 
63
                       x=sampleName)
 
64
  }
65
65
 
66
 
  return(sampleName);
 
66
  return(sampleName)
67
67
}
68
68