Skip to content
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

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

nh13
Copy link
Member

@nh13 nh13 commented Aug 25, 2022

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.

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);
Copy link
Member Author

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);
Copy link
Member Author

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
Copy link
Member Author

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.

@whitwham whitwham self-assigned this Aug 26, 2022
@whitwham whitwham merged commit 3571c32 into samtools:develop Aug 26, 2022
@nh13 nh13 deleted the bugfix/merge-for-template-coordinate branch May 16, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants