Browse code

Replace Rcpp::Rcerr with Rf_warningcall (issue #164)

- Replace Rcpp::Rcerr with Rf_warningcall for most functions.
- Also replace Rprintf with Rf_warningcall if backend not initialized.

jotsetung authored on 17/05/2018 11:52:44
Showing 2 changed files

... ...
@@ -84,7 +84,7 @@ int RcppPwiz::getLastScan() const {
84 84
     SpectrumListPtr slp = msd->run.spectrumListPtr;
85 85
     return slp->size();
86 86
   }
87
-  Rprintf("Warning: pwiz not yet initialized.\n ");
87
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
88 88
   return -1;
89 89
 }
90 90
 
... ...
@@ -93,7 +93,7 @@ int RcppPwiz::getLastChrom() const {
93 93
     ChromatogramListPtr clp = msd->run.chromatogramListPtr;
94 94
     return clp->size();
95 95
   }
96
-  Rprintf("Warning: pwiz not yet initialized.\n ");
96
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
97 97
   return -1;
98 98
 }
99 99
 
... ...
@@ -160,7 +160,7 @@ Rcpp::List RcppPwiz::getInstrumentInfo ( )
160 160
         }
161 161
       return(instrumentInfo);
162 162
     }
163
-  Rprintf("Warning: pwiz not yet initialized.\n ");
163
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
164 164
   return instrumentInfo;
165 165
 }
166 166
 
... ...
@@ -306,7 +306,7 @@ Rcpp::DataFrame RcppPwiz::getScanHeaderInfo (Rcpp::IntegerVector whichScan)
306 306
       
307 307
       return header;
308 308
     }
309
-  Rprintf("Warning: pwiz not yet initialized.\n ");
309
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
310 310
   return Rcpp::DataFrame::create( );
311 311
 }
312 312
 
... ...
@@ -324,7 +324,7 @@ Rcpp::DataFrame RcppPwiz::getAllScanHeaderInfo ( )
324 324
         }
325 325
       return allScanHeaderInfo ;
326 326
     }
327
-  Rprintf("Warning: pwiz not yet initialized.\n ");
327
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
328 328
   return Rcpp::DataFrame::create( );
329 329
 }
330 330
 
... ...
@@ -362,7 +362,7 @@ Rcpp::List RcppPwiz::getPeakList ( int whichScan )
362 362
 				Rcpp::_["peaks"]  = peaks
363 363
 				) ;
364 364
     }
365
-  Rprintf("Warning: pwiz not yet initialized.\n ");
365
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
366 366
   return Rcpp::List::create( );
367 367
 }
368 368
 
... ...
@@ -756,10 +756,10 @@ Rcpp::DataFrame RcppPwiz::getChromatogramsInfo( int whichChrom )
756 756
   if (msd != NULL) {
757 757
     ChromatogramListPtr clp = msd->run.chromatogramListPtr;
758 758
     if (clp.get() == 0) {
759
-      Rcpp::Rcerr << "The direct support for chromatogram info is only available in mzML format." << std::endl;
759
+      Rf_warningcall(R_NilValue, "The direct support for chromatogram info is only available in mzML format.");
760 760
       return Rcpp::DataFrame::create();
761 761
     } else if (clp->size() == 0) {
762
-      Rcpp::Rcerr << "No available chromatogram info." << std::endl;
762
+      Rf_warningcall(R_NilValue, "No available chromatogram info.");
763 763
       return Rcpp::DataFrame::create();
764 764
     } else if ( (whichChrom < 0) || (whichChrom > clp->size()) ) {
765 765
       Rprintf("Index whichChrom out of bounds [0 ... %d].\n", (clp->size())-1);
... ...
@@ -783,7 +783,7 @@ Rcpp::DataFrame RcppPwiz::getChromatogramsInfo( int whichChrom )
783 783
     }
784 784
     return(chromatogramsInfo);
785 785
   }
786
-  Rprintf("Warning: pwiz not yet initialized.\n ");
786
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
787 787
   return Rcpp::DataFrame::create( );
788 788
 }
789 789
 
... ...
@@ -794,10 +794,10 @@ Rcpp::DataFrame RcppPwiz::getChromatogramHeaderInfo (Rcpp::IntegerVector whichCh
794 794
     CVID nativeIdFormat_ = id::getDefaultNativeIDFormat(*msd); // Ask CHRIS if I'm correctly dereferencing this...
795 795
     ChromatogramListPtr clp = msd->run.chromatogramListPtr;
796 796
     if (clp.get() == 0) {
797
-      Rcpp::Rcerr << "The direct support for chromatogram info is only available in mzML format." << std::endl;
797
+      Rf_warningcall(R_NilValue, "The direct support for chromatogram info is only available in mzML format.");
798 798
       return Rcpp::DataFrame::create();
799 799
     } else if (clp->size() == 0) {
800
-      Rcpp::Rcerr << "No available chromatogram info." << std::endl;
800
+      Rf_warningcall(R_NilValue, "No available chromatogram info.");
801 801
       return Rcpp::DataFrame::create();
802 802
     }
803 803
 
... ...
@@ -821,8 +821,8 @@ Rcpp::DataFrame RcppPwiz::getChromatogramHeaderInfo (Rcpp::IntegerVector whichCh
821 821
     for (int i = 0; i < N_chrom; i++) {
822 822
       int current_chrom = whichChrom[i];
823 823
       if (current_chrom < 0 || current_chrom > N) {
824
+	Rf_warningcall(R_NilValue, "Provided index out of bounds.");
824 825
 	Rcpp::Rcerr << "Provided index out of bounds" << std::endl;
825
-	return Rcpp::DataFrame::create();
826 826
       }
827 827
       ChromatogramPtr ch = clp->chromatogram(current_chrom - 1, false);
828 828
       chromatogramId[i] = ch->id;
... ...
@@ -877,7 +877,7 @@ Rcpp::DataFrame RcppPwiz::getChromatogramHeaderInfo (Rcpp::IntegerVector whichCh
877 877
     chromHeader.attr("names") = names;
878 878
     return chromHeader;
879 879
   }
880
-  Rprintf("Warning: pwiz not yet initialized.\n ");
880
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
881 881
   return Rcpp::DataFrame::create( );
882 882
 }
883 883
 
... ...
@@ -885,14 +885,14 @@ Rcpp::DataFrame RcppPwiz::getAllChromatogramHeaderInfo ( ) {
885 885
   if (msd != NULL) {
886 886
     ChromatogramListPtr clp = msd->run.chromatogramListPtr;
887 887
     if (clp.get() == 0) {
888
-      Rcpp::Rcerr << "The direct support for chromatogram info is only available in mzML format." << std::endl;
888
+      Rf_warningcall(R_NilValue, "The direct support for chromatogram info is only available in mzML format.");
889 889
       return Rcpp::DataFrame::create();
890 890
     }
891 891
     int N = clp->size();
892 892
     if (N > 0) {
893 893
       return getChromatogramHeaderInfo(Rcpp::seq(1, N));
894 894
     } else {
895
-      Rprintf("Warning: pwiz not yet initialized.\n ");
895
+      Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
896 896
     }
897 897
   }
898 898
   return Rcpp::DataFrame::create( );
... ...
@@ -921,7 +921,7 @@ Rcpp::NumericMatrix RcppPwiz::get3DMap ( std::vector<int> scanNumbers, double wh
921 921
         }
922 922
 
923 923
       int j=0;
924
-      Rprintf("%d\n",1);
924
+      //Rprintf("%d\n",1);
925 925
       for (int i = 0; i < scanNumbers.size(); i++)
926 926
         {
927 927
 	  SpectrumPtr s = slp->spectrum(scanNumbers[i] - 1, true);
... ...
@@ -945,7 +945,7 @@ Rcpp::NumericMatrix RcppPwiz::get3DMap ( std::vector<int> scanNumbers, double wh
945 945
       return(map3d);
946 946
     }
947 947
 
948
-  Rprintf("Warning: pwiz not yet initialized.\n ");
948
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
949 949
   return Rcpp::NumericMatrix(0,0);
950 950
 }
951 951
 
... ...
@@ -953,6 +953,6 @@ string RcppPwiz::getRunStartTimeStamp() {
953 953
   if (msd != NULL) {
954 954
     return msd->run.startTimeStamp;
955 955
   }
956
-  Rprintf("Warning: pwiz not yet initialized.\n ");
956
+  Rf_warningcall(R_NilValue, "pwiz not yet initialized.");
957 957
   return "";
958 958
 }
... ...
@@ -55,7 +55,7 @@ Rcpp::StringVector RcppRamp::getFilename (  )
55 55
     {
56 56
         return filename;
57 57
     }
58
-    Rprintf("Warning: Ramp not yet initialized.\n ");
58
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
59 59
     return filename;
60 60
 }
61 61
 
... ...
@@ -86,7 +86,7 @@ Rcpp::List RcppRamp::getRunInfo (  )
86 86
         }
87 87
         return runInfo;
88 88
     }
89
-    Rprintf("Warning: Ramp not yet initialized.\n");
89
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
90 90
     return runInfo;
91 91
 }
92 92
 
... ...
@@ -130,7 +130,7 @@ Rcpp::List RcppRamp::getInstrumentInfo ( )
130 130
         }
131 131
         return(instrumentInfo);
132 132
     }
133
-    Rprintf("Warning: Ramp not yet initialized.\n ");
133
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
134 134
     return instrumentInfo;
135 135
 }
136 136
 
... ...
@@ -200,7 +200,7 @@ Rcpp::List RcppRamp::getScanHeaderInfo ( int whichScan  )
200 200
 
201 201
         return  header;
202 202
     }
203
-    Rprintf("Warning: Ramp not yet initialized.\n ");
203
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
204 204
     return Rcpp::List::create( );
205 205
 }
206 206
 
... ...
@@ -322,7 +322,7 @@ Rcpp::DataFrame RcppRamp::getAllScanHeaderInfo ( )
322 322
         }
323 323
         return(allScanHeaderInfo);
324 324
     }
325
-    Rprintf("Warning: Ramp not yet initialized.\n ");
325
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
326 326
     return Rcpp::DataFrame::create( );
327 327
 }
328 328
 
... ...
@@ -361,7 +361,7 @@ Rcpp::List RcppRamp::getPeakList ( int whichScan )
361 361
                    Rcpp::_["peaks"]  = peaks
362 362
                ) ;
363 363
     }
364
-    Rprintf("Warning: Ramp not yet initialized.\n ");
364
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
365 365
     return Rcpp::List::create( );
366 366
 }
367 367
 
... ...
@@ -384,7 +384,7 @@ Rcpp::NumericMatrix RcppRamp::get3DMap ( std::vector<int> scanNumbers, double wh
384 384
         }
385 385
         // map3d = 0.0;
386 386
         int j=0;
387
-        Rprintf("%d\n",1);
387
+        //Rprintf("%d\n",1);
388 388
         for (int i = 0; i < scanNumbers.size(); i++)
389 389
         {
390 390
             rampPeakList *pl = ramp->getPeakList( scanNumbers[i] );
... ...
@@ -415,7 +415,7 @@ Rcpp::NumericMatrix RcppRamp::get3DMap ( std::vector<int> scanNumbers, double wh
415 415
         }
416 416
         return(map3d);
417 417
     }
418
-    Rprintf("Warning: Ramp not yet initialized.\n ");
418
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
419 419
     return Rcpp::NumericMatrix(0,0);
420 420
 }
421 421
 
... ...
@@ -425,7 +425,7 @@ int RcppRamp::getLastScan() const
425 425
     {
426 426
         return ramp->getLastScan();
427 427
     }
428
-    Rprintf("Warning: Ramp not yet initialized.\n ");
428
+    Rf_warningcall(R_NilValue, "Ramp not yet initialized.");
429 429
     return -1;
430 430
 }
431 431