Package htsjdk.variant.variantcontext

Examples of htsjdk.variant.variantcontext.VariantContext



        Iterator<VariantContext> iter = bfr.query(chr, start, end);
        int count = 0;
        while (iter.hasNext()) {
            VariantContext feat = iter.next();
            int expStart = expectedStarts[count];
            assertEquals(expStart, feat.getStart());
            count++;
        }

        Assert.assertEquals(15, count);
View Full Code Here


        AbstractFeatureReader bfr = AbstractFeatureReader.getFeatureReader(testFile, codec);
        Iterator<VariantContext> iter = bfr.query(chr, start, end);
        int count = 0;
        while (iter.hasNext()) {
            VariantContext feat = iter.next();
            int expStart = expectedStarts[count];
            assertEquals(expStart, feat.getStart());
            count++;
        }
        Assert.assertEquals(15, count);
    }
View Full Code Here

    public void setUp() throws Exception {
        super.setUp();
        VariantContextBuilder builder = new VariantContextBuilder();
        //Convert from exclusive end to inclusive end
        builder.start(start + 1).stop(end).chr(chr).alleles(alleles);
        VariantContext vc = builder.make();
        mvc = VariantReviewSource.createMVC(allele0, allele1, callsetName, vc, truthStatus, false);

        int errorsResetting = 0;
        try {
            errorsResetting = resetDB();
View Full Code Here

        this.genome = genome;
    }

    @Override
    public VCFVariant decode(PositionalBufferedStream stream) throws IOException {
        VariantContext vc = wrappedCodec.decode(stream);
        if (vc == null) {
            return null;
        }
        String chr = genome == null ? vc.getChr() : genome.getChromosomeAlias(vc.getChr());
        return new VCFVariant(vc, chr);

    }
View Full Code Here

    public VCFVariant decode(String line) {
        // VCFCodec supports completely missing fields (which would simply have a ".")
        // but does not currently support missing only certain elements of a field.
        // IGV is much more permissive.

        VariantContext vc = null;
        try {
            vc = (VariantContext) wrappedCodec.decode(line);
            //The genotype fields are loaded lazily, we force parsing here to
            //catch the exception if necessary
            if (vc != null) vc.getSampleNames();
        } catch (NumberFormatException e) {
            String msg = String.format("NumberFormatException on line: %s \n Attempting to reformat by replacing ,., with ,0,", line);
            log.warn(msg);
            String refLine = line.replaceAll(",\\.", ",0");
            refLine = refLine.replaceAll("\\.,", "0,");
            vc = (VariantContext) wrappedCodec.decode(refLine);
        }


        if (vc == null) {
            return null;
        }
        String chr = genome == null ? vc.getChr() : genome.getChromosomeAlias(vc.getChr());
        return new VCFVariant(vc, chr);

    }
View Full Code Here

                final String dbSpecPath = trackLocator.getPath();
                JMenuItem addReviewMenuItem = new JMenuItem("Submit Review to " + dbName);
                addReviewMenuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        VariantContext vc = VCFVariant.getVariantContext(variant);
                        (new VariantReviewDialog(IGV.getMainFrame(), vc, dbSpecPath)).setVisible(true);
                    }
                });
                addReviewMenuItem.setEnabled(variant != null);
                return addReviewMenuItem;
View Full Code Here

            Iterator<VariantContext> iter = basicReader.iterator();

            while (iter.hasNext()) {

                VariantContext vc = iter.next();
                String chr = vc.getChr();
                if (!chr.startsWith("chr")) {
                    chr = "chr" + chr;
                }

                int start = vc.getStart() - 1;
                int end = vc.getEnd();
                String id = vc.getID();
                if(id == null) {
                    id = ".";
                }
                String af = vc.getAttributeAsString("AF", "");

                writer.println(chr + "\t" + start + "\t" + end + "\t" + id + "\t" + af);

            }
        }
View Full Code Here

        // For some reason RodWalkers get map calls with null trackers
        if( tracker == null )
            return counter;

        VariantContext vcComp = tracker.getFirstValue(alleles);
        if( vcComp == null )
            return counter;

        //todo - not sure I want this, may be misleading to filter extended indel events.
        if (isInsideExtendedIndel(vcComp,  ref))
            return counter;

        // Do not operate on variants that are not covered to the optional minimum depth
        if (!context.hasReads() || (minDepth > 0 && context.getBasePileup().getBases().length < minDepth)) {
            counter.nUncovered = 1L;
            final GVstatus status = getGVstatus(vcComp);
            if ( status == GVstatus.T )
                counter.nAltNotCalled = 1L;
            else if ( status == GVstatus.F )
                counter.nRefNotCalled = 1L;
            else
                counter.nNoStatusNotCalled = 1L;

            return counter;
        }

        VariantCallContext call;
        if ( vcComp.isSNP() ) {
            call = snpEngine.calculateLikelihoodsAndGenotypes(tracker, ref, context).get(0);
        } else if ( vcComp.isIndel() ) {
            call = indelEngine.calculateLikelihoodsAndGenotypes(tracker, ref, context).get(0);
        } else if ( bamIsTruth ) {
            // assume it's a SNP if no variation is present; this is necessary so that we can test supposed monomorphic sites against the truth bam
            call = snpEngine.calculateLikelihoodsAndGenotypes(tracker, ref, context).get(0);
        } else {
            logger.info("Not SNP or INDEL " + vcComp.getChr() + ":" + vcComp.getStart() + " " + vcComp.getAlleles());
            return counter;
        }


        boolean writeVariant = true;

        if (bamIsTruth) {
            if (call.confidentlyCalled) {
                // If truth is a confident REF call
                if (call.isVariant()) {
                    if (vcComp.isVariant())
                        counter.nAltCalledAlt = 1L;
                    else {
                        counter.nAltCalledRef = 1L;
                        if ( printInterestingSites )
                            System.out.println("Truth=ALT Call=REF at " + call.getChr() + ":" + call.getStart());
                    }
                }
                // If truth is a confident ALT call
                else {
                    if (vcComp.isVariant()) {
                        counter.nRefCalledAlt = 1L;
                        if ( printInterestingSites )
                            System.out.println("Truth=REF Call=ALT at " + call.getChr() + ":" + call.getStart());
                    } else
                        counter.nRefCalledRef = 1L;
                }
            }
            else {
                counter.nNotConfidentCalls = 1L;
                if ( printInterestingSites )
                    System.out.println("Truth is not confident at " + call.getChr() + ":" + call.getStart());
                writeVariant = false;
            }
        }
        else {
//            if (!vcComp.hasExtendedAttribute("GV"))
//                throw new UserException.BadInput("Variant has no GV annotation in the INFO field. " + vcComp.getChr() + ":" + vcComp.getStart());

            final GVstatus status = getGVstatus(vcComp);
            if (call.isCalledAlt(callConf)) {
                if ( status == GVstatus.T )
                    counter.nAltCalledAlt = 1L;
                else if ( status == GVstatus.F ) {
                    counter.nRefCalledAlt = 1L;
                    if ( printInterestingSites )
                        System.out.println("Truth=REF Call=ALT at " + call.getChr() + ":" + call.getStart());
                }
                else
                    counter.nNoStatusCalledAlt = 1L;
            }
            else if (call.isCalledRef(callConf)) {
                if ( status == GVstatus.T ) {
                    counter.nAltCalledRef = 1L;
                    if ( printInterestingSites )
                        System.out.println("Truth=ALT Call=REF at " + call.getChr() + ":" + call.getStart());
                }
                else if ( status == GVstatus.F )
                    counter.nRefCalledRef = 1L;

                else
                    counter.nNoStatusCalledRef = 1L;
            }
            else {
                counter.nNotConfidentCalls = 1L;
                if ( status == GVstatus.T )
                    counter.nAltNotCalled = 1L;
                else if ( status == GVstatus.F )
                    counter.nRefNotCalled = 1L;
                else
                    counter.nNoStatusNotCalled = 1L;

                if ( printInterestingSites )
                    System.out.println("Truth is not confident at " + call.getChr() + ":" + call.getStart());
                writeVariant = false;
            }
        }

        if (vcfWriter != null && writeVariant) {
            if (!vcComp.hasAttribute("callStatus")) {
                vcfWriter.add(new VariantContextBuilder(vcComp).attribute("callStatus", call.isCalledAlt(callConf) ? "ALT" : "REF").make());
            }
            else
                vcfWriter.add(vcComp);
        }
View Full Code Here

            // otherwise, reset to non-relevant
            nextAvailableStart = -1;
            contigOfNextAvailableStart = null;
        }

        final VariantContext result;
        if (genotypeCanBeMergedInCurrentBlock(g)) {
            currentBlock.add(vc.getStart(), g);
            result = null;
        } else {
            result = blockToVCF(currentBlock);
View Full Code Here

            }

            final Genotype g = vc.getGenotype(0);
            if ( g.isHomRef() && vc.hasAlternateAllele(GATKVariantContextUtils.NON_REF_SYMBOLIC_ALLELE) && vc.isBiallelic() ) {
                // create bands
                final VariantContext maybeCompletedBand = addHomRefSite(vc, g);
                if ( maybeCompletedBand != null ) underlyingWriter.add(maybeCompletedBand);
            } else {
                // g is variant, so flush the bands and emit vc
                emitCurrentBlock();
                nextAvailableStart = vc.getEnd();
View Full Code Here

TOP

Related Classes of htsjdk.variant.variantcontext.VariantContext

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.