-
Notifications
You must be signed in to change notification settings - Fork 9
/
Schema.h
1886 lines (1332 loc) · 44.1 KB
/
Schema.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Authors:
Haoyu Cheng
chhy@mail.ustc.edu.cn
*/
#ifndef __MR_FAST__
#define __MR_FAST__
#include "Process_Reads.h"
#include <ctype.h>
///#include "Levenshtein_Cal.h"
#include <sys/queue.h>
#include <pthread.h>
#include "bwt.h"
#define MAP_CHUNKS 15
#define MAX_CIGAR_SIZE 1000
///这个是字符长度, 现在不用了
#define INIT_READ_LENGTH 155
///这个是uint64_t的长度, 一个uint64_t可以存21个3-bit, 所以这个字符长度是INIT_READ_3_BIT_LENGTH*21
#define INIT_READ_3_BIT_LENGTH 8
#define FORWARD_DUP_MASK 128
#define RC_DUP_MASK 64
#define Check_Space(read, c_length, n_length) if(n_length > c_length) {read = (char*)realloc(read, n_length);c_length = n_length;}
///注意c_length_3_bit是uint64_t的长度
///n_length是char的长度
///所以c_length_3_bit的char长度是c_length_3_bit*21
#define Check_Space_3_Bit(read, c_length_3_bit, n_length) if(n_length > c_length_3_bit * 21) \
{c_length_3_bit = n_length / 21 + (n_length % 21 != 0); \
read = (bitmapper_bs_iter*)realloc(read, c_length_3_bit * sizeof(bitmapper_bs_iter)); }
#define Get_Count(arr, i) (arr[i+1]-arr[i])
/**
A->0
C->1
G->2
T->3
N-4
**/
#define Get_BS_conversion(C_or_G) if (C_or_G == 1)/*C methylation*/\
{\
match = 1;/* 'C';*/\
convert = 3;/* 'T';*/\
rc_match = 2;/* 'G';*/\
rc_convert = 0;/* 'A';*/\
}\
else /*G methylation*/\
{\
match = 2;/* 'G';*/\
convert = 0;/* 'A';*/\
rc_match = 1;/* 'C';*/\
rc_convert = 3;/* 'T';*/\
}
#define POS_MASK 15
#define CONTEXT_MASK 48
extern char char_to_3bit[128];
typedef struct deduplicate_PE
{
uint8_t* forward_bits;
uint8_t* rc_bits;
long long each_site_bits;
long long total_sites;
long long each_site_uint8;
}deduplicate_PE;
inline void init_deduplicate_PE(deduplicate_PE* de, long long each_site_bits, long long total_sites)
{
de->each_site_bits = each_site_bits;
de->total_sites = total_sites;
de->each_site_uint8 = each_site_bits / 8;
if (each_site_bits % 8 != 0)
{
de->each_site_uint8++;
}
de->forward_bits = (uint8_t*)malloc(sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
de->rc_bits = (uint8_t*)malloc(sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
memset(de->forward_bits, 0, sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
memset(de->rc_bits, 0, sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
}
inline void re_init_deduplicate_PE(deduplicate_PE* de)
{
memset(de->forward_bits, 0, sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
memset(de->rc_bits, 0, sizeof(uint8_t)*de->each_site_uint8*de->total_sites);
}
///把i这个位置置1
inline void set_deduplicate_PE_mask(deduplicate_PE* de, uint8_t* read_bits, bitmapper_bs_iter site, bitmapper_bs_iter i)
{
bitmapper_bs_iter offset = i & 7;
uint8_t mask = 1;
mask = mask << offset;
offset = i >> 3;
read_bits[offset + site*de->each_site_uint8] |= mask;
}
///把i这个位置置0
inline void unset_deduplicate_PE_mask(deduplicate_PE* de, uint8_t* read_bits, bitmapper_bs_iter site, bitmapper_bs_iter i)
{
bitmapper_bs_iter offset = i & 7;
uint8_t mask = 254;
mask = mask << offset;
offset = i >> 3;
read_bits[offset + site*de->each_site_uint8] &= mask;
}
///把i这个位置的值返回回来
inline uint8_t get_deduplicate_PE_mask(deduplicate_PE* de, uint8_t* read_bits, bitmapper_bs_iter site, bitmapper_bs_iter i)
{
bitmapper_bs_iter inner_offset = i & 7;
bitmapper_bs_iter offset = i >> 3;
uint8_t mask = 1;
mask = (read_bits[offset + site*de->each_site_uint8] >> inner_offset) & mask;
return mask;
}
typedef struct _rg_name_l
{
char _rg_chrome_name[SEQ_MAX_LENGTH];
bitmapper_bs_iter _rg_chrome_length;
bitmapper_bs_iter start_location;
bitmapper_bs_iter end_location;
}_rg_name_l;
typedef struct seed_votes
{
bitmapper_bs_iter site;
bitmapper_bs_iter vote;
unsigned int err;
///int score;
bitmapper_bs_iter end_site;
}seed_votes;
typedef struct
{
unsigned int hash_key;
unsigned int site;
unsigned int *locs;
unsigned int Cnt;
}Candidate;
typedef struct
{
unsigned int start_offset;
unsigned int start_locs;
int err;
}Result_Read1;
typedef struct
{
unsigned short FLAG;
int readNumber;
unsigned short direction;
unsigned int map_location;
int chmore_number;
char cigar[MAX_CIGAR_SIZE];
unsigned short iVal;
char sVal[MAX_CIGAR_SIZE];
} tmp_result;
typedef struct
{
int flag;
bitmapper_bs_iter origin_site;
bitmapper_bs_iter site;
bitmapper_bs_iter end_site;
int chrome_id;
char cigar[SEQ_MAX_LENGTH];
unsigned int err;
int score;
} map_result;
typedef struct
{
///bitmapper_bs_iter minDistance_pair;
bitmapper_bs_iter maxDistance_pair;
///bitmapper_bs_iter length;
bitmapper_bs_iter genome_cuts;
bitmapper_bs_iter** count;
} pair_distance_count;
typedef struct
{
bitmapper_bs_iter count;
short index;
} pe_distance_info;
typedef struct
{
bitmapper_bs_iter maxDistance_pair;
bitmapper_bs_iter genome_cuts;
pe_distance_info* count;
} pair_distance_result;
inline void init_pe_distance(pair_distance_count* distances, bitmapper_bs_iter minDistance_pair, bitmapper_bs_iter maxDistance_pair)
{
distances->genome_cuts = genome_cuts;
///distances->minDistance_pair = minDistance_pair;
distances->maxDistance_pair = maxDistance_pair;
///distances->length = distances->maxDistance_pair - distances->minDistance_pair + 1;
distances->count = (bitmapper_bs_iter**)malloc(sizeof(bitmapper_bs_iter*)*distances->genome_cuts);
int i;
for (i = 0; i < distances->genome_cuts; i++)
{
///distances->count[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*distances->length);
///这个一定一定要+1
distances->count[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(distances->maxDistance_pair + 1));
///memset(distances->count[i], 0, sizeof(bitmapper_bs_iter)*(distances->length));
///这个一定一定要+1
memset(distances->count[i], 0, sizeof(bitmapper_bs_iter)*(distances->maxDistance_pair + 1));
}
}
typedef struct
{
///这个空间应该是genome_cut+1
bitmapper_bs_iter* cut_index;
bitmapper_bs_iter genome_cut;
bitmapper_bs_iter cut_length;
bitmapper_bs_iter* tmp_index; ///这个就是移位用的
int total_size;
int current_size;
///这四个数组构成一个完整的元素
bitmapper_bs_iter* sites;
uint16_t* r_length;
///uint16_t* r_size;
//char** reads;
uint16_t* r_real_length;
uint16_t* r_size_3_bit;
bitmapper_bs_iter** reads_3_bit;
///下面这四个元素纯粹是用来做swap的暂存变量
bitmapper_bs_iter k_sites;
uint16_t k_r_length;
//uint16_t k_r_size;
//char* k_reads;
uint16_t k_r_real_length;
uint16_t k_r_size_3_bit;
bitmapper_bs_iter* k_reads_3_bit;
}Methylation;
typedef struct
{
///这四个数组构成一个完整的元素
bitmapper_bs_iter* sites;
uint16_t* r_length;
///uint16_t* r_size;
///char** reads;
uint16_t* r_real_length;
uint16_t* r_size_3_bit;
bitmapper_bs_iter** reads_3_bit;
///下面这四个元素纯粹是用来做swap的暂存变量
bitmapper_bs_iter k_sites;
uint16_t k_r_length;
uint16_t k_r_real_length;
///uint16_t k_r_size;
///char* k_reads;
uint16_t k_r_size_3_bit;
bitmapper_bs_iter* k_reads_3_bit;
}Single_Methylation;
typedef struct
{
int total_size;
int current_size;
Single_Methylation R[2];
///这个空间应该是genome_cut+1
bitmapper_bs_iter* cut_index;
bitmapper_bs_iter genome_cut;
bitmapper_bs_iter cut_length;
bitmapper_bs_iter* tmp_index; ///这个就是移位用的
}Pair_Methylation;
typedef struct
{
FILE** files;
char filename[SEQ_MAX_LENGTH];
bitmapper_bs_iter* cut_index;
bitmapper_bs_iter genome_cut;
}Methylation_Output;
struct result_queue{
TAILQ_ENTRY(result_queue) result_tailq;
tmp_result single_result;
};
TAILQ_HEAD(Result_Queue,result_queue);
//struct Result_Queue queue_header; ///queue_header是队列的头部
extern long long mappingCnt[MAX_Thread];
extern long long mappedSeqCnt[MAX_Thread];
extern long long completedSeqCnt[MAX_Thread];
extern Methylation_Output methy_out;
void Prepare_alignment(char* outputFileName, char *genFileName, _rg_name_l *chhy_ih_refGenName, int chhy_refChromeCont, int i_read_format, int is_pairedEnd);
int Map_Single_Seq( int thread_id);
int Map_Single_Seq_pbat(int thread_id);
///void* Map_Single_Seq_split(int thread_id);
void* Map_Single_Seq_split(void* arg);
void* Map_Single_Seq_split_pbat(void* arg);
void* Map_Single_Seq_split_one_by_one(void* arg);
int Map_Single_Seq_muti_thread(int thread_id);
int Map_Single_Seq_pbat_muti_thread(int thread_id);
int Map_Pair_Seq(int thread_id);
void* Map_Pair_Seq_split(void* arg);
int Map_Pair_Seq_muti_thread(int thread_id);
void Prepare_methy(char *genFileName, _rg_name_l *chhy_ih_refGenName, int chhy_refChromeCont);
void get_mapping_informations(long long* number_of_read, long long* number_of_unique_mapped_read,
long long* number_of_ambiguous_mapped_read, long long* number_of_unmapped_read, long long* number_of_mapped_bases,
long long* number_of_mapped_errors);
///下面是我到函数
unsigned int get_total_reads_number();
void open_methy_output(Methylation_Output& methy_out);
inline void correct_read_using_cigar(char* cigar, char* input_read, char* output_read)
{
///这下面是遍历cigar用的
int i = 0;
int cur_i = 0;
///这下面是遍历read用的
///int r_length = 0;
int input_length = 0;
int gap_size = 0;
int convert_length;
int output_length = 0;
while (cigar[i] != '\0')
{
switch (cigar[i]){
case 'M':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
memcpy(output_read + output_length, input_read + input_length, convert_length);
input_length = input_length + convert_length;
output_length = output_length + convert_length;
cur_i = i + 1;
break;
case 'I':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
input_length = input_length + convert_length;
gap_size = gap_size - convert_length;
cur_i = i + 1;
break;
case 'D':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
memset(output_read + output_length, '_', convert_length);
output_length = output_length + convert_length;
gap_size = gap_size + convert_length;
cur_i = i + 1;
break;
}
i++;
}
output_read[output_length] = '\0';
}
inline void correct_read_using_cigar_3_bit(char* cigar, char* input_read,
bitmapper_bs_iter* output_read_3_bit)
{
///这下面是遍历cigar用的
int i = 0;
int cur_i = 0;
///这下面是遍历read用的
///int r_length = 0;
int input_length = 0;
int gap_size = 0;
int convert_length;
int output_length = 0;
int word64_index = 0;
int word64_inner_bit_index = 0;
int inner_i = 0;
bitmapper_bs_iter tmp;
while (cigar[i] != '\0')
{
switch (cigar[i]){
case 'M':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
/******************这里要改***********************/
///memcpy(output_read + output_length, input_read + input_length, convert_length);
for (inner_i = 0; inner_i < convert_length; inner_i++)
{
if (word64_inner_bit_index == 0)
{
output_read_3_bit[word64_index] = 0;
}
tmp = char_to_3bit[input_read[input_length + inner_i]];
tmp = tmp << word64_inner_bit_index * 3;
output_read_3_bit[word64_index] = output_read_3_bit[word64_index] | tmp;
word64_inner_bit_index++;
if (word64_inner_bit_index == 21)
{
word64_inner_bit_index = 0;
word64_index++;
}
}
/******************这里要改***********************/
input_length = input_length + convert_length;
output_length = output_length + convert_length;
cur_i = i + 1;
break;
case 'I':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
input_length = input_length + convert_length;
gap_size = gap_size - convert_length;
cur_i = i + 1;
break;
case 'D':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
/******************这里要改***********************/
///memset(output_read + output_length, '_', convert_length);
for (inner_i = 0; inner_i < convert_length; inner_i++)
{
if (word64_inner_bit_index == 0)
{
output_read_3_bit[word64_index] = 0;
}
tmp = char_to_3bit['N'];
tmp = tmp << word64_inner_bit_index * 3;
output_read_3_bit[word64_index] = output_read_3_bit[word64_index] | tmp;
word64_inner_bit_index++;
if (word64_inner_bit_index == 21)
{
word64_inner_bit_index = 0;
word64_index++;
}
}
/******************这里要改***********************/
output_length = output_length + convert_length;
gap_size = gap_size + convert_length;
cur_i = i + 1;
break;
}
i++;
}
///output_read[output_length] = '\0';
}
inline void correct_read_using_cigar_3_bit_over_lap_length_r2(char* cigar, char* input_read,
bitmapper_bs_iter* output_read_3_bit,
long long min1, long long len1, long long min2, long long len2)
{
///这下面是遍历cigar用的
int i = 0;
int cur_i = 0;
///这下面是遍历read用的
///int r_length = 0;
int input_length = 0;
int gap_size = 0;
int convert_length;
int output_length = 0;
int word64_index = 0;
int word64_inner_bit_index = 0;
int inner_i = 0;
bitmapper_bs_iter tmp;
int is_overlap = 0;
long long min = min1;
long long max = min1 + len1;
if (min1 > min2)
min = min2;
if (min1 + len1 < min2 + len2)
max = min2 + len2;
long long overlap_length = max - min - len1 - len2;
long long region_start2;
int region_length2;
///如果不重叠是正值或者0, 重叠是负值
if (overlap_length < 0)
{
is_overlap = 1;
overlap_length = overlap_length*-1;
if (min1 <= min2)
{
region_start2 = 0;
region_length2 = overlap_length;
}
else if (min1>min2)
{
region_start2 = min1 - min2;
region_length2 = overlap_length;
}
///memset(read2 + region_start2, 'N', region_length2);
}
while (cigar[i] != '\0')
{
switch (cigar[i]){
case 'M':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
/******************这里要改***********************/
///memcpy(output_read + output_length, input_read + input_length, convert_length);
///input_length = input_length + convert_length;
///output_length = output_length + convert_length;
for (inner_i = 0; inner_i < convert_length; inner_i++, output_length++, input_length++)
{
if (word64_inner_bit_index == 0)
{
output_read_3_bit[word64_index] = 0;
}
if (is_overlap && output_length >= region_start2&&output_length<region_start2 + region_length2)
{
tmp = char_to_3bit['N'];
}
else
{
tmp = char_to_3bit[input_read[input_length]];
}
tmp = tmp << word64_inner_bit_index * 3;
output_read_3_bit[word64_index] = output_read_3_bit[word64_index] | tmp;
word64_inner_bit_index++;
if (word64_inner_bit_index == 21)
{
word64_inner_bit_index = 0;
word64_index++;
}
}
/******************这里要改***********************/
cur_i = i + 1;
break;
case 'I':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
input_length = input_length + convert_length;
gap_size = gap_size - convert_length;
cur_i = i + 1;
break;
case 'D':
cigar[i] = '\0';
convert_length = atoi(cigar + cur_i);
/******************这里要改***********************/
///memset(output_read + output_length, '_', convert_length);
for (inner_i = 0; inner_i < convert_length; inner_i++)
{
if (word64_inner_bit_index == 0)
{
output_read_3_bit[word64_index] = 0;
}
tmp = char_to_3bit['N'];
tmp = tmp << word64_inner_bit_index * 3;
output_read_3_bit[word64_index] = output_read_3_bit[word64_index] | tmp;
word64_inner_bit_index++;
if (word64_inner_bit_index == 21)
{
word64_inner_bit_index = 0;
word64_index++;
}
}
/******************这里要改***********************/
output_length = output_length + convert_length;
gap_size = gap_size + convert_length;
cur_i = i + 1;
break;
}
i++;
}
///output_read[output_length] = '\0';
}
inline void init_methylation(Methylation* methy, int size)
{
(*methy).total_size = size;
(*methy).current_size = 0;
(*methy).r_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).sites = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*size);
/******************这里改了********************/
///(*methy).r_size = (uint16_t*)malloc(sizeof(uint16_t)*size);
///(*methy).reads = (char**)malloc(sizeof(char*)*size);
(*methy).r_real_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).r_size_3_bit = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).reads_3_bit = (bitmapper_bs_iter**)malloc(sizeof(bitmapper_bs_iter*)*size);
/******************这里改了********************/
(*methy).genome_cut = genome_cuts;
(*methy).cut_length = cut_length;
(*methy).cut_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
(*methy).tmp_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
int i;
for (i = 0; i < size; i++)
{
/******************这里改了********************/
///(*methy).reads[i] = (char*)malloc(sizeof(char)*INIT_READ_LENGTH);
///(*methy).r_size[i] = INIT_READ_LENGTH;
///(*methy).r_length[i] = 0;
(*methy).reads_3_bit[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*INIT_READ_3_BIT_LENGTH);
(*methy).r_size_3_bit[i] = INIT_READ_3_BIT_LENGTH;
(*methy).r_length[i] = 0;
(*methy).r_real_length[i] = 0;
/******************这里改了********************/
}
memset((*methy).cut_index, 0, sizeof(bitmapper_bs_iter)*((*methy).genome_cut + 1));
}
inline bitmapper_bs_iter get_key_pair_methylation(Pair_Methylation* methy, int i)
{
/**
if ((*methy).R[0].r_length[i] & 32) ///比到正向链
{
return (*methy).R[0].sites[i];
}
else
{
return (*methy).R[1].sites[i];
}
**/
if ((*methy).R[1].sites[i] < (*methy).R[0].sites[i])
{
return (*methy).R[1].sites[i];
}
else
{
return (*methy).R[0].sites[i];
}
}
/**
inline bitmapper_bs_iter get_key_pair_methylation(Pair_Methylation* methy, int i)
{
if ((*methy).R[1].sites[i] < (*methy).R[0].sites[i])
{
(*methy).R[0].k_sites = (*methy).R[0].sites[i];
(*methy).R[0].k_r_length = (*methy).R[0].r_length[i];
(*methy).R[0].k_r_size = (*methy).R[0].r_size[i];
(*methy).R[0].k_reads = (*methy).R[0].reads[i];
(*methy).R[0].sites[i] = (*methy).R[1].sites[i];
(*methy).R[0].r_length[i] = (*methy).R[1].r_length[i];
(*methy).R[0].r_size[i] = (*methy).R[1].r_size[i];
(*methy).R[0].reads[i] = (*methy).R[1].reads[i];
(*methy).R[1].sites[i] = (*methy).R[0].k_sites;
(*methy).R[1].r_length[i] = (*methy).R[0].k_r_length;
(*methy).R[1].r_size[i] = (*methy).R[0].k_r_size;
(*methy).R[1].reads[i] = (*methy).R[0].k_reads;
}
return (*methy).R[0].sites[i];
}
**/
inline void init_pair_methylation(Pair_Methylation* methy, int size)
{
methy->total_size = size;
methy->current_size = 0;
(*methy).genome_cut = genome_cuts;
(*methy).cut_length = cut_length;
(*methy).cut_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
(*methy).tmp_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
memset((*methy).cut_index, 0, sizeof(bitmapper_bs_iter)*((*methy).genome_cut + 1));
/**read1**/
(*methy).R[0].r_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].sites = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*size);
/******************这里改了********************/
/**
(*methy).R[0].r_size = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].reads = (char**)malloc(sizeof(char*)*size);
**/
(*methy).R[0].r_real_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].r_size_3_bit = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].reads_3_bit = (bitmapper_bs_iter**)malloc(sizeof(bitmapper_bs_iter*)*size);
/******************这里改了********************/
int i;
for (i = 0; i < size; i++)
{
/******************这里改了********************/
/**
(*methy).R[0].reads[i] = (char*)malloc(sizeof(char)*INIT_READ_LENGTH);
(*methy).R[0].r_size[i] = INIT_READ_LENGTH;
(*methy).R[0].r_length[i] = 0;
**/
(*methy).R[0].reads_3_bit[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*INIT_READ_3_BIT_LENGTH);
(*methy).R[0].r_size_3_bit[i] = INIT_READ_3_BIT_LENGTH;
(*methy).R[0].r_length[i] = 0;
(*methy).R[0].r_real_length[i] = 0;
/******************这里改了********************/
}
/**read1**/
/**read2**/
(*methy).R[1].r_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[1].sites = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*size);
/******************这里改了********************/
/**
(*methy).R[1].r_size = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[1].reads = (char**)malloc(sizeof(char*)*size);
**/
(*methy).R[1].r_real_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[1].r_size_3_bit = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[1].reads_3_bit = (bitmapper_bs_iter**)malloc(sizeof(bitmapper_bs_iter*)*size);
/******************这里改了********************/
for (i = 0; i < size; i++)
{
/******************这里改了********************/
/**
(*methy).R[1].reads[i] = (char*)malloc(sizeof(char)*INIT_READ_LENGTH);
(*methy).R[1].r_size[i] = INIT_READ_LENGTH;
(*methy).R[1].r_length[i] = 0;
**/
(*methy).R[1].reads_3_bit[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*INIT_READ_3_BIT_LENGTH);
(*methy).R[1].r_size_3_bit[i] = INIT_READ_3_BIT_LENGTH;
(*methy).R[1].r_length[i] = 0;
(*methy).R[1].r_real_length[i] = 0;
/******************这里改了********************/
}
/**read2**/
}
inline void init_single_methylation(Pair_Methylation* methy, int size)
{
methy->total_size = size;
methy->current_size = 0;
(*methy).genome_cut = genome_cuts;
(*methy).cut_length = cut_length;
(*methy).cut_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
(*methy).tmp_index = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*(genome_cuts + 1));
memset((*methy).cut_index, 0, sizeof(bitmapper_bs_iter)*((*methy).genome_cut + 1));
/**read1**/
(*methy).R[0].r_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].sites = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*size);
/******************这里改了********************/
/**
(*methy).R[0].r_size = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].reads = (char**)malloc(sizeof(char*)*size);
**/
(*methy).R[0].r_real_length = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].r_size_3_bit = (uint16_t*)malloc(sizeof(uint16_t)*size);
(*methy).R[0].reads_3_bit = (bitmapper_bs_iter**)malloc(sizeof(bitmapper_bs_iter*)*size);
/******************这里改了********************/
int i;
for (i = 0; i < size; i++)
{
/******************这里改了********************/
/**
(*methy).R[0].reads[i] = (char*)malloc(sizeof(char)*INIT_READ_LENGTH);
(*methy).R[0].r_size[i] = INIT_READ_LENGTH;
(*methy).R[0].r_length[i] = 0;
**/
(*methy).R[0].reads_3_bit[i] = (bitmapper_bs_iter*)malloc(sizeof(bitmapper_bs_iter)*INIT_READ_3_BIT_LENGTH);
(*methy).R[0].r_size_3_bit[i] = INIT_READ_3_BIT_LENGTH;
(*methy).R[0].r_length[i] = 0;
(*methy).R[0].r_real_length[i] = 0;
/******************这里改了********************/
}
/**read1**/
}
/**