Skip to content

Commit

Permalink
Add write_custom_filters function so other tools can write SViper hea…
Browse files Browse the repository at this point in the history
…der.
  • Loading branch information
joshuak94 committed Dec 9, 2019
1 parent f29aed8 commit c679a96
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions include/sviper/io.h
Original file line number Diff line number Diff line change
@@ -30,6 +30,21 @@ bool read_vcf(std::vector<Variant> & variants, std::vector<std::string> & vcf_he
return true;
}

void write_custom_filters(std::ofstream & output_vcf)
{
output_vcf << "##FILTER=<ID=FAIL0,Description=\"The fasta index has no entry for the given "
<< "reference name of the variant.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL1,Description=\"No long reads in variant region.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL2,Description=\"No long reads support the variant.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL3,Description=\"The long read regions do not fit.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL4,Description=\"Not enough short reads.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL5,Description=\"The variant was polished away.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL6,Description=\"The variant reference name does not exist in the " <<
"short read BAM file.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL7,Description=\"The variant reference name does not exist in the " <<
"long read BAM file.\">" << std::endl;
}

bool write_vcf(std::vector<Variant> & variants, std::vector<std::string> & vcf_header, input_output_information & info)
{
std::ofstream output_vcf{}; // The polished variant as output
@@ -64,17 +79,7 @@ bool write_vcf(std::vector<Variant> & variants, std::vector<std::string> & vcf_h
}

// write out custom filters
output_vcf << "##FILTER=<ID=FAIL0,Description=\"The fasta index has no entry for the given "
<< "reference name of the variant.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL1,Description=\"No long reads in variant region.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL2,Description=\"No long reads support the variant.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL3,Description=\"The long read regions do not fit.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL4,Description=\"Not enough short reads.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL5,Description=\"The variant was polished away.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL6,Description=\"The variant reference name does not exist in the " <<
"short read BAM file.\">" << std::endl;
output_vcf << "##FILTER=<ID=FAIL7,Description=\"The variant reference name does not exist in the " <<
"long read BAM file.\">" << std::endl;
write_custom_filters(output_vcf);
}

output_vcf << vcf_header[hl] << std::endl;

0 comments on commit c679a96

Please sign in to comment.