@@ -11,22 +11,69 @@ test_chromatograms1 <- function() {
1111 checkIdentical(nrow(chromatogram(x , 136L )), 527L )
1212 checkIdentical(nrow(chromatogram(x , 137L )), 567L )
1313 checkIdentical(nrow(chromatogram(x , 138L )), 567L )
14+ close(x )
1415}
1516
1617test_chromatograms2 <- function () {
1718 f <- proteomics(full.names = TRUE ,
1819 pattern = " TMT_Erwinia_1uLSike_Top10HCD_isol2_45stepped_60min_01.mzML.gz" )
1920 x <- openMSfile(f , backend = " pwiz" )
20- checkIdentical(nChrom(x ), 1L )
21+ checkIdentical(nChrom(x ), 1L )
2122 checkIdentical(tic(x ), chromatogram(x , 1L ))
2223 checkIdentical(nrow(tic(x )), 7534L )
24+ close(x )
25+ }
26+
27+ test_chromatogramHeader_indexing <- function () {
28+ f <- proteomics(full.names = TRUE , pattern = " MRM" )
29+ x <- openMSfile(f , backend = " pwiz" )
30+ tic <- chromatogramHeader(x , 1 )
31+ tic1 <- chromatogramHeader(x , 1 : 1 )
32+ # next chromatogram after TIC (if we assume TIC is always at index 1)
33+ ch2 <- chromatogramHeader(x , 2 )
34+ checkEquals(colnames(ch2 ), c(" chromatogramId" , " chromatogramIndex" , " polarity" ,
35+ " precursorIsolationWindowTargetMZ" ,
36+ " precursorIsolationWindowLowerOffset" ,
37+ " precursorIsolationWindowUpperOffset" ,
38+ " precursorCollisionEnergy" ,
39+ " productIsolationWindowTargetMZ" ,
40+ " productIsolationWindowLowerOffset" ,
41+ " productIsolationWindowUpperOffset" ))
42+ checkEquals(tic $ chromatogramId , " TIC" )
43+ checkEquals(tic1 $ chromatogramId , " TIC" )
44+ checkTrue(! is.na(ch2 $ precursorIsolationWindowTargetMZ ))
45+ checkTrue(! is.na(ch2 $ productIsolationWindowTargetMZ ))
46+ checkEquals(nrow(ch2 ), 1 )
47+ # test index below lower bound should raise error
48+ tryCatch({
49+ chromatogramHeader(x , 0 )
50+ checkTrue(FALSE )
51+ }, error = function (e ) {
52+ checkTrue(grepl(" Index out of bound" , e $ message ))
53+ })
54+ # check last chromatogram in bounds
55+ ch138 <- chromatogramHeader(x , 138 )
56+ checkTrue(startsWith(ch138 $ chromatogramId , " - SRM SIC Q1=808.1 Q3=407.996" ))
57+ # test index above upper bound should raise error
58+ tryCatch({
59+ chromatogramHeader(x , 139 )
60+ checkTrue(FALSE )
61+ }, error = function (e ) {
62+ checkTrue(grepl(" Index out of bound" , e $ message ))
63+ })
64+
65+ chrom2 <- chromatogram(x , 2 )
66+ ch2SafeChromId <- make.names(ch2 $ chromatogramId )
67+ checkEquals(ch2SafeChromId , colnames(chrom2 )[2 ])
68+
69+ close(x )
2370}
2471
2572test_chromatogramHeader <- function () {
2673 library(mzR )
2774 library(RUnit )
2875 library(msdata )
29-
76+
3077 f <- proteomics(full.names = TRUE , pattern = " MRM" )
3178 x <- openMSfile(f )
3279
@@ -42,7 +89,7 @@ test_chromatogramHeader <- function() {
4289 " productIsolationWindowUpperOffset" ))
4390 checkEquals(ch $ chromatogramId [1 ], " TIC" )
4491 checkEquals(sum(is.na(ch $ precursorIsolationWindowTargetMZ )), 1 )
45- checkEquals(sum(is.na(ch $ productIsolationWindowTargetMZ )), 1 )
92+ checkEquals(sum(is.na(ch $ productIsolationWindowTargetMZ )), 1 )
4693 checkEquals(length(chrs ), nrow(ch ))
4794 close(x )
4895
0 commit comments