Search in sources :

Example 11 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc in project gatk by broadinstitute.

the class OverhangFixingManager method fixSplit.

/**
     * Try to fix the given splitRead using the given split
     *
     * @param splitRead        the splitRead to fix
     * @param splice      the split (bad region to clip out)
     */
void fixSplit(final SplitRead splitRead, final Splice splice) {
    // if the splitRead doesn't even overlap the split position then we can just exit
    if (splitRead.unclippedLoc == null || !splice.loc.overlapsP(splitRead.unclippedLoc)) {
        return;
    }
    // if processSecondaryReads == false, filter out clipping of secondary alignments
    if (!processSecondaryReads && splitRead.read.isSecondaryAlignment()) {
        return;
    }
    GenomeLoc readLoc = splitRead.unclippedLoc;
    GATKRead read = splitRead.read;
    final int readReferenceLength = read.getEnd() - read.getStart() + 1;
    if (isLeftOverhang(readLoc, splice.loc)) {
        final int overhang = splice.loc.getStop() - read.getStart() + 1;
        if (overhangingBasesMismatch(read.getBases(), read.getStart() - readLoc.getStart(), readReferenceLength, splice.reference, splice.reference.length - overhang, overhang)) {
            final GATKRead clippedRead = ReadClipper.softClipByReadCoordinates(read, 0, splice.loc.getStop() - readLoc.getStart());
            splitRead.setRead(clippedRead);
        }
    } else if (isRightOverhang(readLoc, splice.loc)) {
        final int overhang = readLoc.getStop() - splice.loc.getStart() + 1;
        if (overhangingBasesMismatch(read.getBases(), read.getLength() - overhang, readReferenceLength, splice.reference, 0, read.getEnd() - splice.loc.getStart() + 1)) {
            final GATKRead clippedRead = ReadClipper.softClipByReadCoordinates(read, read.getLength() - overhang, read.getLength() - 1);
            splitRead.setRead(clippedRead);
        }
    }
}
Also used : GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc)

Example 12 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc in project gatk by broadinstitute.

the class EventMapUnitTest method testAdjacentSNPIndelTest.

/**
     * Example testng test using MyDataProvider
     */
@Test(dataProvider = "AdjacentSNPIndelTest")
public void testAdjacentSNPIndelTest(final String refBases, final String haplotypeBases, final String cigar, final List<List<String>> expectedAlleles) {
    final Haplotype hap = new Haplotype(haplotypeBases.getBytes(), false, 0, TextCigarCodec.decode(cigar));
    final GenomeLoc loc = new UnvalidatingGenomeLoc(CHR, 0, 1, refBases.length());
    final EventMap ee = new EventMap(hap, refBases.getBytes(), loc, NAME);
    ee.replaceClumpedEventsWithBlockSubstitutions();
    Assert.assertEquals(ee.getNumberOfEvents(), expectedAlleles.size());
    final List<VariantContext> actuals = new ArrayList<>(ee.getVariantContexts());
    for (int i = 0; i < ee.getNumberOfEvents(); i++) {
        final VariantContext actual = actuals.get(i);
        Assert.assertEquals(actual.getReference().getDisplayString(), expectedAlleles.get(i).get(0));
        Assert.assertEquals(actual.getAlternateAllele(0).getDisplayString(), expectedAlleles.get(i).get(1));
    }
}
Also used : UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) VariantContext(htsjdk.variant.variantcontext.VariantContext) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 13 with GenomeLoc

use of org.broadinstitute.hellbender.utils.GenomeLoc in project gatk by broadinstitute.

the class HaplotypeUnitTest method makeTrimmingData.

@DataProvider(name = "TrimmingData")
public Object[][] makeTrimmingData() {
    List<Object[]> tests = new ArrayList<>();
    // this functionality can be adapted to provide input data for whatever you might want in your data
    final GenomeLoc loc = new UnvalidatingGenomeLoc("20", 0, 10, 20);
    final String fullBases = "ACGTAACCGGT";
    for (int trimStart = loc.getStart(); trimStart < loc.getStop(); trimStart++) {
        for (int trimStop = trimStart; trimStop <= loc.getStop(); trimStop++) {
            final int start = trimStart - loc.getStart();
            final int stop = start + (trimStop - trimStart) + 1;
            final GenomeLoc trimmedLoc = new UnvalidatingGenomeLoc("20", 0, start + loc.getStart(), stop + loc.getStart() - 1);
            final String expectedBases = fullBases.substring(start, stop);
            final Haplotype full = new Haplotype(fullBases.getBytes(), loc);
            final Haplotype trimmed = new Haplotype(expectedBases.getBytes(), trimmedLoc);
            final int hapStart = 10;
            full.setAlignmentStartHapwrtRef(hapStart);
            full.setCigar(TextCigarCodec.decode(full.length() + "M"));
            trimmed.setAlignmentStartHapwrtRef(hapStart + start);
            trimmed.setCigar(TextCigarCodec.decode(trimmed.length() + "M"));
            tests.add(new Object[] { full, trimmedLoc, trimmed });
        }
    }
    final Haplotype full = new Haplotype("ACT".getBytes(), new UnvalidatingGenomeLoc("20", 0, 10, 14));
    full.setAlignmentStartHapwrtRef(10);
    full.setCigar(TextCigarCodec.decode("1M2D2M"));
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 11, 12), null });
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 10, 12), null });
    tests.add(new Object[] { full, new UnvalidatingGenomeLoc("20", 0, 11, 13), null });
    return tests.toArray(new Object[][] {});
}
Also used : ArrayList(java.util.ArrayList) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) UnvalidatingGenomeLoc(org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc) GenomeLoc(org.broadinstitute.hellbender.utils.GenomeLoc) DataProvider(org.testng.annotations.DataProvider)

Aggregations

GenomeLoc (org.broadinstitute.hellbender.utils.GenomeLoc)13 VariantContext (htsjdk.variant.variantcontext.VariantContext)6 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)6 Test (org.testng.annotations.Test)6 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)5 UnvalidatingGenomeLoc (org.broadinstitute.hellbender.utils.UnvalidatingGenomeLoc)4 Genotype (htsjdk.variant.variantcontext.Genotype)2 DataProvider (org.testng.annotations.DataProvider)2 ArrayList (java.util.ArrayList)1