Search in sources :

Example 1 with Pileup

use of com.hartwig.hmftools.common.pileup.Pileup in project hmftools by hartwigmedical.

the class BAFFactory method create.

@NotNull
List<AmberBAF> create(@NotNull final List<Pileup> normalPileup, @NotNull final List<Pileup> tumorPileup) {
    final GenomePositionSelector<Pileup> tumorSelector = GenomePositionSelectorFactory.create(tumorPileup);
    int medianDepth = medianReadCount(normalPileup);
    int minDepth = (int) Math.round(medianDepth * minDepthPercentage);
    int maxDepth = (int) Math.round(medianDepth * maxDepthPercentage);
    final List<AmberBAF> result = Lists.newArrayList();
    for (Pileup normal : normalPileup) {
        final int readCount = normal.readCount();
        final int altCount = maxMismatchReadCount(normal);
        if (isValidPileup(normal) && between(readCount, minDepth, maxDepth) && isHeterozygousRef(normal.referenceCount(), readCount) && isHeterozygousAlt(altCount, readCount)) {
            final Character alt = alt(altCount, normal);
            tumorSelector.select(normal).filter(BAFFactory::isValidPileup).map(x -> create(alt, normal, x)).filter(BAFFactory::isValidBAF).ifPresent(result::add);
        }
    }
    return result;
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) ImmutableAmberBAF(com.hartwig.hmftools.common.amber.ImmutableAmberBAF) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Pileup

use of com.hartwig.hmftools.common.pileup.Pileup in project hmftools by hartwigmedical.

the class BAFFactoryTest method testNoTumorReadCount.

@Test
public void testNoTumorReadCount() {
    final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t0\t*\t*");
    final List<AmberBAF> result = VICTIM.create(Collections.singletonList(GOOD_NORMAL), Collections.singletonList(tumor));
    assertEquals(0, result.size());
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Example 3 with Pileup

use of com.hartwig.hmftools.common.pileup.Pileup in project hmftools by hartwigmedical.

the class BAFFactoryTest method testDepths.

@Test
public void testDepths() {
    final Pileup normal = PileupFile.fromString("seq2\t156\tA\t11\t.$......+2AG.+2AG.+2AGGG\t<975;:<<<<<");
    final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t31\t.$......+2AG.+2AG.+2AGGG\t<975;:<<<<<");
    assertNotEquals(normal.readCount(), tumor.readCount());
    final AmberBAF victim = BAFFactory.create('A', normal, tumor);
    assertEquals(normal.readCount(), victim.normalDepth());
    assertEquals(tumor.readCount(), victim.tumorDepth());
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Example 4 with Pileup

use of com.hartwig.hmftools.common.pileup.Pileup in project hmftools by hartwigmedical.

the class BAFFactoryTest method testWorking.

@Test
public void testWorking() {
    final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t10\t.GGGGGGGGG\t<975;:<<<<<");
    final List<AmberBAF> result = VICTIM.create(Collections.singletonList(GOOD_NORMAL), Collections.singletonList(tumor));
    assertEquals(1, result.size());
    AmberBAF baf = result.get(0);
    assertEquals(10, baf.normalDepth());
    assertEquals(0.5, baf.normalBAF(), EPSILON);
    assertEquals(10, baf.tumorDepth());
    assertEquals(0.9, baf.tumorBAF(), EPSILON);
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Example 5 with Pileup

use of com.hartwig.hmftools.common.pileup.Pileup in project hmftools by hartwigmedical.

the class BAFFactoryTest method testInvalidBAF.

@Test
public void testInvalidBAF() {
    final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t10\tCCCCCCCCCC\t*");
    final List<AmberBAF> result = VICTIM.create(Collections.singletonList(GOOD_NORMAL), Collections.singletonList(tumor));
    assertEquals(0, result.size());
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Aggregations

AmberBAF (com.hartwig.hmftools.common.amber.AmberBAF)5 Pileup (com.hartwig.hmftools.common.pileup.Pileup)5 Test (org.junit.Test)4 ImmutableAmberBAF (com.hartwig.hmftools.common.amber.ImmutableAmberBAF)1 NotNull (org.jetbrains.annotations.NotNull)1