Created
February 28, 2025 01:48
-
-
Save sjhalayka/41a0d501966a7a17cbc87b5bcf82037f to your computer and use it in GitHub Desktop.
Read code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pgenlib_read.h" | |
#include "pgenlib_write.h" | |
#ifdef __cplusplus | |
using namespace plink2; | |
#endif | |
int32_t main(int32_t argc, char** argv) | |
{ | |
PglErr reterr = kPglRetSuccess; | |
PgenHeaderCtrl header_ctrl; | |
PgenFileInfo pgfi; | |
PgenReader pgr; | |
PreinitPgfi(&pgfi); | |
PreinitPgr(&pgr); | |
uint32_t sample_ct = 0; | |
uint32_t variant_ct = 0; | |
char errstr_buf[kPglErrstrBufBlen]; | |
uintptr_t cur_alloc_cacheline_ct; | |
reterr = PgfiInitPhase1("data2.pgen", nullptr, 0xffffffffU, 0xffffffffU, &header_ctrl, &pgfi, &cur_alloc_cacheline_ct, errstr_buf); | |
if (reterr) { | |
fputs(errstr_buf, stderr); | |
return 0; | |
} | |
sample_ct = pgfi.raw_sample_ct; | |
if (!sample_ct) { | |
fprintf(stderr, "error: sample_ct == 0\n"); | |
return 0; | |
} | |
variant_ct = pgfi.raw_variant_ct; | |
if (!variant_ct) { | |
fprintf(stderr, "error: variant_ct == 0\n"); | |
return 0; | |
} | |
printf("%u variant%s and %u sample%s detected.\n", variant_ct, (variant_ct == 1) ? "" : "s", sample_ct, (sample_ct == 1) ? "" : "s"); | |
return 0; | |
CleanupPgr(&pgr, &reterr); | |
CleanupPgfi(&pgfi, &reterr); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment