-
Notifications
You must be signed in to change notification settings - Fork 9
/
bam_prase.h
108 lines (75 loc) · 2.32 KB
/
bam_prase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
Authors:
Haoyu Cheng
*/
#ifndef __BAM_PRASE__
#define __BAM_PRASE__
#include <stdio.h>
#include <stdlib.h>
#include <htslib/sam.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <inttypes.h>
#include <stdbool.h>
#include <assert.h>
#include <getopt.h>
#include <ctype.h>
#include <htslib/sam.h>
#include <htslib/faidx.h>
#include <htslib/kstring.h>
#include <htslib/khash.h>
#include <htslib/klist.h>
#include <htslib/thread_pool.h>
#include <htslib/bgzf.h>
#include <htslib/sam.h>
#include "Schema.h"
typedef struct
{
samFile* bam_file;
bam_hdr_t* bam_header;
char* output_name;
} bam_operations;
typedef struct
{
kstring_t line;
bam1_t *b;
} bam_output_cell;
typedef struct
{
bam_hdr_t* bam_header;
kstring_t line;
bam1_t **b;
long long size;
long long number;
} bam_output_group;
typedef struct
{
kstring_t line;
bam1_t *b;
BGZF* bgzf;
bgzf_buffer result;
} bam_phrase;
void init_bam_buffer(bam_phrase* buf);
void init_bam_output_group(bam_output_group* group, long long total_size);
void phrase_alignment_only(char* alignment, long long alignment_length, bam_output_group* bam_groups);
void write_alignment_only(bam_output_group* bam_groups);
void get_bam_header(bam_hdr_t** bam_header);
void init_bam_output_cell(bam_output_cell* cell);
void write_alignment_directly(char* alignment, long long alignment_length, bam_output_cell* cell);
void close_bam_file_rename(char* old_name, char* new_name);
void init_bam_header(char* bam_file_name, _rg_name_l *_ih_refGenName, int refChromeCont, int argc, char *argv[]);
void init_bam_file_from_sam(char* file_name, char* outputFileName,
_rg_name_l *_ih_refGenName, int refChromeCont, int argc, char *argv[]);
void close_bam_file();
void write_alignment(const char* alignment);
void write_alignment_muti_thread(const char* alignment);
void write_alignment_group(char* alignment, const long long length);
void write_alignment_group_pre_allocate(char* alignment, const long long length, const long long number);
void convert_string_to_bam(char* alignment, long long alignment_length, bam_phrase* bam_groups);
void flush_bam_buffer(bam_phrase* bam_groups);
#endif