From 55c05b07668010378a22e3881f7df81415ac4f32 Mon Sep 17 00:00:00 2001 From: Georgi Tushev Date: Thu, 8 Sep 2016 00:11:54 +0200 Subject: [PATCH] add MAPQ filter settings --- config.c | 17 +++++++++++++---- config.h | 4 +++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index c7499a2..1d5840d 100644 --- a/config.c +++ b/config.c @@ -11,7 +11,7 @@ const char VERSION[] = "v0.01"; const char PROGRAM_NAME[] = "FastPASSFinder"; -int parseSettings(int argc, char *argv[], Settings *config) +int parseSettings(int argc, const char *argv[], Settings *config) { // initialize default values config->input = NULL; @@ -20,6 +20,7 @@ int parseSettings(int argc, char *argv[], Settings *config) config->window = DEFAULT_WINDOW; config->depth = DEFAULT_DEPTH; config->sizepoly = DEFAULT_SIZEPOLY; + config->mapq = DEFAULT_MAPQ; if(argc < 5) { @@ -44,6 +45,17 @@ int parseSettings(int argc, char *argv[], Settings *config) { version(); } + else if((PARAMETER_CHECK("-q", 2, parameterLength)) || (PARAMETER_CHECK("--mapq", 6, parameterLength))) + { + i += 1; + config->mapq = strtol(argv[i], NULL, 10); + + if (config->mapq < 0) + { + fprintf(stderr, "Error:: MAPQ should be >=0!\n"); + return EXIT_FAILURE; + } + } else if((PARAMETER_CHECK("-w", 2, parameterLength)) || (PARAMETER_CHECK("--window", 8, parameterLength))) { i += 1; @@ -85,7 +97,6 @@ int parseSettings(int argc, char *argv[], Settings *config) (PARAMETER_CHECK("--input", 7, parameterLength))) { i += 1; - config->input = argv[i]; if (config->input == NULL) @@ -98,7 +109,6 @@ int parseSettings(int argc, char *argv[], Settings *config) (PARAMETER_CHECK("--maskpoly", 10, parameterLength))) { i += 1; - config->maskpoly = argv[i]; if (config->maskpoly == NULL) @@ -112,7 +122,6 @@ int parseSettings(int argc, char *argv[], Settings *config) (PARAMETER_CHECK("--output", 8, parameterLength))) { i += 1; - config->output = argv[i]; if (config->output == NULL) diff --git a/config.h b/config.h index d0c0b8c..42e5498 100644 --- a/config.h +++ b/config.h @@ -18,6 +18,7 @@ #define DEFAULT_WINDOW 200 #define DEFAULT_DEPTH 5 #define DEFAULT_SIZEPOLY 3 +#define DEFAULT_MAPQ 0 // define MIN & MAX macros #define MIN(a,b) (((a)<(b))?(a):(b)) @@ -36,11 +37,12 @@ typedef struct _Settings int64_t window; int64_t depth; int64_t sizepoly; + int64_t mapq; } Settings; // function declarations int chompNewLine(char *); -int parseSettings(int, char **, Settings *); +int parseSettings(int, const char **, Settings *); int help(void); int version(void);