-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommon.h
More file actions
136 lines (111 loc) · 3.18 KB
/
common.h
File metadata and controls
136 lines (111 loc) · 3.18 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef __COMMON
#define __COMMON
#include "vector.h"
#include <stdio.h>
#include <htslib/sam.h>
#include <htslib/hts.h>
//#include <zlib.h>
#include <omp.h>
#include "valorconfig.h"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
/* Exit Codes */
#define EXIT_SUCCESS 0
#define EXIT_COMMON 1
#define EXIT_MAXBAMS 2
#define EXIT_PARAM_ERROR 3
#define EXIT_EXTERNAL_PROG_ERROR 4
#define EXIT_FILE_OPEN_ERROR 5
#define EXIT_READGROUP 6
/* Return Codes */
#define RETURN_SUCCESS 0
#define RETURN_ERROR 1
/* STRAND */
#define READ_STRAND_POS 0
#define READ_STRAND_NEG 1
/* Maximum filename length */
#define MAX_LENGTH 1024
/* MAPPING INFO */
#define RPUNMAPPED 0
#define RPCONC 1
#define RPDEL 2
#define RPINV 3
#define RPINS 4
#define RPTDUP 5
#define RPMEI 6
#define RPSEND 7
#define RPPP 8
#define RPMM 9
#define RPTDUPPM 10
#define RPTDUPMP 11
#define RPINTER 12
// Track memory usage
extern long long memUsage;
extern FILE *logFile; //Defined in valor.c
#define SV_MAX_ID 32
typedef enum SV_TYPE{
SV_DELETION = 1,
SV_TANDEM_DUPLICATION = 2,
SV_INVERSION = 4,
SV_DIRECT_DUPLICATION = 8,
SV_INVERTED_DUPLICATION = 16,
SV_TRANSLOCATION = 32,
SV_INVERTED_TRANSLOCATION = 64,
SV_RECIPROCAL=128,
SV_INVERTED_RECIPROCAL=256,
}sv_type;
sv_type atosv(char *str);
const char *sv_type_name(sv_type);
typedef struct _params
{
char* bam_file; /* paths to comma separated input BAM files as a single string before being tokenized */
char* outprefix; /* prefix for the output files */
char *sonic_file;
char *logfile;
sv_type svs_to_find;
unsigned int threads;
int chromosome_count;
int barcode_len; //
int max_frag_size; //
int max_support;
int sample_size;
int min_qual;
int ploidy;
int *chr_copy_count;
double quasi_clique_lambda;
double quasi_clique_gamma;
_Bool filter_gap; //
_Bool filter_satellite; //
_Bool low_mem;
} parameters;
/* Parameter related VALOR functions */
parameters *get_params(void);
parameters *init_params(void);
void free_params(void *);
void print_params( parameters*);
/* FILE opening and error printing functions. For opening regular and BAM/SAM
files safely */
void print_error( char*);
FILE* safe_fopen( char* path, char* mode);
htsFile* safe_hts_open( char* path, char* mode);
/* General BAM processing functions */
int is_proper( int flag);
int is_alt_concordant( int p1, int p2, int flag, char s1, char s2, int min, int max);
int identify_read_alignment( bam1_core_t bam_alignment_core, int min, int max);
char base_as_char( int base_as_int);
char complement_char( char base);
void qual_to_ascii( char* qual);
/* String functions */
void set_str( char **target, char *source); /* Even safer than strncpy */
void reverse_string( char* str);
/* Misc. Utility */
int compare_size_int( const void* p, const void* q);
// Memory allocation/tracking functions
void* getMem( size_t size);
void resizeMem( void **ptr, size_t old_size, size_t new_size);
void freeMem( void* ptr, size_t size);
double getMemUsage();
#define VALOR_LOG(...) fprintf(logFile,__VA_ARGS__)
int what_is_min_cluster_size(sv_type type, int ploidy);
int chr_atoi(char *chromosome);
#endif