annotate rDiff/mex/read.h @ 2:233c30f91d66

updated python based GFF parsing module which will handle GTF/GFF/GFF3 file types
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 07:15:44 -0400
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 /*
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 * the Free Software Foundation; either version 3 of the License, or
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 * (at your option) any later version.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 *
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 * Written (W) 2010-2011 Jonas Behr, Regina Bohnert, Gunnar Raetsch
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 * Copyright (C) 2010-2011 Max Planck Society
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 #ifndef __READ_H__
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13 #define __READ_H__
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 #include <stdint.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 #include <cctype>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17 #include <stdio.h>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 #include <vector>
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 using std::vector;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 class CRead {
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 public:
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 /** constructor
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25 */
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 CRead();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 ~CRead();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
28
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
29 vector<int> block_starts;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
30 vector<int> block_lengths;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
31 char* read_id;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
32 char* sam_line;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
33 int start_pos;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
34 char * strand;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
35 int matches;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
36 int mismatches;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
37 int multiple_alignment_index;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
38 bool left;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
39 bool right;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
40 bool reverse;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
41
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
42 void get_coverage(int p_start_pos, int p_end_pos, uint32_t* coverage);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
43 int get_last_position();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
44 void get_reads_sparse(int p_start_pos, int p_end_pos, double* reads, uint32_t & reads_c, uint32_t row_idx);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
45 void get_introns(vector<int>* introns);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
46 void get_introns(vector<uint32_t>* intron_starts, vector<uint32_t>* intron_ends, vector<uint32_t>* block_len1, vector<uint32_t>* block_len2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
47 void get_acc_splice_sites(vector<int>* acc_pos);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
48 void get_don_splice_sites(vector<int>* acc_pos);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
49 int max_intron_len();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
50 int min_exon_len();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
51 bool operator==(const CRead& read) const;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
52 void print();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
53 void set_strand(char s);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
54 int get_mismatches();
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
55 static bool compare_by_read_id(const CRead* read1, const CRead* read2)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
56 {
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
57 if (!read1->read_id)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
58 return true;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
59 if (!read2->read_id)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
60 return false;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
61
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
62 int cnt1=0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
63 while (read1->read_id[cnt1]!='\0')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
64 cnt1++;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
65 int cnt2 = 0;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
66 while (read2->read_id[cnt2]!='\0')
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
67 cnt2++;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
68
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
69 return std::lexicographical_compare(read1->read_id,read1->read_id+cnt1,read2->read_id,read2->read_id+cnt2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
70 };
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
71 };
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
72 #endif