-
Notifications
You must be signed in to change notification settings - Fork 577
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
bug fix: samtools merge --template-coordinate #1705
bug fix: samtools merge --template-coordinate #1705
Conversation
The keys used to compare based on template coordinate were not being created as the input sorted BAMs were being merged
if (keys->n + n >= keys->m * keys->buffer_size) { | ||
if (template_coordinate_keys_realloc(keys, keys->n + n) < 0) goto mem_fail; | ||
} | ||
lib_lookup = lookup_libraries(hout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unsure of which header to use, so I picked the output one. I think that's correct, but it could use a second set of eyes.
@@ -1686,7 +1728,7 @@ static inline int heap_add_read(heap1_t *heap, int nfiles, samFile **fp, | |||
if (in_mem[i - nfiles].from < in_mem[i - nfiles].to) { | |||
size_t from = in_mem[i - nfiles].from; | |||
heap->entry.bam_record = buf[from].bam_record; | |||
if (g_sam_order == TemplateCoordinate) heap->entry.u.key = template_coordinate_keys_get(keys, from); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes here and below are from #1703
@@ -1379,6 +1410,10 @@ int bam_merge_core2(SamOrder sam_order, char* sort_tag, const char *out, const c | |||
heap->idx = idx++; | |||
if (g_sam_order == TagQueryName || g_sam_order == TagCoordinate) { | |||
heap->entry.u.tag = bam_aux_get(heap->entry.bam_record, g_sort_tag); | |||
} else if (g_sam_order == TemplateCoordinate) { | |||
template_coordinate_key_t *key = template_coordinate_keys_get(keys, heap->i); // get the next key to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think heap->i
is the correct index, but could use another set of eyes.
This includes the commit for the fix in #1703, so this should be merged only after that has been merged.
The keys used to compare based on template coordinate were not being created as the input sorted BAMs were being merged.
Tested via merging large sorted files that were created using the fix in #1703.