Skip to content

Commit

Permalink
Merge branch 'oopsie' into 'dev'
Browse files Browse the repository at this point in the history
Fix nonstandard RG tag leading to segfault [CW-5364]

See merge request epi2melabs/fastcat!79
  • Loading branch information
cjw85 committed Dec 2, 2024
2 parents 65cc70b + 10af24c commit 0e96ed7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [v0.19.1]
### Fixed
- Compilation on macOS with clang.
- Segmentation fault with bad read group information.

## [v0.19.0]
### Added
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ mem_check_fastcat_demultiplex: fastcat
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./fastcat test/data/*.fastq.gz --demultiplex demultiplex > /dev/null

.PHONY: mem_check_fastcat_demultiplex
mem_check_fastcat_demultiplex: fastcat
rm -rf demultiplex
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./fastcat test/data/*.fastq.gz --demultiplex demultiplex > /dev/null

.PHONY: mem_check_bamstats
mem_check_bamstats: bamstats
@echo "Memcheck bamstats with good data"
rm -rf bamstats-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamstats test/parse_rg/[email protected] > /dev/null
@echo "Memcheck bamstats with bad data"
@echo ""
rm -rf bamstats-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamstats test/bamstats/400ecoli-with-qcfail.bam
./bamstats test/parse_rg/bad-ones.bam > /dev/null
@echo ""
@echo "Memcheck bamstats with qcfails"
rm -rf bamstats-histograms
$(VALGRIND) --error-exitcode=1 --tool=memcheck --leak-check=full --show-leak-kinds=all -s \
./bamstats test/parse_rg/[email protected].bam
./bamstats test/bamstats/400ecoli-with-qcfail.bam > /dev/null

.PHONY: mem_check_bamstats_duplex
mem_check_bamstats_duplex: bamstats
Expand Down
8 changes: 6 additions & 2 deletions src/bamstats/readstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,12 @@ void process_bams(
start_time = "";
if (tags.RG != NULL) {
rg_info = create_rg_info(tags.RG);
runid = rg_info->runid;
basecaller = rg_info->basecaller;
if (rg_info->runid != NULL) {
runid = rg_info->runid;
}
if (rg_info->basecaller != NULL) {
basecaller = rg_info->basecaller;
}
} else if (tags.RD != NULL) {
runid = tags.RD;
}
Expand Down
2 changes: 2 additions & 0 deletions src/kh_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int kh_counter_val(kh_counter_t *hash, char *key) {
}

size_t kh_counter_add(kh_counter_t *hash, char *key, int val) {
if (key == NULL) {return -1;}
// note: key is copied so no need for caller to hold on to it
int ret;
khiter_t k = kh_put(KH_COUNTER, hash, key, &ret);
Expand All @@ -47,6 +48,7 @@ size_t kh_counter_add(kh_counter_t *hash, char *key, int val) {
}

size_t kh_counter_sub(kh_counter_t *hash, char *key, int val) {
if (key == NULL) {return -1;}
// note: key is copied so no need for caller to hold on to it
int ret;
khiter_t k = kh_put(KH_COUNTER, hash, key, &ret);
Expand Down
Binary file added test/parse_rg/bad-ones.bam
Binary file not shown.
Binary file added test/parse_rg/bad-ones.bam.bai
Binary file not shown.

0 comments on commit 0e96ed7

Please sign in to comment.