コード例 #1
0
ファイル: VCFHeaderUnitTest.java プロジェクト: k-i-t-e/htsjdk
  @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");
  }
コード例 #2
0
ファイル: VCFHeaderUnitTest.java プロジェクト: k-i-t-e/htsjdk
  @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}};
  }
コード例 #3
0
ファイル: VCFHeaderUnitTest.java プロジェクト: k-i-t-e/htsjdk
  @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);
  }
コード例 #4
0
ファイル: VCFHeaderUnitTest.java プロジェクト: k-i-t-e/htsjdk
  @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);
  }
コード例 #5
0
ファイル: VCFHeaderUnitTest.java プロジェクト: k-i-t-e/htsjdk
  @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);
  }