Package htsjdk.variant.vcf

Examples of htsjdk.variant.vcf.VCFHeader



        TribbleFeatureSource src = TribbleFeatureSource.getFeatureSource(locator, genome);


        VCFHeader header = (VCFHeader) src.getHeader();

        // Test if the input VCF file contains methylation rate data:

        // This is determined by testing for the presence of two sample format fields: MR and GB, used in the
        // rendering of methylation rate.
        // MR is the methylation rate on a scale of 0 to 100% and GB is the number of bases that pass
        // filter for the position. GB is needed to avoid displaying positions for which limited coverage
        // prevents reliable estimation of methylation rate.
        boolean enableMethylationRateSupport = (header.getFormatHeaderLine("MR") != null &&
                header.getFormatHeaderLine("GB") != null);

        List<String> allSamples = new ArrayList(header.getGenotypeSamples());

        VariantTrack t = new VariantTrack(locator, src, allSamples, enableMethylationRateSupport);

        // VCF tracks handle their own margin
        t.setMargin(0);
View Full Code Here


    private void loadVCFListFile(ResourceLocator locator, List<Track> newTracks, Genome genome) throws IOException, TribbleIndexNotFoundException {

        TribbleListFeatureSource src = new TribbleListFeatureSource(locator.getPath(), genome);

        VCFHeader header = (VCFHeader) src.getHeader();

        // Test if the input VCF file contains methylation rate data:

        // This is determined by testing for the presence of two sample format fields: MR and GB, used in the
        // rendering of methylation rate.
        // MR is the methylation rate on a scale of 0 to 100% and GB is the number of bases that pass
        // filter for the position. GB is needed to avoid displaying positions for which limited coverage
        // prevents reliable estimation of methylation rate.
        boolean enableMethylationRateSupport = (header.getFormatHeaderLine("MR") != null &&
                header.getFormatHeaderLine("GB") != null);

        List<String> allSamples = new ArrayList(header.getGenotypeSamples());

        VariantTrack t = new VariantTrack(locator, src, allSamples, enableMethylationRateSupport);

        // VCF tracks handle their own margin
        t.setMargin(0);
View Full Code Here

    @Test
    public void testWriteHeader() throws Exception {

        FeatureCodec codec = CodecFactory.getCodec(inpath, genome);
        AbstractFeatureReader<Feature, ?> bfs = AbstractFeatureReader.getFeatureReader(inpath, codec, false);
        VCFHeader header0 = (VCFHeader) bfs.getHeader();

        VariantContextWriter writer = getWriter();
        writer.writeHeader(header0);
        writer.close();

        AbstractFeatureReader<Feature, ?> bfs1 = AbstractFeatureReader.getFeatureReader(outFile.getAbsolutePath(), codec, false);
        VCFHeader header1 = (VCFHeader) bfs1.getHeader();

        assertHeadersEquals(header0, header1);
    }
View Full Code Here

        FeatureCodec codec = CodecFactory.getCodec(inpath, genome);
        AbstractFeatureReader<VCFVariant, ?> bfs = AbstractFeatureReader.getFeatureReader(inpath, codec, false);
        Iterable<VCFVariant> iter0 = bfs.iterator();
        List<VCFVariant> list0 = new ArrayList<VCFVariant>();
        VCFHeader header0 = (VCFHeader) bfs.getHeader();

        VariantContextWriter writer = getWriter();
        writer.writeHeader(header0);
        for (VCFVariant var : iter0) {
            writer.add(var.getVariantContext());
            list0.add(var);
        }
        writer.close();

        AbstractFeatureReader<VCFVariant, ?> bfs1 = AbstractFeatureReader.getFeatureReader(outFile.getAbsolutePath(), codec, false);
        Iterable<VCFVariant> iter1 = bfs1.iterator();
        VCFHeader header1 = (VCFHeader) bfs1.getHeader();

        assertHeadersEquals(header0, header1);
        int n = 0;

        for (VCFVariant var1 : iter1) {
View Full Code Here

        String trackName = variantCollection.variants.getName();
        Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList(trackName));
        Map<String, VCFHeader> vcfHeaders = GATKVCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList(trackName));

        Set<VCFHeaderLine> headerLines = vcfHeaders.get(trackName).getMetaDataInSortedOrder();
        baseWriter.writeHeader(new VCFHeader(headerLines, samples));

        writer = VariantContextWriterFactory.sortOnTheFly(baseWriter, 200);
    }
View Full Code Here

                "##FORMAT=<ID=GQ, Number=1, Type=Integer, Description=\"Genotype quality\">\n"+
                "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n";

    private VCFHeader createHeader(String headerStr) {
        VCFCodec codec = new VCFCodec();
        VCFHeader head = null;
        head = (VCFHeader) codec.readActualHeader(codec.makeSourceFromStream(new PositionalBufferedStream(new StringBufferInputStream(headerStr))));
        return head;
    }
View Full Code Here

        return head;
    }

    @Test
    public void testHeadersWithSamplesNamesDuplicationThatIsNotAllowed() {
        VCFHeader one = createHeader(VCF4headerStringsWithSamplesName);
        VCFHeader two = createHeader(VCF4headerStringsWithSamplesName);
        Map<String, VCFHeader> headers = new HashMap<String, VCFHeader>();
        headers.put("VCF4headerStringsWithSamplesName",one);
        headers.put("VCF4headerStringsWithSamplesName2",two);
        Assert.assertEquals(SampleUtils.verifyUniqueSamplesNames(headers),false);
    }
View Full Code Here

        Assert.assertEquals(SampleUtils.verifyUniqueSamplesNames(headers),false);
    }

    @Test
    public void testHeadersWithoutSamplesNamesDuplication() {
        VCFHeader one = createHeader(VCF4headerStringsWithSamplesName);
        VCFHeader two = createHeader(VCF4headerStringsWithUniqueSamplesName);
        Map<String, VCFHeader> headers = new HashMap<String, VCFHeader>();
        headers.put("VCF4headerStringsWithSamplesName",one);
        headers.put("VCF4headerStringsWithSamplesName2",two);
        Assert.assertEquals(SampleUtils.verifyUniqueSamplesNames(headers),true);
    }
View Full Code Here

        Assert.assertEquals(SampleUtils.verifyUniqueSamplesNames(headers),true);
    }

    @Test
    public void testHeadersWhereOneIsAStrictSubsetOfTheOther() {
        VCFHeader one = createHeader(VCF4headerStrings);
        VCFHeader two = createHeader(VCF4headerStringsSmallSubset);
        ArrayList<VCFHeader> headers = new ArrayList<VCFHeader>();
        headers.add(one);
        headers.add(two);
        Set<VCFHeaderLine> lines = VCFUtils.smartMergeHeaders(headers, false);
        Assert.assertEquals(lines.size(), VCF4headerStringCount);
View Full Code Here

        Assert.assertEquals(lines.size(), VCF4headerStringCount);
    }

    @Test(expectedExceptions=IllegalStateException.class)
    public void testHeadersInfoDifferentValues() {
        VCFHeader one = createHeader(VCF4headerStrings);
        VCFHeader two = createHeader(VCF4headerStringsBrokenInfo);
        ArrayList<VCFHeader> headers = new ArrayList<VCFHeader>();
        headers.add(one);
        headers.add(two);
        Set<VCFHeaderLine> lines = VCFUtils.smartMergeHeaders(headers, false);
        Assert.assertEquals(lines.size(), VCF4headerStringCount);
View Full Code Here

TOP

Related Classes of htsjdk.variant.vcf.VCFHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.