Skip to content

Commit b62d7f1

Browse files
committed
Mappability file is now optional
1 parent 4dc31ce commit b62d7f1

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

likelihood.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,13 @@ void calculate_likelihood_CNV(bam_info *in_bam, parameters *params, svs arr[], i
128128
expected_rd_unfiltered += in_bam->expected_rd_unfiltered[gc_val];
129129
observed_rd_unfiltered += in_bam->rd_unfiltered[i];
130130

131-
mappability_score += in_bam->mappability[i];
131+
if(params->mappability_file != NULL)
132+
mappability_score += in_bam->mappability[i];
132133
}
133134
//fprintf(stderr,"%d - %f ----- %d - %f\n", observed_rd_filtered, expected_rd_filtered, observed_rd_unfiltered, expected_rd_unfiltered);
134135

135-
arr[count].mappability = mappability_score / (double) (arr[count].end - arr[count].start);
136+
if(params->mappability_file != NULL)
137+
arr[count].mappability = mappability_score / (double) (arr[count].end - arr[count].start);
136138

137139
if(!params->no_kmer)
138140
{
@@ -248,11 +250,23 @@ void output_SVs( parameters *params, FILE* fpSVs, FILE* fp_del, FILE* fp_dup)
248250
fprintf(fp_del,"%s\t%d\t%d\t%.1f\t%.2f\t%.2f\t%d\t%.2lf\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].likelihood_kmer, all_svs_del[count].rp, all_svs_del[count].mappability);
249251
//fprintf(fp_del,"%s\t%d\t%d\t%.2lf\t%.2f\t%.2lf\t%d\t%f\t%d\t%f\t%d\t%f\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].likelihood_filtered, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].border_rp, all_svs_del[count].mappability, all_svs_del[count].observed_rd_filtered, all_svs_del[count].expected_rd_filtered, all_svs_del[count].observed_rd_all, all_svs_del[count].expected_rd_all);
250252

251-
if(all_svs_del[count].likelihood_unfiltered < 0.5 && all_svs_del[count].mappability > 0.5 && all_svs_del[count].likelihood_kmer < 10)
253+
if(params->mappability_file != NULL)
252254
{
253-
fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.1f\t%.2f\t%.2f\t%d\t%.2lf\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].likelihood_kmer, all_svs_del[count].rp, all_svs_del[count].mappability);
254-
//fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.2lf\t%.2f\t%.2lf\t%d\t%f\t%d\t%f\t%d\t%f\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].likelihood_filtered, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].border_rp, all_svs_del[count].mappability, all_svs_del[count].observed_rd_filtered, all_svs_del[count].expected_rd_filtered, all_svs_del[count].observed_rd_all, all_svs_del[count].expected_rd_all);
255-
sv_cnt_del++;
255+
if(all_svs_del[count].likelihood_unfiltered < 0.5 && all_svs_del[count].mappability > 0.5 && all_svs_del[count].likelihood_kmer < 10)
256+
{
257+
fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.1f\t%.2f\t%.2f\t%d\t%.2lf\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].likelihood_kmer, all_svs_del[count].rp, all_svs_del[count].mappability);
258+
//fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.2lf\t%.2f\t%.2lf\t%d\t%f\t%d\t%f\t%d\t%f\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].likelihood_filtered, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].border_rp, all_svs_del[count].mappability, all_svs_del[count].observed_rd_filtered, all_svs_del[count].expected_rd_filtered, all_svs_del[count].observed_rd_all, all_svs_del[count].expected_rd_all);
259+
sv_cnt_del++;
260+
}
261+
}
262+
else
263+
{
264+
if(all_svs_del[count].likelihood_unfiltered < 0.5 && all_svs_del[count].likelihood_kmer < 10)
265+
{
266+
fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.1f\t%.2f\t%.2f\t%d\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].likelihood_kmer, all_svs_del[count].rp);
267+
//fprintf(fpSVs,"%s\t%d\t%d\tDEL\t%.2lf\t%.2f\t%.2lf\t%d\t%f\t%d\t%f\t%d\t%f\n", all_svs_del[count].chr_name, all_svs_del[count].start, all_svs_del[count].end, all_svs_del[count].likelihood_filtered, all_svs_del[count].copy_number, all_svs_del[count].likelihood_unfiltered, all_svs_del[count].border_rp, all_svs_del[count].mappability, all_svs_del[count].observed_rd_filtered, all_svs_del[count].expected_rd_filtered, all_svs_del[count].observed_rd_all, all_svs_del[count].expected_rd_all);
268+
sv_cnt_del++;
269+
}
256270
}
257271
}
258272

@@ -358,16 +372,20 @@ void find_SVs( bam_info *in_bam, parameters *params, FILE* fp_del, FILE* fp_dup,
358372

359373
//Check mappability
360374
//fprintf(stderr,"Finding mappability for each region\n");
361-
init_mappability_per_chr( in_bam, params, chr_index);
362-
load_mappability_regions( in_bam, params, chr_name);
375+
if(params->mappability_file != NULL)
376+
{
377+
init_mappability_per_chr( in_bam, params, chr_index);
378+
load_mappability_regions( in_bam, params, chr_name);
379+
}
363380

364381

365382
fprintf(stderr,"\nCalculating Likelihoods\n");
366383
find_depths(in_bam, params, chr_name, chr_index);
367384

368-
//free( in_bam->rd_filtered);
369385
free( in_bam->rd_unfiltered);
370-
free( in_bam->mappability);
386+
387+
if(params->mappability_file != NULL)
388+
free( in_bam->mappability);
371389

372390
if(!params->no_kmer)
373391
{

0 commit comments

Comments
 (0)