diff --git a/.editorconfig b/.editorconfig index b52f2c44b..eef6f902f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ root = true charset = utf-8 end_of_line = lf trim_trailing_whitespace = true -insert_final_newline = false +insert_final_newline = true [*.R] indent_style = space @@ -18,4 +18,4 @@ indent_style = tab [.travis.yml] indent_style = space -indent_size = 2 +indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index 7da178a3a..43ebfe910 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -54,8 +54,8 @@ jobs: matrix: config: - { os: ubuntu-latest, r: 'devel', bioc: 'devel', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" } - - { os: macOS-latest, r: '4.4', bioc: 'devel'} - - { os: windows-latest, r: '4.4', bioc: 'devel'} + - { os: macOS-latest, r: '4.4', bioc: '3.20'} + - { os: windows-latest, r: '4.4', bioc: '3.20'} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} diff --git a/DESCRIPTION b/DESCRIPTION index 809562945..c49c7537a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: xcms -Version: 4.5.0 +Version: 4.5.1 Title: LC-MS and GC-MS Data Analysis Description: Framework for processing and visualization of chromatographically separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF, diff --git a/NEWS.md b/NEWS.md index 536bc58e5..c1eced596 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# xcms 4.5.1 + +## Changes in version 4.5.1 + +- Fix compile errors with R-4.5 + # xcms 4.3 ## Changes in version 4.3.4 diff --git a/src/binners.c b/src/binners.c index f97136310..58a6948d0 100644 --- a/src/binners.c +++ b/src/binners.c @@ -72,11 +72,11 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize, base_value = REAL(baseValue)[0]; if (from_idx < 0 || to_idx < 0) - error("'fromIdx' and 'toIdx' have to be >= 0!"); + Rf_error("'fromIdx' and 'toIdx' have to be >= 0!"); if (from_idx > to_idx) - error("'fromIdx' has to be smaller than 'toIdx'!"); + Rf_error("'fromIdx' has to be smaller than 'toIdx'!"); if (to_idx >= LENGTH(x)) - error("'toIdx' can not be larger than length(x)!"); + Rf_error("'toIdx' can not be larger than length(x)!"); /* Define from_x and to_x */ if (ISNA(REAL(fromX)[0])) { @@ -95,12 +95,12 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize, n_bin = (LENGTH(breaks) - 1); p_brks = REAL(breaks); if (n_bin < 1) - error("Not enough breaks defined!"); + Rf_error("Not enough breaks defined!"); } else if (INTEGER(nBins)[0] != NA_INTEGER) { /* Calculating breaks based on the number of bins. */ n_bin = asInteger(nBins); if (n_bin <= 0) - error("'nBins' must be larger 1!"); + Rf_error("'nBins' must be larger 1!"); PROTECT(brks = allocVector(REALSXP, n_bin + 1)); count_protect++; /* Calculate the breaks */ @@ -110,7 +110,7 @@ SEXP binYonX(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize, /* Calculating breaks based on bin size. */ bin_size = REAL(binSize)[0]; if (bin_size < 0) - error("'binSize' has to be > 0!"); + Rf_error("'binSize' has to be > 0!"); if (shift_by_half_bin_size > 0) { from_x = from_x - (bin_size / 2); to_x = to_x + (bin_size / 2); @@ -224,7 +224,7 @@ SEXP binYonX_multi(SEXP x, SEXP y, SEXP breaks, SEXP nBins, SEXP binSize, SEXP res, from_idx, to_idx, current_res; int n_subsets, *p_subset_from_idx, *p_subset_to_idx; if (LENGTH(subsetFromIdx) != LENGTH(subsetToIdx)) { - error("Arguments 'subsetFromIdx' and 'subsetToIdx' have to have the same length!"); + Rf_error("Arguments 'subsetFromIdx' and 'subsetToIdx' have to have the same length!"); } n_subsets = LENGTH(subsetFromIdx); p_subset_from_idx = INTEGER(subsetFromIdx); diff --git a/src/fastMatch.c b/src/fastMatch.c index 667583ecc..232e89208 100644 --- a/src/fastMatch.c +++ b/src/fastMatch.c @@ -29,7 +29,7 @@ SEXP fastMatch(SEXP x, SEXP y, SEXP xidx, SEXP yidx, SEXP xolength, SEXP tol) { struct idxStruct * pidxS = (struct idxStruct *) calloc(nx, sizeof(struct idxStruct)); if (pidxS == NULL) - error("fastMatch/calloc: memory could not be allocated ! (%lu bytes)\n", nx * sizeof(struct idxStruct) ); + Rf_error("fastMatch/calloc: memory could not be allocated ! (%lu bytes)\n", nx * sizeof(struct idxStruct) ); for (xi=0;xi < nx;xi++) pidxS[xi].from = ny+1; diff --git a/src/massifquant/nmath.h b/src/massifquant/nmath.h index 114232786..2d9d68637 100644 --- a/src/massifquant/nmath.h +++ b/src/massifquant/nmath.h @@ -46,11 +46,11 @@ double gamma_cody(double); #ifndef MATHLIB_STANDALONE #include -# define MATHLIB_ERROR(fmt,x) error(fmt,x); -# define MATHLIB_WARNING(fmt,x) warning(fmt,x) -# define MATHLIB_WARNING2(fmt,x,x2) warning(fmt,x,x2) -# define MATHLIB_WARNING3(fmt,x,x2,x3) warning(fmt,x,x2,x3) -# define MATHLIB_WARNING4(fmt,x,x2,x3,x4) warning(fmt,x,x2,x3,x4) +# define MATHLIB_ERROR(fmt,x) Rf_error(fmt,x); +# define MATHLIB_WARNING(fmt,x) Rf_warning(fmt,x) +# define MATHLIB_WARNING2(fmt,x,x2) Rf_warning(fmt,x,x2) +# define MATHLIB_WARNING3(fmt,x,x2,x3) Rf_warning(fmt,x,x2,x3) +# define MATHLIB_WARNING4(fmt,x,x2,x3,x4) Rf_warning(fmt,x,x2,x3,x4) #include #define ML_POSINF R_PosInf @@ -199,4 +199,4 @@ void attribute_hidden bratio(double a, double b, double x, double y, double *w, double *w1, int *ierr, int log_p); -#endif /* MATHLIB_PRIVATE_H */ +#endif /* MATHLIB_PRIVATE_H */ \ No newline at end of file diff --git a/src/massifquant/xcms_massifquant.cpp b/src/massifquant/xcms_massifquant.cpp index 086c40468..b43713756 100644 --- a/src/massifquant/xcms_massifquant.cpp +++ b/src/massifquant/xcms_massifquant.cpp @@ -59,7 +59,7 @@ extern "C" SEXP massifquant(SEXP mz, SEXP intensity, SEXP scanindex, } if ((scanrangeFrom < firstScan) || (scanrangeFrom > totalScanNums) || (scanrangeTo < firstScan) || (scanrangeTo > totalScanNums)) - error("Error in scanrange \n"); + Rf_error("Error in scanrange \n"); //show the progress please Rprintf("\n Detecting Kalman ROI's ... \n percent finished: "); @@ -112,17 +112,17 @@ extern "C" SEXP massifquant(SEXP mz, SEXP intensity, SEXP scanindex, Rprintf(" %d\n", 100); const char *names[N_NAMES] = {"mz", "mzmin", "mzmax", "scmin", "scmax", "length", "intensity"}; - PROTECT(list_names = allocVector(STRSXP, N_NAMES)); + PROTECT(list_names = Rf_allocVector(STRSXP, N_NAMES)); for(int j = 0; j < N_NAMES; j++) - SET_STRING_ELT(list_names, j, mkChar(names[j])); + SET_STRING_ELT(list_names, j, Rf_mkChar(names[j])); - PROTECT(peaklist = allocVector(VECSXP, busybody.getPicCounts())); + PROTECT(peaklist = Rf_allocVector(VECSXP, busybody.getPicCounts())); for (int i=0;i featInfo = busybody.iterOverFeatures(i, pscantime); //jo int scanLength = int(featInfo.at(5) - featInfo.at(4) + 1); - PROTECT(entrylist = allocVector(VECSXP, N_NAMES)); + PROTECT(entrylist = Rf_allocVector(VECSXP, N_NAMES)); //allow for new vars declared to be passed out PROTECT(vmz = NEW_NUMERIC(1)); @@ -153,7 +153,7 @@ extern "C" SEXP massifquant(SEXP mz, SEXP intensity, SEXP scanindex, SET_VECTOR_ELT(entrylist, 5, vlength); SET_VECTOR_ELT(entrylist, 6, vintensity); - setAttrib(entrylist, R_NamesSymbol, list_names); //attaching the vector names + Rf_setAttrib(entrylist, R_NamesSymbol, list_names); //attaching the vector names SET_VECTOR_ELT(peaklist, i, entrylist); UNPROTECT(N_NAMES + 1); //entrylist + values } diff --git a/src/mzROI.c b/src/mzROI.c index 19333b469..5474ccd79 100644 --- a/src/mzROI.c +++ b/src/mzROI.c @@ -76,7 +76,7 @@ struct mzROIStruct * checkmzROIBufSize(struct mzROIStruct *mzROI, const unsigned mzROI = (struct mzROIStruct *) realloc(mzROI, newLength * sizeof(struct mzROIStruct)); if (mzROI == NULL) - error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct) ); + Rf_error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct) ); mzLength->mzROITotal = newLength; } @@ -99,7 +99,7 @@ struct mzROIStruct * checkmzvalBufSize(struct mzROIStruct *mzval, const unsigned mzval = (struct mzROIStruct *) realloc(mzval, newLength * sizeof(struct mzROIStruct)); if (mzval == NULL) - error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct)); + Rf_error("findmzROI/realloc: buffer memory could not be allocated ! (%lu bytes)\n", newLength * sizeof(struct mzROIStruct)); mzLength->mzvalTotal = newLength; } @@ -202,7 +202,7 @@ struct mzROIStruct * insertpeak(const double fMass, const double fInten, if (ddiff <= ddev) { // match (smaller than defined ppm) -> extend this ROI - if ( (i > hpos) || (i hpos) || (i ctScan) { #ifdef DEBUG - error("Warning : entries > ctScan (is this centroid data ?) i: %d m: %3.4f %d entries, lastscan %d (ctScan=%d)\n",i,mzval[i].mz,mzval[i].length,lastscan,ctScan); + Rf_error("Warning : entries > ctScan (is this centroid data ?) i: %d m: %3.4f %d entries, lastscan %d (ctScan=%d)\n",i,mzval[i].mz,mzval[i].length,lastscan,ctScan); #endif (*scerr)++; } @@ -328,7 +328,7 @@ int i,p,del=0; p=0; struct mzROIStruct * tmp = (struct mzROIStruct *) calloc(mzLength->mzval - del, sizeof(struct mzROIStruct)); if (tmp == NULL) - error("findmzROI/cleanup: buffer memory could not be allocated ! (%lu bytes)\n", (mzLength->mzval - del) * sizeof(struct mzROIStruct)); + Rf_error("findmzROI/cleanup: buffer memory could not be allocated ! (%lu bytes)\n", (mzLength->mzval - del) * sizeof(struct mzROIStruct)); for (i=0; i < mzLength->mzval; i++) { if (mzval[i].deleteMe == FALSE) { tmp[p].mz = mzval[i].mz; @@ -379,7 +379,7 @@ struct scanBuf * getScan(int scan, double *pmz, double *pintensity, int *pscanin scanbuf->thisScan= (struct scanStruct *) calloc(N, sizeof(struct scanStruct)); // scanbuf->thisScan= (struct scanStruct *) malloc(N * sizeof(struct scanStruct)); if (scanbuf->thisScan == NULL) - error("findmzROI/getThisScan: Memory could not be allocated!\n"); + Rf_error("findmzROI/getThisScan: Memory could not be allocated!\n"); scanbuf->thisScanLength=N; @@ -411,7 +411,7 @@ struct scanBuf * getScan(int scan, double *pmz, double *pintensity, int *pscanin if (N > 0) { scanbuf->nextScan= (double *) calloc(N, sizeof(double)); if (scanbuf->nextScan == NULL) - error("findmzROI/getNextScan: Memory could not be allocated!\n"); + Rf_error("findmzROI/getNextScan: Memory could not be allocated!\n"); scanbuf->nextScanLength=N; for (idx=idx1;idx <= idx2; idx++) @@ -463,7 +463,7 @@ SEXP getEIC(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, SEXP scanrang scanrangeFrom = INTEGER(scanrange)[0]; scanrangeTo = INTEGER(scanrange)[1]; if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) || (scanrangeTo < firstScan) || (scanrangeTo > ilastScan)) - error("Error in scanrange \n"); + Rf_error("Error in scanrange \n"); char *names[2] = {"scan", "intensity"}; PROTECT(list_names = allocVector(STRSXP, 2)); for(i = 0; i < 2; i++) @@ -508,7 +508,7 @@ SEXP getMZ(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, SEXP scanrange scanrangeFrom = INTEGER(scanrange)[0]; scanrangeTo = INTEGER(scanrange)[1]; if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) || (scanrangeTo < firstScan) || (scanrangeTo > ilastScan)) - error("Error in scanrange \n"); + Rf_error("Error in scanrange \n"); buflength = scanrangeTo - scanrangeFrom +1; PROTECT(res = NEW_NUMERIC(buflength)); @@ -563,7 +563,7 @@ SEXP getWeightedMZ(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, scanrangeTo = INTEGER(scanrange)[1]; if ((scanrangeFrom < firstScan) || (scanrangeFrom > ilastScan) || (scanrangeTo < firstScan) || (scanrangeTo > ilastScan)) - error("Error in scanrange \n"); + Rf_error("Error in scanrange \n"); buflength = scanrangeTo - scanrangeFrom +1; PROTECT(res = NEW_NUMERIC(buflength)); @@ -626,11 +626,11 @@ SEXP findmzROI(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, struct mzROIStruct * mzROI = (struct mzROIStruct *) calloc(ROI_INIT_LENGTH, sizeof(struct mzROIStruct)); if (mzROI == NULL) - error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",ROI_INIT_LENGTH * sizeof(struct mzROIStruct) ); + Rf_error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",ROI_INIT_LENGTH * sizeof(struct mzROIStruct) ); struct mzROIStruct * mzval = (struct mzROIStruct *) calloc(MZVAL_INIT_LENGTH, sizeof(struct mzROIStruct)); if (mzval == NULL) - error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",MZVAL_INIT_LENGTH * sizeof(struct mzROIStruct) ); + Rf_error("findmzROI/calloc: buffer memory could not be allocated ! (%lu bytes)\n",MZVAL_INIT_LENGTH * sizeof(struct mzROIStruct) ); mzLength.mzvalTotal = MZVAL_INIT_LENGTH; mzLength.mzROITotal = ROI_INIT_LENGTH; @@ -678,7 +678,7 @@ SEXP findmzROI(SEXP mz, SEXP intensity, SEXP scanindex, SEXP mzrange, fInten = scanbuf->thisScan[p].intensity; if (fMass < lastMass) - error("m/z sort assumption violated ! (scan %d, p %d, current %2.4f (I=%2.2f), last %2.4f) \n",ctScan,p,fMass,fInten,lastMass); + Rf_error("m/z sort assumption violated ! (scan %d, p %d, current %2.4f (I=%2.2f), last %2.4f) \n",ctScan,p,fMass,fInten,lastMass); lastMass = fMass; if (fInten > inoise) diff --git a/src/xcms_obiwarp.cpp b/src/xcms_obiwarp.cpp index 998db09dd..86f557c9c 100644 --- a/src/xcms_obiwarp.cpp +++ b/src/xcms_obiwarp.cpp @@ -39,16 +39,16 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S double *pscantime2, *pmz2, *pintensity2; SEXP corrected; - PROTECT(valscantime = coerceVector(valscantime, INTSXP)); - mzrange = coerceVector(mzrange, INTSXP); + PROTECT(valscantime = Rf_coerceVector(valscantime, INTSXP)); + mzrange = Rf_coerceVector(mzrange, INTSXP); pvalscantime = INTEGER(valscantime)[0]; pmzrange = INTEGER(mzrange)[0]; pscantime = REAL(scantime); pmz = REAL(mz); pintensity = REAL(intensity); - PROTECT(valscantime2 = coerceVector(valscantime2, INTSXP)); - mzrange2 = coerceVector(mzrange2, INTSXP); + PROTECT(valscantime2 = Rf_coerceVector(valscantime2, INTSXP)); + mzrange2 = Rf_coerceVector(mzrange2, INTSXP); pvalscantime2 = INTEGER(valscantime2)[0]; pmzrange2 = INTEGER(mzrange2)[0]; pscantime2 = REAL(scantime2); @@ -120,8 +120,8 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S lmat2.tm_axis_vals(nOut, nOutF); lmat2.warp_tm(nOutF, mOutF); - PROTECT(corrected = allocVector(REALSXP, length(scantime2))); - for(int i=0; i < length(scantime2);i++){ + PROTECT(corrected = Rf_allocVector(REALSXP, Rf_length(scantime2))); + for(int i=0; i < Rf_length(scantime2);i++){ REAL(corrected)[i] = lmat2.tm()->back()[i]; } @@ -129,4 +129,4 @@ extern "C" SEXP R_set_from_xcms(SEXP valscantime, SEXP scantime, SEXP mzrange, S return corrected; -} +} \ No newline at end of file