Package org.broadinstitute.gatk.utils

Examples of org.broadinstitute.gatk.utils.GenomeLoc


                Genotype call = GenotypeBuilder.create(name, genotypeAlleles);

                // add the call to the genotype list, and then use this list to create a VariantContext
                genotypes.add(call);
                alleles.add(refAllele);
                GenomeLoc loc = ref.getGenomeLocParser().createGenomeLoc(geli.getChr(),geli.getStart());
                return new VariantContextBuilder(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles).genotypes(genotypes).log10PError(-1 * geli.getLODBestToReference()).attributes(attributes).make();
            } else
                return null; // can't handle anything else
        }
View Full Code Here


            final GATKBAMIndex index = dataSource.getIndex(reader);
            final GATKBAMIndexData indexData = index.readReferenceSequence(referenceSequence);

            int currentBinInLowestLevel = GATKBAMIndex.getFirstBinInLevel(GATKBAMIndex.getNumIndexLevels()-1);
            Iterator<GenomeLoc> locusIterator = intervals.iterator();
            GenomeLoc currentLocus = locusIterator.next();

            final long readerStartOffset = position();

            int maxChunkCount = 0;

            while(currentBinInLowestLevel < GATKBAMIndex.MAX_BINS && currentLocus != null) {
                final Bin bin = new Bin(referenceSequence,currentBinInLowestLevel);
                final int binStart = index.getFirstLocusInBin(bin);
                final int binStop = index.getLastLocusInBin(bin);

                // In required, pull bin iterator ahead to the point of the next GenomeLoc.
                if(binStop < currentLocus.getStart()) {
                    currentBinInLowestLevel++;
                    continue;
                }

                // At this point, the bin stop is guaranteed to be >= the start of the locus.
                // If the bins have gone past the current locus, update the current locus if at all possible.
                if(binStart > currentLocus.getStop()) {
                    currentLocus = locusIterator.hasNext() ? locusIterator.next() : null;
                    continue;
                }

                // Code at this point knows that the current bin is neither before nor after the current locus,
View Full Code Here

        Shard shard = new MockLocusShard(genomeLocParser,Collections.singletonList(genomeLocParser.createGenomeLoc(sequenceFile.getSequenceDictionary().getSequence(0).getSequenceName(), 1, 50)));

        LocusShardDataProvider dataProvider = new LocusShardDataProvider(shard, null, genomeLocParser, shard.getGenomeLocs().get(0), null, sequenceFile, null);
        LocusReferenceView view = new LocusReferenceView(dataProvider);

        GenomeLoc locus = genomeLocParser.createGenomeLoc(sequenceFile.getSequenceDictionary().getSequence(0).getSequenceName(), 50, 51);

        ReferenceContext rc = view.getReferenceContext(locus);
        Assert.assertTrue(rc.getLocus().equals(locus));
        Assert.assertTrue(rc.getWindow().equals(genomeLocParser.createGenomeLoc(sequenceFile.getSequenceDictionary().getSequence(0).getSequenceName(),50)));
        Assert.assertTrue(rc.getBases().length == 1);
View Full Code Here

        LocusShardDataProvider dataProvider = new LocusShardDataProvider(shard, null, genomeLocParser, loc, null, sequenceFile, null);
        LocusReferenceView view = new LocusReferenceView(dataProvider);

        while (shardIterator.hasNext()) {
            GenomeLoc locus = shardIterator.next();

            ReferenceSequence expectedAsSeq = sequenceFile.getSubsequenceAt(locus.getContig(), locus.getStart(), locus.getStop());
            char expected = Character.toUpperCase(StringUtil.bytesToString(expectedAsSeq.getBases()).charAt(0));
            char actual = view.getReferenceContext(locus).getBaseAsChar();

            Assert.assertEquals(actual, expected, String.format("Value of base at position %s in shard %s does not match expected", locus.toString(), shard.getGenomeLocs())
            );
        }
    }
View Full Code Here

        try {
            for (Shard sh : strat) {
                int readCount = 0;
                count++;

                GenomeLoc firstLocus = sh.getGenomeLocs().get(0), lastLocus = sh.getGenomeLocs().get(sh.getGenomeLocs().size()-1);
                logger.debug("Start : " + firstLocus.getStart() + " stop : " + lastLocus.getStop() + " contig " + firstLocus.getContig());
                logger.debug("count = " + count);
                GATKSAMIterator datum = data.seek(sh);

                // for the first couple of shards make sure we can see the reads
                if (count < 5) {
View Full Code Here

        VCFCodec codec = new VCFCodec();
        TestFeatureReader reader = new TestFeatureReader(file.getAbsolutePath(), codec);
        CheckableCloseableTribbleIterator<Feature> tribbleIterator = reader.query(chr, 1, 100000);
        FeatureToGATKFeatureIterator gatkIterator = new FeatureToGATKFeatureIterator(parser, tribbleIterator, "test");
        Assert.assertTrue(gatkIterator.hasNext(), "GATK feature iterator does not have a next value.");
        GenomeLoc gatkLocation = gatkIterator.next().getLocation();
        Assert.assertEquals(gatkLocation.getContig(), chr, "Instead of chr 20 rod iterator was at location " + gatkLocation);
        Assert.assertFalse(tribbleIterator.isClosed(), "Tribble iterator is closed but should be still open.");
        gatkIterator.close();
        Assert.assertTrue(tribbleIterator.isClosed(), "Tribble iterator is open but should be now closed.");
        reader.close();
    }
View Full Code Here

     * @param resources @{inheritedDoc}
     * @return @{inheritedDoc}
     */
    public LocationAwareSeekableRODIterator selectBestExistingResource( DataStreamSegment segment, List<LocationAwareSeekableRODIterator> resources ) {
        if(segment instanceof MappedStreamSegment) {
            GenomeLoc position = ((MappedStreamSegment)segment).getLocation();

            for( LocationAwareSeekableRODIterator RODIterator : resources ) {

                if( (RODIterator.position() == null && RODIterator.hasNext()) ||
                    (RODIterator.position() != null && RODIterator.position().isBefore(position)) )
View Full Code Here

        return tests.toArray(new Object[][]{});
    }

    @Test(enabled = !DEBUG, dataProvider = "BadReadsTest", expectedExceptions = IllegalArgumentException.class)
    public void testBadReads(final GATKSAMRecord read1, final GATKSAMRecord read2) {
        final GenomeLoc loc = genomeLocParser.createGenomeLoc(read1);
        final ActiveRegion region = new ActiveRegion(loc, null, true, genomeLocParser, 0);
        region.add(read1);
        region.add(read2);
    }
View Full Code Here

    @DataProvider(name = "SplitActiveRegion")
    public Object[][] makeSplitActiveRegion() {
        List<Object[]> tests = new ArrayList<Object[]>();

        final GenomeLoc whole_span = genomeLocParser.createGenomeLoc("20", 1, 500);
        final GenomeLoc gl_before = genomeLocParser.createGenomeLoc("20", 1, 9);
        final GenomeLoc gl_after = genomeLocParser.createGenomeLoc("20", 250, 500);
        final GenomeLoc gl_diff_contig = genomeLocParser.createGenomeLoc("19", 40, 50);

        final int regionStart = 10;
        final int regionStop = 100;
        final GenomeLoc region = genomeLocParser.createGenomeLoc("20", regionStart, regionStop);

        for ( final GenomeLoc noEffect : Arrays.asList(whole_span) )
            tests.add(new Object[]{
                    region,
                    Arrays.asList(noEffect),
View Full Code Here

            final GenomeLocSortedSet intervals = new GenomeLocSortedSet(genomeLocParser,  intervalLocs);
            final List<ActiveRegion> regions = region.splitAndTrimToIntervals(intervals);

            Assert.assertEquals(regions.size(), expectedRegionLocs.size(), "Wrong number of split locations");
            for ( int i = 0; i < expectedRegionLocs.size(); i++ ) {
                final GenomeLoc expected = expectedRegionLocs.get(i);
                final ActiveRegion actual = regions.get(i);
                Assert.assertEquals(actual.getLocation(), expected, "Bad region after split");
                Assert.assertEquals(actual.isActive(), region.isActive());
                Assert.assertEquals(actual.getExtension(), region.getExtension());
            }
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.GenomeLoc

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.