Skip to content

Commit

Permalink
Added test cases for missing meta-data of reference and contig
Browse files Browse the repository at this point in the history
  • Loading branch information
srbcheema1 committed Apr 6, 2018
1 parent 1dd5910 commit 49624f6
Showing 1 changed file with 76 additions and 4 deletions.
80 changes: 76 additions & 4 deletions test/vcf/optional_policy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,79 @@ namespace ebi

TEST_CASE("Meta-data warnings", "[warnings]")
{
SECTION("Reference not in meta section")
{
std::shared_ptr<vcf::Source> source{
new vcf::Source{
"Example VCF source",
vcf::InputFormat::VCF_FILE_VCF | vcf::InputFormat::VCF_FILE_BGZIP,
vcf::Version::v43}};

vcf::ParsingState parsing_state{source};

vcf::ValidateOptionalPolicy optional_policy;

CHECK_THROWS_AS( (optional_policy.optional_check_meta_section(parsing_state)), vcf::MetaSectionError*);
}

SECTION("Contig not in meta section")
{
std::shared_ptr<vcf::Source> source{
new vcf::Source{
"Example VCF source",
vcf::InputFormat::VCF_FILE_VCF | vcf::InputFormat::VCF_FILE_BGZIP,
vcf::Version::v43}};

source->meta_entries.emplace(vcf::REFERENCE,
vcf::MetaEntry{
1,
vcf::REFERENCE,
"file",
source
});

source->meta_entries.emplace(vcf::CONTIG,
vcf::MetaEntry{
1,
vcf::CONTIG,
{ { vcf::ID, "chr1" } },
source
});

vcf::ParsingState parsing_state{source};

vcf::ValidateOptionalPolicy optional_policy;

CHECK_NOTHROW( (optional_policy.optional_check_body_entry(parsing_state, vcf::Record{
1,
"chr1",
123456,
{ vcf::MISSING_VALUE },
"A",
{ "AC" },
1.0,
{ vcf::PASS },
{ { vcf::MISSING_VALUE, "" } },
{ },
{ },
source})) );

CHECK_THROWS_AS( (optional_policy.optional_check_body_entry(parsing_state, vcf::Record{
1,
"chr2",
123456,
{ vcf::MISSING_VALUE },
"A",
{ "AC" },
1.0,
{ vcf::PASS },
{ { vcf::MISSING_VALUE, "" } },
{ },
{ },
source})),
vcf::NoMetaDefinitionError*);
}

SECTION("Alternate Allele not in meta section")
{
std::shared_ptr<vcf::Source> source{
Expand Down Expand Up @@ -435,7 +508,7 @@ namespace ebi
1,
"chr1",
123456,
{ vcf::PASS },
{ vcf::MISSING_VALUE },
"A",
{ "AC" },
1.0,
Expand All @@ -453,7 +526,7 @@ namespace ebi
"A",
{ "<DEL>" },
1.0,
{ vcf::MISSING_VALUE },
{ vcf::PASS },
{ { vcf::MISSING_VALUE, "" } },
{ },
{ },
Expand All @@ -467,13 +540,12 @@ namespace ebi
"A",
{ "<INS>" },
1.0,
{ "q10" },
{ vcf::PASS },
{ { vcf::MISSING_VALUE, "" } },
{ },
{ },
source})),
vcf::NoMetaDefinitionError*);

}

SECTION("FILTER not in meta section")
Expand Down

0 comments on commit 49624f6

Please sign in to comment.