plink2_text library

35 views
Skip to first unread message

choish...@gmail.com

unread,
Nov 15, 2021, 12:58:15 PM11/15/21
to plink2-dev
Hi Chris,

Thanks for the software and library. I am currently trying to update our software to use PGEN data and are having some trouble using the libraries.

For plink2_text, do we need to have a global memory pool like g_bigstack_base for us to use it? If not, what are the preferred way of memory allocation? I saw that SizeAndInitTextStream is used in psam.cc and TextStreamOpenEx is used in pmerge.cc. Which is the preferred function?

Sorry for the troubles.

Thanks

Sam

Christopher Chang

unread,
Nov 16, 2021, 2:51:44 AM11/16/21
to plink2-dev
No, plink2_text does not require a global memory pool.  See LoadMinimalPvar() in pvar_ffi_support.cc for a straightforward TextStreamOpen() example.

choish...@gmail.com

unread,
Nov 16, 2021, 10:02:15 AM11/16/21
to plink2-dev
Thanks! Will do.

choish...@gmail.com

unread,
Jan 4, 2022, 11:09:24 AM1/4/22
to plink2-dev
Hi Chris, if you don't mind me asking, is multi-thread read / write implemented in the library? If so, is it InitBgzfCompressStream?

Thanks!

Christopher Chang

unread,
Jan 4, 2022, 11:53:52 AM1/4/22
to plink2-dev
Yes.  TextStreamOpenEx() has a decompress_thread_ct parameter (which is set by TextStreamOpen() to the number of detected cores).

Christopher Chang

unread,
Jan 4, 2022, 11:55:20 AM1/4/22
to plink2-dev
(oops, that's just the reader; yes, InitBgzfCompressStream can be used for writing and also has a thread_ct parameter.)

choish...@gmail.com

unread,
Jan 5, 2022, 2:56:14 PM1/5/22
to plink2-dev
Thanks Chris, based on the usage in plink_merge.cc,  I guess the parameters should be:

1. File name
2. Maximum length of line allow? (plink2::kMaxLongLine)
3. The size of the buffer?  I guess that would be plink2::kMaxLongLine + plink2::kDecompressChunkSize  if we don't have the global memory pool size? Or should that preferrably be a different number?
4. Number of thread use for decompress
5. Not sure what this is, only know that it is a textFile pointer and can be a nullptr
6. The linebuf storage
7. The initialized plink2::TextStream

Is that correct? Sorry for the troubles and thank you for your library.

Christopher Chang

unread,
Jan 5, 2022, 5:57:25 PM1/5/22
to plink2-dev
The simpler TextStreamOpen() wrapper is defined as:

HEADER_INLINE PglErr TextStreamOpen(const char* fname, TextStream* txs_ptr) {
  return TextStreamOpenEx(fname, kMaxLongLine, 0, NumCpu(nullptr), nullptr, nullptr, txs_ptr);
}

If you are not using a global memory pool, this form will allocate the necessary memory for you (and free it when you call CleanupTextStream on the returned plink2::TextStream).  Feel free to change the decompressor thread count.

choish...@gmail.com

unread,
Jan 5, 2022, 7:12:52 PM1/5/22
to plink2-dev
That's exactly what I needed. Thanks Chris!
Reply all
Reply to author
Forward
0 new messages