2025-04-17 16:17:44 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <htslib/sam.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2025-12-16 23:44:49 +08:00
|
|
|
#include "sort.h"
|
|
|
|
|
|
2025-04-17 16:17:44 +08:00
|
|
|
// Struct which contains the sorting key for TemplateCoordinate sort.
|
|
|
|
|
struct TemplateCoordinateKey {
|
|
|
|
|
int tid1;
|
|
|
|
|
int tid2;
|
|
|
|
|
hts_pos_t pos1;
|
|
|
|
|
hts_pos_t pos2;
|
|
|
|
|
bool neg1;
|
|
|
|
|
bool neg2;
|
|
|
|
|
const char *library;
|
|
|
|
|
char *mid;
|
|
|
|
|
char *name;
|
|
|
|
|
bool is_upper_of_pair;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Struct which contains the a record, and the pointer to the sort tag (if any) or
|
|
|
|
|
// a combined ref / position / strand.
|
|
|
|
|
// Used to speed up sorts (coordinate, by-tag, and template-coordinate).
|
2025-04-17 18:29:12 +08:00
|
|
|
struct BamSortTag {
|
2025-04-17 16:17:44 +08:00
|
|
|
bam1_t *bam_record;
|
|
|
|
|
union {
|
|
|
|
|
const uint8_t *tag;
|
|
|
|
|
uint8_t pos_tid[12];
|
|
|
|
|
TemplateCoordinateKey *key;
|
|
|
|
|
} u;
|
2025-12-16 23:44:49 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int ks_radixsort(size_t n, OneBam* buf, const sam_hdr_t* h, int tid);
|