-
Notifications
You must be signed in to change notification settings - Fork 9
/
SAM_queue.h
107 lines (81 loc) · 2.18 KB
/
SAM_queue.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
/*
Authors:
Haoyu Cheng
chhy@mail.ustc.edu.cn
*/
#ifndef __SAMQUENUE_
#define __SAMQUENUE_
#include "Auxiliary.h"
#include <sys/queue.h>
#include "Process_Reads.h"
#include <string>
typedef struct element_queue
{
int ele;
}element_queue;
typedef struct Queue
{
Read *qBase;
int front;
int rear; ///rear指向队尾的下一个元素
int output_queue_length;
}QUEUE;
typedef struct
{
char* sVal;
int length;
///std::string stringVal;
} tmp_result_string;
typedef struct SAM_Queue
{
tmp_result_string *qBase;
int front;
int rear; ///rear指向队尾的下一个元素
int output_queue_length;
}SAM_Queue;
struct SINGLE_END_QUEUE{
char* single_location_result_string;
int length;
TAILQ_ENTRY(SINGLE_END_QUEUE) entries;
};
TAILQ_HEAD(HEADER_SINGLE_END_QUEUE, SINGLE_END_QUEUE);
void push_SINGLE_END_QUEUE(struct HEADER_SINGLE_END_QUEUE* header, int* queue_length, char* alignemnt, int alignment_length);
char* pop_all_SINGLE_END_QUEUE(struct HEADER_SINGLE_END_QUEUE* header, int* queue_length, int total_length);
void initQueue(QUEUE *pq, int length);
void enQueue(QUEUE *pq , Read* value);
void deQueue(QUEUE *pq , Read *value);
int if_empty(QUEUE *pq);
int if_full(QUEUE *pq);
inline int if_empty(QUEUE *pq)
{
if (pq->front == pq->rear)
return 1;
else
return 0;
}
inline int if_full(QUEUE *pq)
{
if (pq->front == (pq->rear + 1) % (pq->output_queue_length))
return 1;
else
return 0;
}
inline void enQueue(QUEUE *pq, Read* value)
{
strcpy(pq->qBase[pq->rear].name, value->name);
strcpy(pq->qBase[pq->rear].qual, value->qual);
strcpy(pq->qBase[pq->rear].rseq, value->rseq);
strcpy(pq->qBase[pq->rear].seq, value->seq);
pq->qBase[pq->rear].length = value->length;
pq->rear = (pq->rear + 1) % (pq->output_queue_length);
}
inline void deQueue(QUEUE *pq, Read *value)
{
strcpy(value->name, pq->qBase[pq->front].name);
strcpy(value->qual, pq->qBase[pq->front].qual);
strcpy(value->rseq, pq->qBase[pq->front].rseq);
strcpy(value->seq, pq->qBase[pq->front].seq);
value->length = pq->qBase[pq->front].length;
pq->front = (pq->front + 1) % (pq->output_queue_length);
}
#endif