+ changed PipelinHeuristic to support new data access functions
[qpalma.git] / cparser / read.h
1 #ifndef __READ_H__
2 #define __READ_H__
3
4 typedef struct read {
5 unsigned long id;
6
7 int chr;
8 char strand;
9 int splitpos;
10 int size;
11 int p_start;
12 int exon_stop;
13 int exon_start;
14 int p_stop;
15 int true_cut;
16
17 char* seq;
18 char* prb;
19 char* cal_prb;
20 char* chastity;
21
22 char* gene_id;
23 } Read;
24
25
26 void init_read(Read *r) {
27 int buffer_size = 64;
28
29 r->id = 0;
30 r->chr = 0;
31 r->strand = '*';
32 r->splitpos = 0;
33 r->size = 0;
34 r->p_start = 0;
35 r->exon_stop = 0;
36 r->exon_start = 0;
37 r->p_stop = 0;
38 r->true_cut = 0;
39
40 r->seq = malloc(sizeof(char)*buffer_size);
41 r->prb = malloc(sizeof(char)*buffer_size);
42 r->cal_prb = malloc(sizeof(char)*buffer_size);
43 r->chastity = malloc(sizeof(char)*buffer_size);
44 r->gene_id = malloc(sizeof(char)*buffer_size);
45 }
46
47
48 Read* read_alloc() {
49 Read* newRead = (Read*) malloc(sizeof(struct read));
50 assert( newRead != NULL );
51
52 init_read(newRead);
53
54 return newRead;
55 }
56
57
58 void free_read(Read* oldRead) {
59 if(oldRead->seq != 0)
60 free(oldRead->seq);
61 if(oldRead->prb != 0)
62 free(oldRead->prb);
63 if(oldRead->cal_prb != 0)
64 free(oldRead->cal_prb);
65 if(oldRead->chastity != 0)
66 free(oldRead->chastity);
67 if(oldRead->gene_id != 0)
68 free(oldRead->gene_id);
69 }
70
71
72 void create_read(Read* newRead, unsigned long id, int chr, char strand, char* seq, int splitpos, int size, char* prb, char* cal_prb, char* chastity, char* gene_id, int p_start, int exon_stop, int exon_start, int p_stop, int true_cut) {
73
74 newRead->id = id;
75 newRead->chr = chr;
76 newRead->strand = strand;
77 newRead->splitpos = splitpos;
78 newRead->size = size;
79
80 newRead->p_start = p_start;
81 newRead->exon_stop = exon_stop;
82 newRead->exon_start = exon_start;
83 newRead->p_stop = p_stop;
84
85 newRead->true_cut = true_cut;
86
87 newRead->seq = malloc(sizeof(char)*strlen(seq));
88 newRead->prb = malloc(sizeof(char)*(size));
89 newRead->cal_prb = malloc(sizeof(char)*(size));
90 newRead->chastity = malloc(sizeof(char)*(size));
91
92 newRead->gene_id = malloc(sizeof(char)*(strlen(gene_id)));
93
94 strncpy(newRead->seq,seq,strlen(seq));
95 strncpy(newRead->prb,prb,size);
96 strncpy(newRead->cal_prb,cal_prb,size);
97 strncpy(newRead->chastity,chastity,size);
98 strncpy(newRead->gene_id,gene_id,strlen(gene_id));
99 }
100
101
102 void print_read(Read* r) {
103
104 const char* read_format = "%lu\t%d\t%c\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\n";
105
106 printf("read has entries:\n");
107 printf(read_format,r->id,r->chr,r->strand,r->seq,r->splitpos,
108 r->size,r->prb,r->cal_prb,r->chastity,r->gene_id,
109 r->p_start,r->exon_stop,r->exon_start,r->p_stop,r->true_cut);
110 }
111
112
113
114 #endif // __READ_H__