| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,56 @@ |
| 1 |
+#ifndef DATA_TYPES_H |
|
| 2 |
+#define DATA_TYPES_H |
|
| 3 |
+ |
|
| 4 |
+#include <Rcpp.h> |
|
| 5 |
+using namespace Rcpp; |
|
| 6 |
+ |
|
| 7 |
+using namespace std; |
|
| 8 |
+ |
|
| 9 |
+// |
|
| 10 |
+// definitions of data types |
|
| 11 |
+// |
|
| 12 |
+typedef map<string, vector<unsigned int> > Bins_end_coord; // a map: chr -> a vector of end coordinate of each bin. coordinate is 1-base |
|
| 13 |
+typedef map<string, vector<int> > Bins_index; // a map: chr -> a vector of bin index. Note some bins are void/complementary, so their indexes are 0 |
|
| 14 |
+typedef map<string, vector<string> > Bins_info; // a map: chr -> a vector of bins' info. Each bin's info is a string |
|
| 15 |
+ |
|
| 16 |
+typedef map<string, map<int,map<int,double> > > Wig_bins_data; // chr -> (bin_internal_index -> (position -> value)). This is a three-layer map |
|
| 17 |
+ |
|
| 18 |
+typedef unsigned int GENOME_POSITION; |
|
| 19 |
+ |
|
| 20 |
+// Bins2Values: a map for bin_index -> a vector of value. bin_index is always 1-base |
|
| 21 |
+typedef map<int, vector<double> > Bins2Values; |
|
| 22 |
+typedef map<int, vector<unsigned int> > Bins2UnsignedIntegers; |
|
| 23 |
+ |
|
| 24 |
+// Bins2PairedValues: a map for bin_index -> two vectors of values. bin_index is always 1-base |
|
| 25 |
+typedef map<int, pair<vector<double>,vector<double> > > Bins2PairedValues; |
|
| 26 |
+ |
|
| 27 |
+// Bins2PositionValuePairs: a map for bin_index -> a pair of (position vector, value vector). bin_index is always 1-base |
|
| 28 |
+typedef map<unsigned int, pair<vector<GENOME_POSITION>,vector<double> > > Bins2PositionValuePairs; |
|
| 29 |
+ |
|
| 30 |
+// Bins2Value: a map of bin_index -> a value. bin_index is always 1-base |
|
| 31 |
+typedef map<int, double> Bins2Value; |
|
| 32 |
+ |
|
| 33 |
+// |
|
| 34 |
+// functions for these data types |
|
| 35 |
+// |
|
| 36 |
+void read_bins_annot_file(string input_bins_annot_file, Bins_end_coord & bins_end_coord, |
|
| 37 |
+ Bins_index & bins_index, Bins_info & bins_info, bool has_header_line); |
|
| 38 |
+int get_num_of_non_void_bins(Bins_index & bins_index, vector<int> & returned_markers_index); |
|
| 39 |
+int find_exact_bin(Bins_end_coord & bins_end_coord, string chr, unsigned int bin_start_coord, unsigned int bin_end_coord); |
|
| 40 |
+int find_bin_of_position(Bins_end_coord & bins_end_coord, string chr, unsigned int position); |
|
| 41 |
+int find_overlap_bin(Bins_end_coord & bins_end_coord, string query_region_chr, unsigned int query_region_start_coord, |
|
| 42 |
+ unsigned int query_region_end_coord, int & overlap_length); |
|
| 43 |
+void print_bins( ostream& os, Bins_end_coord & bins_end_coord, Bins_index & bins_index, Bins_info & bins_info); |
|
| 44 |
+ |
|
| 45 |
+void create_Bins2Values(int num_bins, int num_of_values, double init_value, Bins2Values & bins2values); |
|
| 46 |
+void create_Bins2Values(vector<int> markers_index, int num_of_values, double init_value, Bins2Values & bins2values); |
|
| 47 |
+void write_Bins2Values(Bins2Values & bins2values, vector<string> & columns_names, string output_file, bool optional_write=false); |
|
| 48 |
+void print_Bins2Values(Bins2Values & bins2values); |
|
| 49 |
+void print_Bins2UnsignedIntegers(Bins2UnsignedIntegers& bins2values); |
|
| 50 |
+ |
|
| 51 |
+void create_Bins2Value(int num_bins, double init_value, Bins2Value & bins2value); |
|
| 52 |
+ostream& operator<<(ostream& out, Bins2Value& bins2value); |
|
| 53 |
+void write_Bins2Value(Bins2Value & bins2value, string output_file); |
|
| 54 |
+ |
|
| 55 |
+#endif |
|
| 56 |
+ |