|
2 | 2 | // |
3 | 3 | // SeqArray.cpp: the C++ codes for the SeqArray package |
4 | 4 | // |
5 | | -// Copyright (C) 2013-2024 Xiuwen Zheng |
| 5 | +// Copyright (C) 2013-2025 Xiuwen Zheng |
6 | 6 | // |
7 | 7 | // This file is part of SeqArray. |
8 | 8 | // |
@@ -1362,6 +1362,29 @@ COREARRAY_DLL_EXPORT SEXP SEQ_ClearVarMap(SEXP gdsfile) |
1362 | 1362 |
|
1363 | 1363 |
|
1364 | 1364 |
|
| 1365 | +// =========================================================== |
| 1366 | +// Clear VarMap in a GDS file |
| 1367 | +// =========================================================== |
| 1368 | + |
| 1369 | +COREARRAY_DLL_EXPORT SEXP SEQ_BufferPosition(SEXP gdsfile, SEXP clear) |
| 1370 | +{ |
| 1371 | + int clear_flag = Rf_asLogical(clear); |
| 1372 | + COREARRAY_TRY |
| 1373 | + CFileInfo &File = GetFileInfo(gdsfile); |
| 1374 | + if (clear_flag == 1) // TRUE |
| 1375 | + { |
| 1376 | + File.ClearPosition(); |
| 1377 | + rv_ans = R_NilValue; |
| 1378 | + } else { |
| 1379 | + vector<C_Int32> &pos = File.Position(); |
| 1380 | + SEXP n = Rf_ScalarInteger(pos.size()); // # of positions |
| 1381 | + rv_ans = R_MakeExternalPtr(&pos[0], R_NilValue, n); |
| 1382 | + } |
| 1383 | + COREARRAY_CATCH |
| 1384 | +} |
| 1385 | + |
| 1386 | + |
| 1387 | + |
1365 | 1388 | // =========================================================== |
1366 | 1389 | // Get system configuration |
1367 | 1390 | // =========================================================== |
@@ -1653,7 +1676,7 @@ COREARRAY_DLL_EXPORT void R_init_SeqArray(DllInfo *info) |
1653 | 1676 | CALL(SEQ_SelectFlag, 2), CALL(SEQ_ResetChrom, 1), |
1654 | 1677 |
|
1655 | 1678 | CALL(SEQ_IntAssign, 2), CALL(SEQ_AppendFill, 3), |
1656 | | - CALL(SEQ_ClearVarMap, 1), |
| 1679 | + CALL(SEQ_ClearVarMap, 1), CALL(SEQ_BufferPosition, 2), |
1657 | 1680 |
|
1658 | 1681 | CALL(SEQ_bgzip_create, 1), |
1659 | 1682 | CALL(SEQ_ToVCF_Init, 6), CALL(SEQ_ToVCF_Done, 0), |
|
0 commit comments