Esempio n. 1
0
  @Test
  public void testVCFHeaderSerialization() throws Exception {
    final VCFFileReader reader =
        new VCFFileReader(new File("testdata/htsjdk/variant/HiSeq.10000.vcf"), false);
    final VCFHeader originalHeader = reader.getFileHeader();
    reader.close();

    final VCFHeader deserializedHeader = TestUtil.serializeAndDeserialize(originalHeader);

    Assert.assertEquals(
        deserializedHeader.getMetaDataInInputOrder(),
        originalHeader.getMetaDataInInputOrder(),
        "Header metadata does not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getContigLines(),
        originalHeader.getContigLines(),
        "Contig header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getFilterLines(),
        originalHeader.getFilterLines(),
        "Filter header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getFormatHeaderLines(),
        originalHeader.getFormatHeaderLines(),
        "Format header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getIDHeaderLines(),
        originalHeader.getIDHeaderLines(),
        "ID header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getInfoHeaderLines(),
        originalHeader.getInfoHeaderLines(),
        "Info header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getOtherHeaderLines(),
        originalHeader.getOtherHeaderLines(),
        "Other header lines do not match before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getGenotypeSamples(),
        originalHeader.getGenotypeSamples(),
        "Genotype samples not the same before/after serialization");
    Assert.assertEquals(
        deserializedHeader.samplesWereAlreadySorted(),
        originalHeader.samplesWereAlreadySorted(),
        "Sortedness of samples not the same before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getSampleNamesInOrder(),
        originalHeader.getSampleNamesInOrder(),
        "Sorted list of sample names in header not the same before/after serialization");
    Assert.assertEquals(
        deserializedHeader.getSampleNameToOffset(),
        originalHeader.getSampleNameToOffset(),
        "Sample name to offset map not the same before/after serialization");
    Assert.assertEquals(
        deserializedHeader.toString(),
        originalHeader.toString(),
        "String representation of header not the same before/after serialization");
  }
Esempio n. 2
0
  @DataProvider(name = "HiSeqVCFHeaderDataProvider")
  public Object[][] getHiSeqVCFHeaderData() {
    final File vcf = new File("testdata/htsjdk/variant/HiSeq.10000.vcf");
    final VCFFileReader reader = new VCFFileReader(vcf, false);
    final VCFHeader header = reader.getFileHeader();
    reader.close();

    return new Object[][] {{header}};
  }
Esempio n. 3
0
  @Test
  public void testVCFHeaderAddDuplicateContigLine() {
    File input = new File("testdata/htsjdk/variant/ex2.vcf");

    VCFFileReader reader = new VCFFileReader(input, false);
    VCFHeader header = reader.getFileHeader();

    final int numContigLinesBefore = header.getContigLines().size();
    // try to readd the first contig line
    header.addMetaDataLine(header.getContigLines().get(0));
    final int numContigLinesAfter = header.getContigLines().size();

    // assert that we have the same number of contig lines before and after
    Assert.assertEquals(numContigLinesBefore, numContigLinesAfter);
  }
Esempio n. 4
0
  @Test
  public void testVCFHeaderAddDuplicateHeaderLine() {
    File input = new File("testdata/htsjdk/variant/ex2.vcf");

    VCFFileReader reader = new VCFFileReader(input, false);
    VCFHeader header = reader.getFileHeader();

    VCFHeaderLine newHeaderLine = new VCFHeaderLine("key", "value");
    // add this new header line
    header.addMetaDataLine(newHeaderLine);

    final int numHeaderLinesBefore = header.getOtherHeaderLines().size();
    // readd the same header line
    header.addMetaDataLine(newHeaderLine);
    final int numHeaderLinesAfter = header.getOtherHeaderLines().size();

    // assert that we have the same number of other header lines before and after
    Assert.assertEquals(numHeaderLinesBefore, numHeaderLinesAfter);
  }
Esempio n. 5
0
  @Test
  public void testVCFHeaderAddMetaDataLineDoesNotDuplicateContigs() {
    File input = new File("testdata/htsjdk/variant/ex2.vcf");

    VCFFileReader reader = new VCFFileReader(input, false);
    VCFHeader header = reader.getFileHeader();

    final int numContigLinesBefore = header.getContigLines().size();

    VCFInfoHeaderLine newInfoField =
        new VCFInfoHeaderLine(
            "test", VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "test info field");
    header.addMetaDataLine(newInfoField);

    // getting the sequence dictionary was failing due to duplicating contigs in issue #214,
    // we expect this to not throw an exception
    header.getSequenceDictionary();

    final int numContigLinesAfter = header.getContigLines().size();
    // assert that we have the same number of contig lines before and after
    Assert.assertEquals(numContigLinesBefore, numContigLinesAfter);
  }