31 #ifndef _CRAM_STRUCTS_H_
32 #define _CRAM_STRUCTS_H_
66 typedef
unsigned char uc;
83 #define SEQS_PER_SLICE 10000
84 #define SLICE_PER_CNT 1
86 #define CRAM_SUBST_MATRIX "CGTNAGTNACTNACGNACGT"
88 #define MAX_STAT_VAL 1024
184 #define CRAM_MAJOR_VERS(v) ((v) >> 8)
185 #define CRAM_MINOR_VERS(v) ((v) & 0xff)
266 #define CRAM_MAP_HASH 32
267 #define CRAM_MAP(a,b) (((a)*3+(b))&(CRAM_MAP_HASH-1))
286 char substitution_matrix[5][4];
295 khash_t(map) *preservation_map;
328 unsigned char md5[16];
435 #define cram_qname(c) (&(c)->s->name_blk->data[(c)->name])
436 #define cram_seq(c) (&(c)->s->seqs_blk->data[(c)->seq])
437 #define cram_qual(c) (&(c)->s->qual_blk->data[(c)->qual])
438 #define cram_aux(c) (&(c)->s->aux_blk->data[(c)->aux])
439 #define cram_seqi(c,i) (cram_seq((c))[(i)])
440 #define cram_name_len(c) ((c)->name_len)
441 #define cram_strand(c) (((c)->flags & BAM_FREVERSE) != 0)
442 #define cram_mstrand(c) (((c)->flags & BAM_FMREVERSE) != 0)
443 #define cram_cigar(c) (&((cr)->s->cigar)[(c)->cigar])
707 unsigned char L1[256];
708 unsigned char L2[256];
772 #define CRAM_CIGAR (CRAM_FN | CRAM_FP | CRAM_FC | CRAM_DL | CRAM_IN | \
773 CRAM_SC | CRAM_HC | CRAM_PD | CRAM_RS | CRAM_RL | CRAM_BF)
775 #define CRAM_SEQ (CRAM_CIGAR | CRAM_BA | CRAM_QS | CRAM_BS | \
776 CRAM_RL | CRAM_AP | CRAM_BB | CRAM_QQ)
780 #define CRAM_FPAIRED 256
781 #define CRAM_FPROPER_PAIR 128
782 #define CRAM_FUNMAP 64
783 #define CRAM_FREVERSE 32
784 #define CRAM_FREAD1 16
785 #define CRAM_FREAD2 8
786 #define CRAM_FSECONDARY 4
787 #define CRAM_FQCFAIL 2
790 #define DS_aux_S "\001"
791 #define DS_aux_OQ_S "\002"
792 #define DS_aux_BQ_S "\003"
793 #define DS_aux_BD_S "\004"
794 #define DS_aux_BI_S "\005"
795 #define DS_aux_FZ_S "\006"
796 #define DS_aux_oq_S "\007"
797 #define DS_aux_os_S "\010"
798 #define DS_aux_oz_S "\011"
800 #define CRAM_M_REVERSE 1
801 #define CRAM_M_UNMAP 2
805 #define CRAM_FLAG_PRESERVE_QUAL_SCORES (1<<0)
806 #define CRAM_FLAG_DETACHED (1<<1)
807 #define CRAM_FLAG_MATE_DOWNSTREAM (1<<2)
int32_t mate_ref_id
Definition: cram_structs.h:407
int lzma_cnt
Definition: cram_structs.h:235
Definition: cram_structs.h:755
uint8_t minor_version
Definition: cram_structs.h:180
#define KHASH_MAP_INIT_INT(name, khval_t)
Definition: khash.h:583
cram_fields
Definition: cram_structs.h:733
Definition: cram_structs.h:144
cram_block * aux_BD_blk
Definition: cram_structs.h:562
Definition: cram_structs.h:114
Definition: cram_structs.h:102
Definition: cram_structs.h:128
int eof
Definition: cram_structs.h:714
int32_t len
Definition: cram_structs.h:401
char * fn
Definition: cram_structs.h:603
int32_t cram_flags
Definition: cram_structs.h:400
Definition: cram_structs.h:192
Definition: cram_structs.h:762
unsigned int required_fields
Definition: cram_structs.h:701
Definition: cram_structs.h:763
enum cram_encoding encoding
Definition: cram_structs.h:309
Definition: cram_structs.h:152
int ref_id
Definition: cram_structs.h:680
Definition: cram_structs.h:170
int bzip2_cnt
Definition: cram_structs.h:234
size_t offset
Definition: cram_structs.h:355
int ignore_md5
Definition: cram_structs.h:696
int32_t num_content_ids
Definition: cram_structs.h:325
int32_t ref_base_id
Definition: cram_structs.h:327
int embed_ref
Definition: cram_structs.h:694
Definition: cram_structs.h:138
int32_t * block_content_ids
Definition: cram_structs.h:326
int max_apos
Definition: cram_structs.h:525
Definition: cram_structs.h:121
char * ref
Definition: cram_structs.h:377
Definition: cram_structs.h:190
int seq_idx
Definition: cram_structs.h:465
int32_t ncigar
Definition: cram_structs.h:425
Definition: cram_structs.h:146
int32_t aux
Definition: cram_structs.h:413
int nslice
Definition: cram_structs.h:628
Definition: cram_structs.h:126
int unmapped_qs_included
Definition: cram_structs.h:280
int qual
Definition: cram_structs.h:460
ref_entry * last
Definition: cram_structs.h:609
int64_t count
Definition: cram_structs.h:589
int32_t mate_flags
Definition: cram_structs.h:431
Definition: cram_structs.h:160
int32_t aend
Definition: cram_structs.h:426
int64_t offset
Definition: cram_structs.h:637
Definition: cram_structs.h:206
struct cram_index cram_index
cram_external_type
Definition: cram_structs.h:111
Definition: string_alloc.h:52
int nfeatures
Definition: cram_structs.h:541
int end
Definition: cram_structs.h:643
Definition: cram_structs.h:749
int bases_per_line
Definition: cram_structs.h:587
Definition: cram_structs.h:736
Definition: cram_structs.h:743
cram_block * name_blk
Definition: cram_structs.h:554
int strat
Definition: cram_structs.h:227
int sz_rans1
Definition: cram_structs.h:221
int use_rans
Definition: cram_structs.h:698
Definition: cram_structs.h:156
cram_block * aux_blk
Definition: cram_structs.h:559
Definition: cram_structs.h:761
Definition: cram_structs.h:745
Definition: cram_structs.h:101
int refid
Definition: cram_structs.h:631
int sz_gz_rle
Definition: cram_structs.h:218
int32_t num_landmarks
Definition: cram_structs.h:351
char * ref_free
Definition: cram_structs.h:679
uint32_t ncigar
Definition: cram_structs.h:538
int shared_ref
Definition: cram_structs.h:700
cram_block * comp_hdr_block
Definition: cram_structs.h:359
Definition: cram_structs.h:130
char * seq
Definition: cram_structs.h:590
int nTL
Definition: cram_structs.h:290
struct ref_entry ref_entry
int slice_rec
Definition: cram_structs.h:365
Definition: cram_structs.h:169
int len
Definition: cram_structs.h:466
Definition: cram_structs.h:757
int32_t num_records
Definition: cram_structs.h:349
Definition: cram_structs.h:449
int32_t mqual
Definition: cram_structs.h:427
Definition: cram_structs.h:154
int nsamp
Definition: cram_structs.h:93
Definition: cram_structs.h:124
int32_t ref_seq_id
Definition: cram_structs.h:319
int afeatures
Definition: cram_structs.h:542
Definition: cram_structs.h:198
int32_t ntags
Definition: cram_structs.h:412
int refid
Definition: cram_structs.h:641
Definition: cram_structs.h:112
Definition: cram_structs.h:105
int32_t mate_pos
Definition: cram_structs.h:408
int index_sz
Definition: cram_structs.h:711
int32_t record_counter
Definition: cram_structs.h:347
int nref
Definition: cram_structs.h:601
cram_block * qual_blk
Definition: cram_structs.h:556
int sz_lzma
Definition: cram_structs.h:223
Definition: cram_structs.h:208
cram_block ** block
Definition: cram_structs.h:521
uint32_t * cigar
Definition: cram_structs.h:536
Definition: cram_structs.h:140
int offset
Definition: cram_structs.h:310
int32_t tlen
Definition: cram_structs.h:409
Definition: cram_structs.h:108
int use_bz2
Definition: cram_structs.h:697
Definition: cram_structs.h:753
int32_t feature
Definition: cram_structs.h:429
Definition: cram_structs.h:135
Definition: sam_header.h:183
int32_t ref_seq_start
Definition: cram_structs.h:272
int revised_method
Definition: cram_structs.h:236
int sz_bzip2
Definition: cram_structs.h:222
Definition: cram_structs.h:212
int32_t nfeature
Definition: cram_structs.h:430
int32_t ref_seq_span
Definition: cram_structs.h:321
off_t first_container
Definition: cram_structs.h:713
Definition: cram_structs.h:167
Definition: cram_structs.h:759
Definition: cram_structs.h:153
Definition: cram_structs.h:113
SAM_hdr * header
Definition: cram_structs.h:660
int32_t ref_seq_start
Definition: cram_structs.h:320
int32_t * landmark
Definition: cram_structs.h:276
Definition: thread_pool.h:81
int seqs_per_slice
Definition: cram_structs.h:692
int no_ref
Definition: cram_structs.h:695
int count
Definition: cram_structs.h:606
size_t alloc
Definition: cram_structs.h:258
int multi_seq
Definition: cram_structs.h:372
Definition: cram_structs.h:165
#define KHASH_MAP_INIT_STR(name, khval_t)
Definition: khash.h:614
t_pool * pool
Definition: cram_structs.h:722
Definition: cram_structs.h:754
int32_t name_len
Definition: cram_structs.h:405
int pos
Definition: cram_structs.h:452
int slice
Definition: cram_structs.h:635
int ref_start
Definition: cram_structs.h:681
#define CRAM_MAP_HASH
Definition: cram_structs.h:266
Definition: cram_structs.h:125
bam_seq_t ** bams
Definition: cram_structs.h:381
Definition: cram_structs.h:158
double lzma_extra
Definition: cram_structs.h:243
Definition: cram_codecs.h:111
cram_block * aux_oz_blk
Definition: cram_structs.h:567
int ref_end
Definition: cram_structs.h:682
int32_t idx
Definition: cram_structs.h:254
int read_names_included
Definition: cram_structs.h:283
int key
Definition: cram_structs.h:308
Definition: cram_structs.h:171
double bzip2_extra
Definition: cram_structs.h:242
int32_t seq
Definition: cram_structs.h:422
Definition: cram_structs.h:127
bam_seq_t ** bams
Definition: cram_structs.h:651
cram_block * seqs_blk
Definition: cram_structs.h:555
Definition: cram_structs.h:123
Definition: cram_structs.h:756
int last_slice
Definition: cram_structs.h:715
cram_range range
Definition: cram_structs.h:702
cram_block * hdr_block
Definition: cram_structs.h:520
Definition: cram_structs.h:760
int32_t TN_idx
Definition: cram_structs.h:416
Definition: cram_structs.h:518
Definition: cram_structs.h:115
int32_t name
Definition: cram_structs.h:404
Definition: cram_structs.h:100
cram_block * base_blk
Definition: cram_structs.h:557
int32_t * landmark
Definition: cram_structs.h:352
unsigned char ** TL
Definition: cram_structs.h:291
int use_lzma
Definition: cram_structs.h:699
char cram_sub_matrix[32][32]
Definition: cram_structs.h:709
cram_block * aux_OQ_blk
Definition: cram_structs.h:560
int i
Definition: cram_structs.h:72
int line_length
Definition: cram_structs.h:588
Definition: cram_structs.h:177
int nvals
Definition: cram_structs.h:94
string_alloc_t * pool
Definition: cram_structs.h:597
int32_t qual
Definition: cram_structs.h:423
int nalloc
Definition: cram_structs.h:628
cram_block_method
Definition: cram_structs.h:189
Definition: cram_structs.h:151
Definition: cram_structs.h:149
int code
Definition: cram_structs.h:453
uint32_t * TN
Definition: cram_structs.h:546
Definition: cram_structs.h:734
int32_t ref_id
Definition: cram_structs.h:398
#define H(x, y, z)
Definition: md5.c:53
cram_block_compression_hdr * comp_hdr
Definition: cram_structs.h:358
Definition: cram_structs.h:197
int32_t num_records
Definition: cram_structs.h:322
Definition: cram_structs.h:173
Definition: cram_structs.h:103
Definition: cram_structs.h:164
Definition: cram_structs.h:204
Definition: cram_structs.h:742
refs_t * refs
Definition: cram_structs.h:678
cram_block_slice_hdr * hdr
Definition: cram_structs.h:519
int ref_start
Definition: cram_structs.h:573
Definition: cram_structs.h:202
int32_t mate_line
Definition: cram_structs.h:406
int64_t length
Definition: cram_structs.h:585
Definition: cram_structs.h:750
cram_index * index
Definition: cram_structs.h:712
Definition: cram_structs.h:764
struct cram_slice * s
Definition: cram_structs.h:396
int32_t aux_size
Definition: cram_structs.h:414
int empty_container
Definition: cram_structs.h:718
Definition: cram_structs.h:133
Definition: cram_structs.h:141
int unmapped_placed
Definition: cram_structs.h:281
cram_block * aux_BI_blk
Definition: cram_structs.h:563
string_alloc_t * pair_keys
Definition: cram_structs.h:569
Definition: cram_structs.h:747
int aTN
Definition: cram_structs.h:547
Definition: cram_structs.h:758
char * uncomp
Definition: cram_structs.h:301
Definition: cram_structs.h:129
Definition: cram_structs.h:640
int base
Definition: cram_structs.h:454
int last_apos
Definition: cram_structs.h:525
int32_t length
Definition: cram_structs.h:343
Definition: cram_structs.h:142
int last_slice
Definition: cram_structs.h:371
cram_DS_ID
Definition: cram_structs.h:120
Definition: cram_structs.h:735
uint32_t cigar_alloc
Definition: cram_structs.h:537
int sz_rans0
Definition: cram_structs.h:220
int start
Definition: cram_structs.h:642
Definition: cram_structs.h:765
char * prefix
Definition: cram_structs.h:662
int own_pool
Definition: cram_structs.h:721
Definition: cram_structs.h:270
Definition: cram_structs.h:596
unsigned char uc
Definition: cram_structs.h:66
int max_rec
Definition: cram_structs.h:363
int * refs_used
Definition: cram_structs.h:387
Definition: cram_structs.h:196
int sz_gz_def
Definition: cram_structs.h:219
Definition: cram_structs.h:147
double rans1_extra
Definition: cram_structs.h:241
int64_t offset
Definition: cram_structs.h:586
int unsorted
Definition: cram_structs.h:717
Definition: cram_structs.h:193
Definition: cram_structs.h:195
char * ref
Definition: cram_structs.h:572
Definition: cram_structs.h:395
int ref_id
Definition: cram_structs.h:575
int slices_per_container
Definition: cram_structs.h:693
Definition: cram_structs.h:247
double gz_rle_extra
Definition: cram_structs.h:238
int32_t comp_size
Definition: cram_structs.h:251
int gz_rle_cnt
Definition: cram_structs.h:230
cram_metrics * m[DS_END]
Definition: cram_structs.h:687
int32_t content_id
Definition: cram_structs.h:250
unsigned char * data
Definition: cram_structs.h:255
struct cram_codec * codec
Definition: cram_structs.h:312
int AP_delta
Definition: cram_structs.h:284
uint8_t major_version
Definition: cram_structs.h:179
int last_base
Definition: cram_structs.h:675
Definition: cram_structs.h:203
Definition: cram_structs.h:582
int ref_start
Definition: cram_structs.h:376
unsigned int cram_flag_swap[0x1000]
Definition: cram_structs.h:706
cram_record * crecs
Definition: cram_structs.h:531
int32_t num_blocks
Definition: cram_structs.h:324
int32_t flags
Definition: cram_structs.h:399
Definition: cram_structs.h:122
int mapped_qs_included
Definition: cram_structs.h:279
struct cram_map * next
Definition: cram_structs.h:313
Definition: cram_structs.h:751
cram_block * soft_blk
Definition: cram_structs.h:558
int32_t record_counter
Definition: cram_structs.h:323
int next_trial
Definition: cram_structs.h:215
Definition: cram_structs.h:143
int bit
Definition: cram_structs.h:260
cram_block ** block_by_id
Definition: cram_structs.h:522
Definition: cram_structs.h:106
int max_c_rec
Definition: cram_structs.h:364
Definition: cram_structs.h:90
int max_apos
Definition: cram_structs.h:370
int32_t ref_seq_id
Definition: cram_structs.h:271
int last_id
Definition: cram_structs.h:610
char * ref
Definition: cram_structs.h:679
int max_slice
Definition: cram_structs.h:362
int unsorted
Definition: cram_structs.h:373
Definition: cram_structs.h:205
int len
Definition: cram_structs.h:636
Definition: cram_structs.h:740
Definition: cram_structs.h:104
int ref_end
Definition: cram_structs.h:574
Definition: cram_structs.h:134
Definition: cram_structs.h:71
cram_block * TD_blk
Definition: cram_structs.h:289
int32_t ref_seq_start
Definition: cram_structs.h:345
char * name
Definition: cram_structs.h:583
Definition: cram_structs.h:194
Definition: cram_structs.h:166
pthread_mutex_t ref_lock
Definition: cram_structs.h:725
int decode_md
Definition: cram_structs.h:690
int32_t ref_seq_span
Definition: cram_structs.h:273
size_t byte
Definition: cram_structs.h:259
Definition: cram_structs.h:342
Definition: cram_structs.h:139
Definition: cram_structs.h:150
#define khash_t(name)
Definition: khash.h:422
Definition: cram_structs.h:148
Definition: cram_structs.h:207
Definition: cram_structs.h:627
Definition: cram_structs.h:744
Definition: cram_structs.h:116
struct spare_bams * next
Definition: cram_structs.h:652
Definition: cram_structs.h:738
void * job_pending
Definition: cram_structs.h:728
unsigned int bam_flag_swap[0x1000]
Definition: cram_structs.h:705
struct spare_bams spare_bams
ref_entry ** ref_id
Definition: cram_structs.h:600
cram_feature * features
Definition: cram_structs.h:540
unsigned char L1[256]
Definition: cram_structs.h:707
unsigned int data_series
Definition: cram_structs.h:304
Definition: cram_structs.h:159
struct cram_slice ** slices
Definition: cram_structs.h:368
char * ref_fn
Definition: cram_structs.h:683
char * p
Definition: cram_structs.h:73
Definition: cram_structs.h:99
Definition: cram_structs.h:650
Definition: cram_structs.h:132
int32_t uncomp_size
Definition: cram_structs.h:252
int qs_included
Definition: cram_structs.h:282
Definition: cram_structs.h:145
Definition: cram_structs.h:317
int slice_num
Definition: cram_structs.h:664
Definition: cram_structs.h:191
Definition: thread_pool.h:108
cram_encoding
Definition: cram_structs.h:98
size_t uncomp_size
Definition: cram_structs.h:302
Definition: cram_structs.h:137
int64_t num_bases
Definition: cram_structs.h:348
int trial
Definition: cram_structs.h:214
pthread_mutex_t metrics_lock
Definition: cram_structs.h:724
int32_t num_blocks
Definition: cram_structs.h:350
struct hFILE * fp
Definition: cram_structs.h:656
int curr_ref
Definition: cram_structs.h:366
Definition: cram_structs.h:739
cram_block * aux_oq_blk
Definition: cram_structs.h:565
cram_block * aux_os_blk
Definition: cram_structs.h:566
int nseq
Definition: cram_structs.h:634
int last_pos
Definition: cram_structs.h:367
int32_t num_records
Definition: cram_structs.h:274
int version
Definition: cram_structs.h:658
#define KHASH_SET_INIT_INT(name)
Definition: khash.h:575
t_results_queue * rqueue
Definition: cram_structs.h:723
uint32_t crc32
Definition: cram_structs.h:253
Definition: cram_structs.h:746
int32_t ref_seq_id
Definition: cram_structs.h:344
int nTN
Definition: cram_structs.h:547
double gz_def_extra
Definition: cram_structs.h:239
int TL
Definition: cram_structs.h:420
int level
Definition: cram_structs.h:686
int pos_sorted
Definition: cram_structs.h:369
BGZF * fp
Definition: cram_structs.h:604
cram_file_def * file_def
Definition: cram_structs.h:659
Definition: cram_structs.h:157
struct cram_slice cram_slice
#define MAX_STAT_VAL
Definition: cram_structs.h:88
Definition: cram_structs.h:748
Definition: cram_structs.h:752
int end
Definition: cram_structs.h:633
int gz_def_cnt
Definition: cram_structs.h:231
pthread_mutex_t lock
Definition: cram_structs.h:608
cram_content_type
Definition: cram_structs.h:201
unsigned char L2[256]
Definition: cram_structs.h:708
pthread_mutex_t bam_list_lock
Definition: cram_structs.h:727
cram_block * aux_BQ_blk
Definition: cram_structs.h:561
int rans1_cnt
Definition: cram_structs.h:233
int mode
Definition: cram_structs.h:657
cram_block * aux_FZ_blk
Definition: cram_structs.h:564
Definition: cram_structs.h:655
int32_t cigar
Definition: cram_structs.h:424
int multi_seq
Definition: cram_structs.h:716
uint64_t id
Definition: cram_structs.h:528
struct cram_index * e
Definition: cram_structs.h:629
int verbose
Definition: cram_structs.h:691
int record_counter
Definition: cram_structs.h:663
int err
Definition: cram_structs.h:665
int size
Definition: cram_structs.h:311
Definition: cram_structs.h:162
Definition: cram_structs.h:107
Definition: cram_structs.h:741
int32_t ref_seq_span
Definition: cram_structs.h:346
int32_t apos
Definition: cram_structs.h:402
string_alloc_t * TD_keys
Definition: cram_structs.h:293
Definition: cram_structs.h:737
uint32_t crc32
Definition: cram_structs.h:389
double rans0_extra
Definition: cram_structs.h:240
spare_bams * bl
Definition: cram_structs.h:726
int32_t num_landmarks
Definition: cram_structs.h:275
int method
Definition: cram_structs.h:226
char * fn
Definition: cram_structs.h:584
#define I(x, y, z)
Definition: md5.c:54
int first_base
Definition: cram_structs.h:675
Definition: cram_structs.h:131
cram_container * ctr
Definition: cram_structs.h:672
int32_t rg
Definition: cram_structs.h:403
int start
Definition: cram_structs.h:632
int rans0_cnt
Definition: cram_structs.h:232
Definition: cram_structs.h:307
Definition: cram_structs.h:155
int ooc
Definition: cram_structs.h:729