Skip to content

Commit 10975ef

Browse files
committed
Added chromatogramHeader test
1 parent 0368dbf commit 10975ef

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

R/methods-mzRpwiz.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ setMethod("chromatogramHeader", "mzRpwiz",
192192
} else {
193193
stopifnot(is.numeric(chrom))
194194
n <- nChrom(object)
195+
chrom <- as.integer(chrom)
195196
if (min(chrom) < 1 || max(chrom) > n)
196197
stop("Index out of bound [", 1, ":", n, "]")
197-
chrom <- chrom -1L
198+
chrom <- chrom - 1L
198199
res <- object@backend$getChromatogramHeaderInfo(chrom)
199200
}
200201
res$chromatogramId <- as.character(res$chromatogramId)

inst/unitTests/test_chromatograms.R

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,37 @@ test_chromatograms2 <- function() {
1717
f <- proteomics(full.names = TRUE,
1818
pattern = "TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.gz")
1919
x <- openMSfile(f, backend = "pwiz")
20-
checkIdentical(nChrom(x), 1L)
20+
checkIdentical(nChrom(x), 1L)
2121
checkIdentical(tic(x), chromatogram(x, 1L))
2222
checkIdentical(nrow(tic(x)), 7534L)
2323
}
2424

25+
test_individual_chromatogramHeader <- function() {
26+
f <- proteomics(full.names = TRUE, pattern = "MRM")
27+
x <- openMSfile(f, backend = "pwiz")
28+
tic <- chromatogramHeader(x, 1)
29+
tic1 <- chromatogramHeader(x, 1:1)
30+
ch <- chromatogramHeader(x, 2)
31+
checkEquals(colnames(ch), c("chromatogramId", "chromatogramIndex", "polarity",
32+
"precursorIsolationWindowTargetMZ",
33+
"precursorIsolationWindowLowerOffset",
34+
"precursorIsolationWindowUpperOffset",
35+
"precursorCollisionEnergy",
36+
"productIsolationWindowTargetMZ",
37+
"productIsolationWindowLowerOffset",
38+
"productIsolationWindowUpperOffset"))
39+
checkEquals(tic$chromatogramId, "TIC")
40+
checkEquals(sum(is.na(ch$precursorIsolationWindowTargetMZ)), 1)
41+
checkEquals(sum(is.na(ch$productIsolationWindowTargetMZ)), 1)
42+
checkEquals(nrow(ch), 1)
43+
close(x)
44+
}
45+
2546
test_chromatogramHeader <- function() {
2647
library(mzR)
2748
library(RUnit)
2849
library(msdata)
29-
50+
3051
f <- proteomics(full.names = TRUE, pattern = "MRM")
3152
x <- openMSfile(f)
3253

@@ -42,7 +63,7 @@ test_chromatogramHeader <- function() {
4263
"productIsolationWindowUpperOffset"))
4364
checkEquals(ch$chromatogramId[1], "TIC")
4465
checkEquals(sum(is.na(ch$precursorIsolationWindowTargetMZ)), 1)
45-
checkEquals(sum(is.na(ch$productIsolationWindowTargetMZ)), 1)
66+
checkEquals(sum(is.na(ch$productIsolationWindowTargetMZ)), 1)
4667
checkEquals(length(chrs), nrow(ch))
4768
close(x)
4869

0 commit comments

Comments
 (0)