1 /* Time-stamp: <2019-09-20 11:32:42 taoliu> 2 3 This code is free software; you can redistribute it and/or modify it 4 under the terms of the BSD License (see the file LICENSE included 5 with the distribution). 6 */ 7 8 #define max(x, y) ((x)>(y)?(x):(y)) 9 #define min(x, y) ((x)>(y)?(y):(x)) 10 #define compare(x, y) ((x)>(y)?1:0) 11 12 /* Equivalent to bedGraph data structure */ 13 struct PosVal { 14 int pos; 15 float value; 16 }; 17 18 /* for comparison between two PosVal arrays */ 19 struct PosValVal { 20 int pos; 21 float value1; 22 float value2; 23 }; 24 25 struct PosVal * single_end_pileup ( int * plus_tags, long l_plus_tags, int * minus_tags, long l_minus_tags, int five_shift, int three_shift, int leftmost_coord, int rightmost_coord, float scale_factor, float baseline_value, long * final_length ); 26 27 struct PosVal * quick_pileup ( int * start_poss, int * end_poss, long length_poss, float scale_factor, float baseline_value, long * final_length ); 28 29 int cmpfunc_simple ( const void * a, const void * b); 30 31 int * fix_coordinates ( int * poss, long l, int leftmost_coord, int rightmost_coord ); 32 33 struct PosVal * max_over_two_pv_array ( struct PosVal * pva1, long l_pva1, struct PosVal * pva2, long l_pva2, long * final_length ); 34 35 struct PosVal * apply_func_two_pv_array ( float (*func)(float, float), struct PosVal * pva1, long l_pva1, struct PosVal * pva2, long l_pva2, long * final_length ); 36 37 struct PosValVal * align_two_pv_array ( struct PosVal * pva1, long l_pva1, struct PosVal * pva2, long l_pva2, long * final_length ); 38 39 void write_pv_array_to_bedGraph ( struct PosVal * pv_array, long l_pv_array, char * chromosome, char * bdgfile, short append ); 40 41 long quick_pileup_simple ( int * ret_poss, float * ret_values, int * start_poss, int * end_poss, long length_poss, float scale_factor, float baseline_value ); 42