Skip to content

Commit

Permalink
add cpy count filter
Browse files Browse the repository at this point in the history
  • Loading branch information
njspix committed Jun 14, 2024
1 parent f505a37 commit 24501cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bsconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ int bsconv_func(bam1_t *b, samFile *out, bam_hdr_t *hdr, void *data) {
retn[nt256char_to_nt256int8_table['A']] +
retn[nt256char_to_nt256int8_table['C']] +
retn[nt256char_to_nt256int8_table['T']] > conf->max_cph) tofilter = 1;
if (conf->max_cpy >= 0 &&
retn[nt256char_to_nt256int8_table['C']] +
retn[nt256char_to_nt256int8_table['T']] > conf->max_cph) tofilter = 1;

if (conf->max_cph_frac < 1.0) {
int cph_retn = retn[nt256char_to_nt256int8_table['A']] +
Expand Down Expand Up @@ -199,6 +202,7 @@ static void usage() {
fprintf(stderr, " -a INT Filter: maximum CpA retention [Inf]\n");
fprintf(stderr, " -c INT Filter: maximum CpC retention [Inf]\n");
fprintf(stderr, " -t INT Filter: maximum CpT retention [Inf]\n");
fprintf(stderr, " -x INT Filter: maximum CpY retention [Inf]\n");
fprintf(stderr, " -p Print in tab-separated format, print order:\n");
fprintf(stderr, " CpA_R, CpA_C, CpC_R, CpC_C, CpG_R, CpG_C, CpT_R, CpT_C\n");
fprintf(stderr, " -v Show filtered reads instead of remaining reads\n");
Expand All @@ -210,7 +214,7 @@ int main_bsconv(int argc, char *argv[]) {
int c;
char *reg = 0; // target region
bsconv_conf_t conf = {0};
conf.max_cph = conf.max_cpa = conf.max_cpc = conf.max_cpt = -1;
conf.max_cph = conf.max_cpa = conf.max_cpc = conf.max_cpt = conf.max_cpy = -1;
conf.max_cph_frac = 1.0;
conf.max_cpy_frac = 1.0;
conf.print_in_tab = 0;
Expand All @@ -222,6 +226,7 @@ int main_bsconv(int argc, char *argv[]) {
case 'g': reg = optarg; break;
case 'm': conf.max_cph = atoi(optarg); break;
case 'f': conf.max_cph_frac = atof(optarg); break;
case 'x': conf.max_cpy = atoi(optarg); break;
case 'y': conf.max_cpy_frac = atof(optarg); break;
case 'a': conf.max_cpa = atoi(optarg); break;
case 'c': conf.max_cpc = atoi(optarg); break;
Expand Down
1 change: 1 addition & 0 deletions src/bsconv.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef struct {
int max_cpa;
int max_cpc;
int max_cpt;
int max_cpy;
int filter_u;
int show_filtered;
int print_in_tab;
Expand Down

0 comments on commit 24501cf

Please sign in to comment.