Skip to content

Commit

Permalink
USE_NO_REMAP
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengxwen committed Sep 29, 2024
1 parent 5058e3a commit 4e1f776
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 135 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: SeqArray
Type: Package
Title: Data Management of Large-Scale Whole-Genome Sequence Variant Calls
Version: 1.45.4
Date: 2024-09-21
Version: 1.45.5
Date: 2024-09-29
Depends: R (>= 3.5.0), gdsfmt (>= 1.31.1)
Imports: methods, parallel, IRanges, GenomicRanges, GenomeInfoDb, Biostrings,
S4Vectors
Expand Down
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ UTILITIES
o `seqGetData()` return NULL, if 'var.name=character()'


CHANGES IN VERSION 1.44.3
-------------------------

UTILITIES

o update the C codes according to '_R_USE_STRICT_R_HEADERS_=true' &
'_R_CXX_USE_NO_REMAP_=true'


CHANGES IN VERSION 1.44.2
-------------------------

Expand Down
6 changes: 3 additions & 3 deletions src/ConvGDS2VCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ inline static void ExportHead(SEXP X)
inline static void ExportInfoFormat(SEXP X, size_t info_st)
{
// variable list
SEXP VarNames = getAttrib(X, R_NamesSymbol);
SEXP VarNames = Rf_getAttrib(X, R_NamesSymbol);

//==== INFO ====//

Expand Down Expand Up @@ -528,7 +528,7 @@ inline static void ExportInfoFormat(SEXP X, size_t info_st)
{
// name, "fmt.*"
SEXP D = VECTOR_ELT(X, i + cnt_info + info_st);
if (!isNull(D))
if (!Rf_isNull(D))
{
if (i > 0 || info_st > 6)
*pLine++ = ':';
Expand Down Expand Up @@ -569,7 +569,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_Quote(SEXP text, SEXP dQuote)
tmp.push_back('\"');
}
}
SET_STRING_ELT(ans, i, mkChar(tmp.c_str()));
SET_STRING_ELT(ans, i, Rf_mkChar(tmp.c_str()));
}

UNPROTECT(2);
Expand Down
6 changes: 3 additions & 3 deletions src/ConvToGDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// ConvToGDS.cpp: format conversion
//
// Copyright (C) 2015-2018 Xiuwen Zheng
// Copyright (C) 2015-2024 Xiuwen Zheng
//
// This file is part of SeqArray.
//
Expand Down Expand Up @@ -87,7 +87,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_ConvBED2GDS(SEXP GenoNode, SEXP Num, SEXP File,
// 'readBin(File, raw(), 3)'
SEXP R_Read_Call = PROTECT(
LCONS(ReadBinFun, LCONS(File,
LCONS(NEW_RAW(0), LCONS(ScalarInteger(nPack), R_NilValue)))));
LCONS(NEW_RAW(0), LCONS(Rf_ScalarInteger(nPack), R_NilValue)))));

vector<C_UInt8> dstgeno(nGeno);
static const C_UInt8 cvt1[4] = { 1, 3, 1, 0 };
Expand All @@ -99,7 +99,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_ConvBED2GDS(SEXP GenoNode, SEXP Num, SEXP File,
for (int i=0; i < n; i++)
{
// read genotypes
SEXP val = eval(R_Read_Call, Rho);
SEXP val = Rf_eval(R_Read_Call, Rho);
unsigned char *srcgeno = (unsigned char *)RAW(val);

// unpacked
Expand Down
12 changes: 6 additions & 6 deletions src/ConvVCF2GDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_NumLines(SEXP File, SEXP SkipHead,
}

Done_VCF_Buffer();
return ScalarReal(n);
return Rf_ScalarReal(n);
}


Expand All @@ -1109,9 +1109,9 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_Split(SEXP start, SEXP count, SEXP pnum,
SEXP multiple)
{
int num = Rf_asInteger(pnum);
if (num <= 0) error("'pnum' should be > 0.");
if (num <= 0) Rf_error("'pnum' should be > 0.");
int multi = Rf_asInteger(multiple);
if (multi < 0) error("'multiple' should be > 0.");
if (multi < 0) Rf_error("'multiple' should be > 0.");
if (multi == 0) multi = 1;
SEXP ans = PROTECT(NEW_LIST(2));
SEXP start_array = PROTECT(NEW_NUMERIC(num));
Expand Down Expand Up @@ -1683,7 +1683,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_Parse(SEXP vcf_fn, SEXP header,
if (it == format_missing.end())
{
format_missing.insert(cell);
warning("Unknown FORMAT ID '%s' is ignored (it should be defined in the meta-information lines).",
Rf_warning("Unknown FORMAT ID '%s' is ignored (it should be defined in the meta-information lines).",
cell.c_str());
}
} else {
Expand Down Expand Up @@ -1898,7 +1898,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_Parse(SEXP vcf_fn, SEXP header,
// set returned value: levels(filter)
PROTECT(rv_ans = NEW_CHARACTER(filter_list.size()));
for (int i=0; i < (int)filter_list.size(); i++)
SET_STRING_ELT(rv_ans, i, mkChar(filter_list[i].c_str()));
SET_STRING_ELT(rv_ans, i, Rf_mkChar(filter_list[i].c_str()));
nProtected ++;

REAL(line_cnt)[0] = variant_index;
Expand Down Expand Up @@ -1930,7 +1930,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_VCF_Parse(SEXP vcf_fn, SEXP header,
GDS_SetError(buf);
has_error = true;
});
if (has_error) error("%s", GDS_GetError());
if (has_error) Rf_error("%s", GDS_GetError());

// output
return rv_ans;
Expand Down
6 changes: 3 additions & 3 deletions src/FileMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FileMerge.cpp: GDS file merging
//
// Copyright (C) 2016-2020 Xiuwen Zheng
// Copyright (C) 2016-2024 Xiuwen Zheng
//
// This file is part of SeqArray.
//
Expand Down Expand Up @@ -184,7 +184,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_MergeGeno(SEXP num, SEXP varidx, SEXP files,
if ((0 <= v) && (v < nAllele))
*p = map[v];
else if (v != NA_INTEGER)
warning("Genotype in File(%d), out of range.", j+1);
Rf_warning("Genotype in File(%d), out of range.", j+1);
}
} else
vec_int32_set(pGeno, size, NA_INTEGER);
Expand Down Expand Up @@ -349,7 +349,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_MergeInfo(SEXP num, SEXP varidx, SEXP files,
if (info_idx)
GDS_Array_AppendData(info_idx, 1, &ZERO, svInt32);
else
GDS_R_Append(info_var, ScalarInteger(NA_INTEGER));
GDS_R_Append(info_var, Rf_ScalarInteger(NA_INTEGER));
}
}

Expand Down
58 changes: 29 additions & 29 deletions src/GetData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static SEXP get_chrom(CFileInfo &File, TVarMap &Var, void *param)
TSelection &Sel = File.Selection();
C_BOOL *s = Sel.pVariant + Sel.varStart;
size_t p = 0, i = Sel.varStart;
SEXP lastR = mkChar("");
SEXP lastR = Rf_mkChar("");
string lastS;
for (; n > 0; i++)
{
Expand All @@ -141,7 +141,7 @@ static SEXP get_chrom(CFileInfo &File, TVarMap &Var, void *param)
if (ss != lastS)
{
lastS = ss;
lastR = mkChar(ss.c_str());
lastR = Rf_mkChar(ss.c_str());
}
SET_STRING_ELT(rv_ans, p++, lastR);
n--;
Expand Down Expand Up @@ -243,14 +243,14 @@ static SEXP get_dosage(CFileInfo &File, TVarMap &Var, void *param)
CApply_Variant_Dosage NodeVar(File, false, false, false);
if (!get_geno_is_i32(P, NodeVar))
{
rv_ans = PROTECT(allocMatrix(RAWSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(RAWSXP, nSample, nVariant));
C_UInt8 *base = (C_UInt8 *)RAW(rv_ans);
do {
NodeVar.ReadDosage(base);
base += nSample;
} while (NodeVar.Next());
} else {
rv_ans = PROTECT(allocMatrix(INTSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(INTSXP, nSample, nVariant));
int *base = INTEGER(rv_ans);
do {
NodeVar.ReadDosage(base);
Expand All @@ -277,14 +277,14 @@ static SEXP get_dosage_alt(CFileInfo &File, TVarMap &Var, void *param)
CApply_Variant_Dosage NodeVar(File, false, true, false);
if (!get_geno_is_i32(P, NodeVar))
{
rv_ans = PROTECT(allocMatrix(RAWSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(RAWSXP, nSample, nVariant));
C_UInt8 *base = (C_UInt8 *)RAW(rv_ans);
do {
NodeVar.ReadDosageAlt(base);
base += nSample;
} while (NodeVar.Next());
} else {
rv_ans = PROTECT(allocMatrix(INTSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(INTSXP, nSample, nVariant));
int *base = INTEGER(rv_ans);
do {
NodeVar.ReadDosageAlt(base);
Expand All @@ -311,14 +311,14 @@ static SEXP get_dosage_alt2(CFileInfo &File, TVarMap &Var, void *param)
CApply_Variant_Dosage NodeVar(File, false, true, true);
if (!get_geno_is_i32(P, NodeVar))
{
rv_ans = PROTECT(allocMatrix(RAWSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(RAWSXP, nSample, nVariant));
C_UInt8 *base = (C_UInt8 *)RAW(rv_ans);
do {
NodeVar.ReadDosageAlt_p(base);
base += nSample;
} while (NodeVar.Next());
} else {
rv_ans = PROTECT(allocMatrix(INTSXP, nSample, nVariant));
rv_ans = PROTECT(Rf_allocMatrix(INTSXP, nSample, nVariant));
int *base = INTEGER(rv_ans);
do {
NodeVar.ReadDosageAlt_p(base);
Expand Down Expand Up @@ -572,7 +572,7 @@ static SEXP get_ref_allele(CFileInfo &File, TVarMap &Var, void *param)
const char *p = buffer[i].c_str();
size_t m = 0;
for (const char *s=p; *s!=',' && *s!=0; s++) m++;
SET_STRING_ELT(rv_ans, k++, mkCharLen(p, m));
SET_STRING_ELT(rv_ans, k++, Rf_mkCharLen(p, m));
}
}
UNPROTECT(1);
Expand All @@ -595,7 +595,7 @@ static SEXP get_alt_allele(CFileInfo &File, TVarMap &Var, void *param)
const char *p = buffer[i].c_str();
for (; *p!=',' && *p!=0;) p++;
if (*p == ',') p++;
SET_STRING_ELT(rv_ans, k++, mkChar(p));
SET_STRING_ELT(rv_ans, k++, Rf_mkChar(p));
}
}
UNPROTECT(1);
Expand All @@ -620,7 +620,7 @@ static SEXP get_chrom_pos(CFileInfo &File, TVarMap &Var, void *param)
if (*s++)
{
snprintf(buf, sizeof(buf), "%s:%d", Chrom[i].c_str(), pos[i]);
SET_STRING_ELT(rv_ans, p++, mkChar(buf));
SET_STRING_ELT(rv_ans, p++, Rf_mkChar(buf));
n--;
}
}
Expand Down Expand Up @@ -655,11 +655,11 @@ static SEXP get_chrom_pos2(CFileInfo &File, TVarMap &Var, void *param)
{
dup ++;
snprintf(p1, sizeof(buf1), "%s:%d_%d", chr, pos[i], dup);
SET_STRING_ELT(rv_ans, p++, mkChar(p1));
SET_STRING_ELT(rv_ans, p++, Rf_mkChar(p1));
} else {
char *tmp;
tmp = p1; p1 = p2; p2 = tmp;
SET_STRING_ELT(rv_ans, p++, mkChar(p2));
SET_STRING_ELT(rv_ans, p++, Rf_mkChar(p2));
dup = 0;
}
n--;
Expand Down Expand Up @@ -695,7 +695,7 @@ static SEXP get_chrom_pos_allele(CFileInfo &File, TVarMap &Var, void *param)
for (char *p=(char*)allele; *p; p++)
if (*p == ',') *p = '_';
snprintf(strbuf, sizeof(strbuf), "%s:%d_%s", chr, pos, allele);
SET_STRING_ELT(rv_ans, k++, mkChar(strbuf));
SET_STRING_ELT(rv_ans, k++, Rf_mkChar(strbuf));
}
}
UNPROTECT(1);
Expand Down Expand Up @@ -1280,25 +1280,25 @@ COREARRAY_DLL_EXPORT SEXP SEQ_GetData(SEXP gdsfile, SEXP var_name, SEXP UseRaw,
{
// var.name
if (!Rf_isString(var_name))
error("'var.name' should be character.");
Rf_error("'var.name' should be character.");
const int nlen = RLength(var_name);
// .useraw
if (TYPEOF(UseRaw) != LGLSXP)
error("'.useraw' must be logical.");
Rf_error("'.useraw' must be logical.");
const int use_raw = Rf_asLogical(UseRaw);
// .padNA
const int padNA = Rf_asLogical(PadNA);
if (padNA == NA_LOGICAL)
error("'.padNA' must be TRUE or FALSE.");
Rf_error("'.padNA' must be TRUE or FALSE.");
// .tolist
const int tolist = Rf_asLogical(ToList);
if (tolist == NA_LOGICAL)
error("'.tolist' must be TRUE or FALSE.");
Rf_error("'.tolist' must be TRUE or FALSE.");
// .envir
if (!Rf_isNull(Env))
{
if (!Rf_isEnvironment(Env) && !Rf_isVectorList(Env))
error("'envir' should be an environment and list object.");
Rf_error("'envir' should be an environment and list object.");
}
// if var.name = character()
if (nlen <= 0) return R_NilValue;
Expand All @@ -1319,9 +1319,9 @@ COREARRAY_DLL_EXPORT SEXP SEQ_GetData(SEXP gdsfile, SEXP var_name, SEXP UseRaw,
VarGetData(File, CHAR(STRING_ELT(var_name, i)), use_raw,
padNA, tolist, Env));
}
SEXP nm = getAttrib(var_name, R_NamesSymbol);
SEXP nm = Rf_getAttrib(var_name, R_NamesSymbol);
if (nm == R_NilValue) nm = var_name;
setAttrib(rv_ans, R_NamesSymbol, nm);
Rf_setAttrib(rv_ans, R_NamesSymbol, nm);
UNPROTECT(1);
}
COREARRAY_CATCH
Expand All @@ -1338,24 +1338,24 @@ COREARRAY_DLL_EXPORT SEXP SEQ_BApply_Variant(SEXP gdsfile, SEXP var_name,
// bsize
int bsize = Rf_asInteger(RGetListElement(param, "bsize"));
if (bsize < 1)
error("'bsize' must be >= 1.");
Rf_error("'bsize' must be >= 1.");
// .useraw
SEXP pam_use_raw = RGetListElement(param, "useraw");
if (!Rf_isLogical(pam_use_raw))
error("'.useraw' must be TRUE, FALSE or NA.");
Rf_error("'.useraw' must be TRUE, FALSE or NA.");
int use_raw_flag = Rf_asLogical(pam_use_raw);
// .padNA
int padNA = Rf_asLogical(RGetListElement(param, "padNA"));
if (padNA == NA_LOGICAL)
error("'.padNA' must be TRUE or FALSE.");
Rf_error("'.padNA' must be TRUE or FALSE.");
// .tolist
int tolist = Rf_asLogical(RGetListElement(param, "tolist"));
if (tolist == NA_LOGICAL)
error("'.tolist' must be TRUE or FALSE.");
Rf_error("'.tolist' must be TRUE or FALSE.");
// .progress
int prog_flag = Rf_asLogical(RGetListElement(param, "progress"));
if (prog_flag == NA_LOGICAL)
error("'.progress' must be TRUE or FALSE.");
Rf_error("'.progress' must be TRUE or FALSE.");

COREARRAY_TRY

Expand Down Expand Up @@ -1410,7 +1410,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_BApply_Variant(SEXP gdsfile, SEXP var_name,
}

// rho environment
if (!isEnvironment(rho))
if (!Rf_isEnvironment(rho))
throw ErrSeqArray("'rho' should be an environment");

// var.index
Expand Down Expand Up @@ -1509,7 +1509,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_BApply_Variant(SEXP gdsfile, SEXP var_name,
use_raw_flag, padNA, tolist, rho));
}
// call R function
call_val = eval(R_fcall, rho);
call_val = Rf_eval(R_fcall, rho);

} else {
R_call_param = VarGetData(File, CHAR(STRING_ELT(var_name, 0)),
Expand All @@ -1525,7 +1525,7 @@ COREARRAY_DLL_EXPORT SEXP SEQ_BApply_Variant(SEXP gdsfile, SEXP var_name,
}

// call R function
call_val = eval(R_fcall, rho);
call_val = Rf_eval(R_fcall, rho);
}

// store data
Expand Down
Loading

0 comments on commit 4e1f776

Please sign in to comment.