Skip to content

Commit

Permalink
Merge branch 'samtools-2086' into 'dev'
Browse files Browse the repository at this point in the history
[CW-4573] Allow more flexibility in samtools hex suffixes

See merge request epi2melabs/fastcat!69
  • Loading branch information
cjw85 committed Jul 24, 2024
2 parents 4a82041 + 6dec012 commit 76800b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).



## [v0.18.5]
### Changed
- Parsing of RG ID field containing a modified base model, now returns only the core basecaller model.
### Fixed
- Workaround samtools "bug" where RG ID suffix is not fixed width.

## [v0.18.4]
### Fixed
Expand Down
11 changes: 8 additions & 3 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,14 @@ void strip_hex_suffix(char *str) {
regex_t regex;
regmatch_t matches[1];

// its supposed to be formatted as "%s-%0lX" which is a long formatted
// as hex with leading zeros. But I (cjw) observed cases with only 7 \:D/
if (regcomp(&regex, "-[0-9A-Fa-f]{7,8}$", REG_EXTENDED) != 0) {
// samtools formats this as "%s-%0lX" which is a long formatted
// as hex with leading zeros. BUT there's no field width specified!
// https://github.com/samtools/samtools/issues/2086
// This will strip even a solitary `-` from the end of the string,
// we could be probabilistic and require say 2 hex digits leaving
// the 16 edge cases of 0 ("") to F. No one should have and RG ID
// ending in "-", right?
if (regcomp(&regex, "-[0-9A-Fa-f]{0,8}$", REG_EXTENDED) != 0) {
fprintf(stderr, "Could not compile regex\n");
exit(1);
}
Expand Down

0 comments on commit 76800b7

Please sign in to comment.