Mercurial > repos > marie-tremblay-metatoul > nmr_preprocessing
annotate ReadFids_script.R @ 6:6e837e9352a2 draft default tip
"planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 62fed9acaee7410de763b756cfa7de48ee258929"
author | workflow4metabolomics |
---|---|
date | Wed, 13 May 2020 03:52:09 -0400 |
parents | 5e64657b4fe5 |
children |
rev | line source |
---|---|
2
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
1 ################################################################################################ |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
2 # |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
3 # Read FIDs in Bruker format |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
4 # |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
5 # |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
6 ################################################################################################ |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
7 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
8 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
9 # vec2mat ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
10 vec2mat <- function(vec) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
11 return(matrix(vec, nrow = 1, dimnames = list(c(1), names(vec)))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
12 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
13 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
14 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
15 # ReadFid ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
16 ReadFid <- function(path) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
17 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
18 # Read 1D FID using Bruker XWinNMR and TopSpin format. It is inspired of the |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
19 # matNMR matlab library which deals with 2D FID and also other formats |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
20 # Read also the parameters in the acqus file |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
21 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
22 paramFile <- file.path(path, "acqus") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
23 # BYTEORDA: 0 -> Little Endian 1 -> Big Endian |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
24 params <- readParams(paramFile, c("TD", "BYTORDA", "DIGMOD", "DECIM", "DSPFVS", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
25 "SW_h", "SW", "O1")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
26 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
27 if (params[["DSPFVS"]] >= 20) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
28 # The group delay first order phase correction is given directly from version 20 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
29 grpdly <- readParams(paramFile, c("GRPDLY")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
30 params[["GRPDLY"]] <- grpdly[["GRPDLY"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
31 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
32 TD <- params[["TD"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
33 endianness <- if (params$BYTORDA) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
34 "big" else "little" |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
35 if (TD%%2 != 0) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
36 stop(paste("Only even numbers are allowed for size in TD because it is complex |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
37 data with the real and imaginary part for each element.", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
38 "The TD value is in the", paramFile, "file")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
39 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
40 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
41 # Interpret params Dwell Time, time between 2 data points in the FID |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
42 params[["DT"]] <- 1/(2 * params[["SW_h"]]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
43 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
44 # Read fid |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
45 fidFile <- file.path(path, "fid") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
46 fidOnDisk <- readBin(fidFile, what = "int", n = TD, size = 4L, endian = endianness) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
47 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
48 # Real size that is on disk (it should be equal to TD2, except for TopSpin/Bruker |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
49 # (which is our case) according to matNMR as just discussed |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
50 TDOnDisk <- length(fidOnDisk) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
51 if (TDOnDisk < TD) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
52 warning("Size is smaller than expected, the rest is filled with zero so the size is the same for every fid") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
53 fidGoodSize <- sapply(vector("list", length = TD), function(x) 0) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
54 fidGoodSize[1:TDOnDisk] <- fidOnDisk |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
55 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
56 } else if (TDOnDisk > TD) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
57 warning("Size is bigger than expected, the rest ignored so the size is the same for every fid") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
58 fidGoodSize <- fidOnDisk(1:TD) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
59 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
60 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
61 fidGoodSize <- fidOnDisk |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
62 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
63 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
64 fidRePart <- fidGoodSize[seq(from = 1, to = TD, by = 2)] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
65 fidImPart <- fidGoodSize[seq(from = 2, to = TD, by = 2)] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
66 fid <- complex(real = fidRePart, imaginary = fidImPart) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
67 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
68 return(list(fid = fid, params = params)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
69 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
70 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
71 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
72 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
73 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
74 # getDirsContainingFid ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
75 getDirsContainingFid <- function(path) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
76 subdirs <- dir(path, full.names = TRUE) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
77 if (length(subdirs) > 0) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
78 cond <- sapply(subdirs, function(x) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
79 content <- dir(x) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
80 # subdirs must contain fid, acqu and acqus files |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
81 return("fid" %in% content && "acqu" %in% content && "acqus" %in% content) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
82 }) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
83 subdirs <- subdirs[cond] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
84 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
85 return(subdirs) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
86 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
87 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
88 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
89 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
90 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
91 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
92 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
93 # beginTreatment ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
94 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
95 beginTreatment <- function(name, Signal_data = NULL, Signal_info = NULL, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
96 force.real = FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
97 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
98 cat("Begin", name, "\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
99 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
100 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
101 # Formatting the Signal_data and Signal_info ----------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
102 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
103 vec <- is.vector(Signal_data) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
104 if (vec) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
105 Signal_data <- vec2mat(Signal_data) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
106 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
107 if (is.vector(Signal_info)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
108 Signal_info <- vec2mat(Signal_info) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
109 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
110 if (!is.null(Signal_data)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
111 if (!is.matrix(Signal_data)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
112 stop("Signal_data is not a matrix.") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
113 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
114 if (!is.complex(Signal_data) && !is.numeric(Signal_data)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
115 stop("Signal_data contains non-numerical values.") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
116 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
117 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
118 if (!is.null(Signal_info) && !is.matrix(Signal_info)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
119 stop("Signal_info is not a matrix.") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
120 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
121 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
122 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
123 Original_data <- Signal_data |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
124 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
125 # Extract the real part of the spectrum --------------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
126 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
127 if (force.real) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
128 if (is.complex(Signal_data)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
129 Signal_data <- Re(Signal_data) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
130 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
131 # The signal is numeric Im(Signal_data) is zero anyway so let's avoid |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
132 # using complex(real=...,imaginary=0) which would give a complex signal |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
133 # in endTreatment() |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
134 force.real <- FALSE |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
135 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
136 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
137 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
138 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
139 # Return the formatted data and metadata entries -------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
140 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
141 return(list(start = proc.time(), vec = vec, force.real = force.real, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
142 Original_data = Original_data, Signal_data = Signal_data, Signal_info = Signal_info)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
143 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
144 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
145 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
146 # endTreatment ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
147 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
148 endTreatment <- function(name, begin_info, Signal_data) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
149 end_time = proc.time() # record it as soon as possible |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
150 start_time = begin_info[["start"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
151 delta_time = end_time - start_time |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
152 delta = delta_time[] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
153 cat("End", name, "\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
154 cat("It lasted", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
155 round(delta["user.self"], 3), "s user time,", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
156 round(delta["sys.self"] , 3), "s system time and", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
157 round(delta["elapsed"] , 3), "s elapsed time.\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
158 if (begin_info[["force.real"]]) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
159 # The imaginary part is left untouched |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
160 i <- complex(real=0, imaginary=1) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
161 Signal_data = Signal_data + i * Im(begin_info[["Original_data"]]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
162 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
163 if (begin_info[["vec"]]) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
164 Signal_data = Signal_data[1,] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
165 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
166 return(Signal_data) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
167 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
168 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
169 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
170 # checkArg ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
171 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
172 checkArg <- function(arg, checks, can.be.null=FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
173 check.list <- list(bool=c(is.logical, "a boolean"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
174 int =c(function(x){x%%1==0}, "an integer"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
175 num =c(is.numeric, "a numeric"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
176 str =c(is.character, "a string"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
177 pos =c(function(x){x>0}, "positive"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
178 pos0=c(function(x){x>=0}, "positive or zero"), |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
179 l1 =c(function(x){length(x)==1}, "of length 1") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
180 ) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
181 if (is.null(arg)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
182 if (!can.be.null) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
183 stop(deparse(substitute(arg)), " is null.") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
184 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
185 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
186 if (is.matrix(arg)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
187 stop(deparse(substitute(arg)), " is not scalar.") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
188 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
189 for (c in checks) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
190 if (!check.list[[c]][[1]](arg)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
191 stop(deparse(substitute(arg)), " is not ", check.list[[c]][[2]], ".") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
192 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
193 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
194 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
195 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
196 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
197 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
198 # getArg ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
199 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
200 getArg <- function(arg, info, argname, can.be.absent=FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
201 if (is.null(arg)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
202 start <- paste("impossible to get argument", argname, "it was not given directly and"); |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
203 if (!is.matrix(info)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
204 stop(paste(start, "the info matrix was not given")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
205 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
206 if (!(argname %in% colnames(info))) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
207 if (can.be.absent) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
208 return(NULL) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
209 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
210 stop(paste(start, "is not in the info matrix")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
211 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
212 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
213 if (nrow(info) < 1) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
214 stop(paste(start, "the info matrix has no row")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
215 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
216 arg <- info[1,argname] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
217 if (is.na(arg)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
218 stop(paste(start, "it is NA in the info matrix")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
219 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
220 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
221 return(arg) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
222 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
223 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
224 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
225 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
226 # getTitle ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
227 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
228 # Get the name of the signal from the title file or fromt the name of the subdirectory |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
229 # Get the name of the signal from the title file or fromt the name of the subdirectory |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
230 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
231 getTitle <- function(path, l, subdirs) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
232 title <- NULL |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
233 title_file <- file.path(file.path(file.path(path, "pdata"), "1"), "title") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
234 if (file.exists(title_file)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
235 lines <- readLines(title_file, warn = FALSE) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
236 if (length(lines) >= 1) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
237 first_line <- gsub("^\\s+|\\s+$", "", lines[l]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
238 if (nchar(first_line) >= 1) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
239 title <- first_line |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
240 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
241 warning(paste("The", l ,"line of the title file is blank for directory ", |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
242 path, "and the (sub)dirs names are used instead")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
243 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
244 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
245 warning(paste("The title file is empty for directory ", path, "and the (sub)dirs names are used instead")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
246 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
247 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
248 warning(paste("Title file doesn't exists for directory ", path, "\n the (sub)dirs names are used instead")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
249 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
250 if (is.null(title)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
251 if(subdirs) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
252 separator <- .Platform$file.sep |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
253 path_elem <- strsplit(path,separator)[[1]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
254 title <- paste(path_elem[length(path_elem)-1], path_elem[length(path_elem)], sep = "_") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
255 } else{title <- basename(path)} |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
256 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
257 return(title) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
258 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
259 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
260 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
261 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
262 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
263 # readParams ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
264 # Read parameter values for Fid_info in the ReadFids function |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
265 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
266 readParams <- function(file, paramsName) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
267 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
268 isDigit <- function(c) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
269 return(suppressWarnings(!is.na(as.numeric(c)))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
270 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
271 lines <- readLines(file) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
272 params <- sapply(paramsName, function(x) NULL) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
273 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
274 for (paramName in paramsName) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
275 # Find the line with the parameter I add a '$' '=' in the pattern so that for |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
276 # example 'TD0' is not found where I look for 'TD' and LOCSW and WBSW when I look |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
277 # for 'SW' |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
278 pattern <- paste("\\$", paramName, "=", sep = "") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
279 occurences <- grep(pattern, lines) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
280 if (length(occurences) == 0L) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
281 stop(paste(file, "has no field", pattern)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
282 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
283 if (length(occurences) > 1L) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
284 warning(paste(file, "has more that one field", pattern, " I take the first one")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
285 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
286 line <- lines[occurences[1]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
287 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
288 # Cut beginning and end of the line '##$TD= 65536' -> '65536' |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
289 igual = as.numeric(regexpr("=", line)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
290 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
291 first <- igual |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
292 while (first <= nchar(line) & !isDigit(substr(line, first, first))) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
293 first <- first + 1 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
294 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
295 last <- nchar(line) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
296 while (last > 0 & !isDigit(substr(line, last, last))) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
297 last <- last - 1 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
298 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
299 params[paramName] <- as.numeric(substr(line, first, last)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
300 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
301 return(params) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
302 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
303 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
304 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
305 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
306 # ReadFids ============================================================================== |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
307 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
308 ReadFids <- function(path, l = 1, subdirs = FALSE, dirs.names = FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
309 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
310 # Data initialisation and checks ---------------------------------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
311 begin_info <- beginTreatment("ReadFids") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
312 checkArg(path, c("str")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
313 checkArg(l, c("pos")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
314 if (file.exists(path) == FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
315 stop(paste("Invalid path:", path)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
316 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
317 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
318 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
319 # Extract the FIDs and their info ---------------------------------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
320 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
321 if (subdirs == FALSE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
322 fidDirs <- getDirsContainingFid(path) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
323 n <- length(fidDirs) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
324 if (n == 0L) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
325 stop(paste("No valid fid in", path)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
326 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
327 if (dirs.names) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
328 separator <- .Platform$file.sep |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
329 path_elem <- strsplit(fidDirs,separator) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
330 fidNames <- sapply(path_elem, function(x) x[[length(path_elem[[1]])]]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
331 }else {fidNames <- sapply(X = fidDirs, FUN = getTitle, l = l, subdirs = subdirs, USE.NAMES = F)} |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
332 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
333 for (i in 1:n) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
334 fidList <- ReadFid(fidDirs[i]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
335 fid <- fidList[["fid"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
336 info <- fidList[["params"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
337 m <- length(fid) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
338 if (i == 1) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
339 Fid_data <- matrix(nrow = n, ncol = m, dimnames = list(fidNames, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
340 info[["DT"]] * (0:(m - 1)))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
341 Fid_info <- matrix(nrow = n, ncol = length(info), dimnames = list(fidNames, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
342 names(info))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
343 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
344 Fid_data[i, ] <- fid |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
345 Fid_info[i, ] <- unlist(info) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
346 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
347 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
348 } else { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
349 maindirs <- dir(path, full.names = TRUE) # subdirectories |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
350 Fid_data <- numeric() |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
351 Fid_info <- numeric() |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
352 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
353 fidDirs <- c() |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
354 for (j in maindirs) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
355 fd <- getDirsContainingFid(j) # recoved FIDs from subdirectories |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
356 n <- length(fd) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
357 if (n > 0L) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
358 fidDirs <- c(fidDirs, fd) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
359 } else {warning(paste("No valid fid in",j ))} |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
360 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
361 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
362 if (dirs.names==TRUE) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
363 if (length(fidDirs)!= length(dir(path))) { # at least one subdir contains more than 1 FID |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
364 separator <- .Platform$file.sep |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
365 path_elem <- strsplit(fidDirs,separator) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
366 fidNames <- sapply(path_elem, function(x) paste(x[[length(path_elem[[1]])-1]], |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
367 x[[length(path_elem[[1]])]], sep = "_")) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
368 }else {fidNames <- dir(path)} |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
369 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
370 } else {fidNames <- sapply(X = fidDirs, FUN = getTitle, l = l, subdirs = subdirs, USE.NAMES = F)} |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
371 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
372 for (i in 1:length(fidNames)) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
373 fidList <- ReadFid(fidDirs[i]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
374 fid <- fidList[["fid"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
375 info <- fidList[["params"]] |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
376 m <- length(fid) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
377 if (i == 1) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
378 Fid_data <- matrix(nrow = length(fidNames), ncol = m, dimnames = list(fidNames, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
379 info[["DT"]] * (0:(m - 1)))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
380 Fid_info <- matrix(nrow = length(fidNames), ncol = length(info), dimnames = list(fidNames, |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
381 names(info))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
382 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
383 Fid_data[i, ] <- fid |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
384 Fid_info[i, ] <- unlist(info) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
385 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
386 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
387 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
388 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
389 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
390 # Check for non-unique IDs ---------------------------------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
391 NonnuniqueIds <- sum(duplicated(row.names(Fid_data))) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
392 cat("dim Fid_data: ", dim(Fid_data), "\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
393 cat("IDs: ", rownames(Fid_data), "\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
394 cat("non-unique IDs?", NonnuniqueIds, "\n") |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
395 if (NonnuniqueIds > 0) { |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
396 warning("There are duplicated IDs: ", Fid_data[duplicated(Fid_data)]) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
397 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
398 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
399 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
400 # Return the results ---------------------------------------------- |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
401 return(list(Fid_data = endTreatment("ReadFids", begin_info, Fid_data), Fid_info = Fid_info)) |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
402 |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
403 } |
5e64657b4fe5
planemo upload for repository https://github.com/workflow4metabolomics/nmr_preprocessing commit 22ca8782d7c4c0211e13c95b425d4f29f53f995e
lecorguille
parents:
diff
changeset
|
404 |