-
Notifications
You must be signed in to change notification settings - Fork 24
/
plugin_min_phred.c
44 lines (35 loc) · 982 Bytes
/
plugin_min_phred.c
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
#include<stdlib.h>
#include<pandaseq-plugin.h>
HELP("Ensure the minimum score of all the output bases is above a certain PHRED value.", "min_phred:value");
VER_INFO("1.0");
static bool check_func(
PandaLogProxy logger,
const panda_result_seq *sequence,
void *user_data) {
size_t it;
(void) logger;
for (it = 0; it < sequence->sequence_length; it++) {
if (panda_result_phred(&sequence->sequence[it]) < *(int *) user_data) {
return false;
}
}
return true;
}
OPEN {
long int value;
char *endptr;
(void) precheck;
if (args == NULL || *args == '\0') {
panda_log_proxy_write_str(logger, "Need a number for a PHRED score.\n");
return false;
}
value = strtol(args, &endptr, 10);
if ((endptr != NULL && *endptr != '\0') || value < 0 || value > 127) {
panda_log_proxy_write_str(logger, "PHRED score must be a number between 0 and 127.\n");
return false;
}
*check = check_func;
*user_data = PANDA_STRUCT_DUP(&value);
*destroy = free;
return true;
}