-
Notifications
You must be signed in to change notification settings - Fork 460
Update the new introspection API: minor bug fixes, better names for hFILE plugin API functions #1222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
(Added another commit to resolve the conflict with PR #1211's fix of the same Makefile buglet. This commit should probably be omitted in the event this PR is rebased or merged.) |
|
You might also consider renaming the general-purpose introspection functions as |
|
Is there any guidance on naming or file structure? I confess I don't really understand what should be in what file as it doesn't feel particularly cleanly separated to me. I chose hfile because it felt like the best fit, but clearly you disagree (and you're the author of both that and hts.c). The only documentation I could find is counter to your changes. Eg hts.h explicitly states: Format-neutral I/O, indexing, and iterator API functions. This is obviously at odds with introspection functions. As for that matter is hfile.h (Buffered low-level input/output streams). Both seem to contain other unrelated stuff. Maybe we need a different header completely (Edit: it's why I initially chose neither and they started off life in hts_os.h which was the general rag-tag of OS specific things, which felt like a better fit for introspection queries to me)? Either that or fix the documentation to match reality. PS. Don't even get me started on sam.h, which appears to include not only the kitchen sink but the entire scullery. |
|
No real guidance that I'm aware of I'm afraid 😄 IMHO there's a division between relatively well-delineated stuff (most .h and .c files) and general dumping grounds (hts.h, sam.h). So e.g. hfile.h is pretty well-delineated and focussed on Yes, hts.h says “Format-neutral I/O, indexing, and iterator API functions” as a summary, but that's mainly a polite way of saying “That format-neutral stuff and a random grab bag of other generic htsfoo stuff”. Similarly, whatever the comment at the top of sam.h says, what it means is “random grab bag of everything to do with SAM(/BAM/CRAM generically) sequence data files”. |
It'll be convenient for API users to find the HTS_FEATURE_* functionality in htslib/hts.h alongside hts_version() etc. Fix the missing quote marks for -DHTS_CPPFLAGS by recoding to implement this via a new generated config_vars.h header instead. Similarly to the version.h and config.h rules, this avoids the fragile quoting needed to add possibly-whitespace-containing string values via -D options. Ignore config_vars.h and some recently-added test executables.
Leave gaps in the allocated bits between the different feature categories. Leave a gap at the end for HTS_FEATURE_LIBS if it is added in future. Don't mention htslib_plugin_path() in the public header as it is an internal function. Change htslib_test_feature() to use unsigned int, as per htslib_features().
The hFILE plugin mechanism is the only current plugin endpoint in HTSlib, but the facility is general so that there could be other plugin endpoints added in future, e.g., for other compression methods. Rename these introspection functions as they pertain to hFILE plugins only.
|
Thanks John, I'll rebase and merge this. It occurs to me that I forgot to do part 2 of this - a Trivial to do though so I'll knock one up. :-) |
|
Excellent, thanks. I'd draw your attention to the question in #1222 (comment) although TBH At the risk of opening a can of worms: Is there any version infrastructure for htscodecs? If you use the standard submodule commit as recorded in the htslib commit (rather than |
965cba7 to
3392674
Compare
|
I'm unsure what to do about the introspection stuff - I can see both Htscodecs versioning follows the strict major, minor, patchlevel rules dictated by GNU and autotools (which is compatible with the usual versioning numbers). It doesn't have any introspection functions for querying the version number. It's probably something we should add though. I know Rob was doing something about submodule configurations and the ways it tracks, but tbh I'm still learning what works and what doesn't. |
|
I'll leave I had in mind whether the associated htscodecs version was something that needed to be added to |
This maintains consistency with the existing hts_version() function. Note this also renames the internal htslib_plugin_path function too, again simply for consistency. Not it queries the HTS_PATH and not HTSLIB_PATH environment variable, so the new name is better.
|
I think htscodecs is a sufficiently different issue that it can come as a new PR. It'll need to be done in sync with changes there too. Meanwhile, I took the liberty of pushing an additional commit to this branch to do the renaming. Let me know what you think and if you're happy I'll hit the merge button. |
|
Looks good for the public functions. For The existing path-handling functions that this introspection function is associated with are And the flexible signature would parallel const char *hts_path_string(const char *path, const char *builtin_path)
{
if (! builtin_path) builtin_path = PLUGINPATH;
if (! path) path = getenv("HTS_PATH");
// …Or expose the const char *hts_path_expand(kstring_t *dest, const char *path, const char *builtin_path)
{
ks_clear(dest);
// set path & builtin_path as before
// …Anyway, as it's internal all that can always be made more flexible later if it's useful… |
|
👍 🎉 |
Apologies for the belated followup to PR #1170. This fixes some minor API bugs, moves some code around to a better place for it, and renames the hFILE plugin introspection functions:
Use
unsigned intconsistently, and leave gaps between the allocated bits in different categories (general/transport/compression/build) for future additions.Users will find
"htslib/hfile.h"to be an odd place for the general-purposehtslib_features()etc functions. This moves them to"htslib/hts.h"alongside the existinghts_version()functions — ashts.his already a bit of a grab bag of everything, this is a good place for it. The hFILE introspection functions of course stay inhfile.h.The
hFILEplugin mechanism is the only current plugin endpoint in HTSlib, but the facility is general so that there could be other plugin endpoints added in future, e.g., for other compression methods. So rename these introspection functions to have ahfile_prefix as they introspect only the hFILE plugins and URL scheme machinery.