use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.
the class CopyNumberDAO method read.
@NotNull
public List<PurpleCopyNumber> read(@NotNull final String sample) {
List<PurpleCopyNumber> copyNumbers = Lists.newArrayList();
Result<Record> result = context.select().from(COPYNUMBER).where(COPYNUMBER.SAMPLEID.eq(sample)).fetch();
for (Record record : result) {
copyNumbers.add(ImmutablePurpleCopyNumber.builder().chromosome(record.getValue(COPYNUMBER.CHROMOSOME)).start(record.getValue(COPYNUMBER.START)).end(record.getValue(COPYNUMBER.END)).bafCount(record.getValue(COPYNUMBER.BAFCOUNT)).method(CopyNumberMethod.valueOf(record.getValue(COPYNUMBER.COPYNUMBERMETHOD))).segmentStartSupport(SegmentSupport.valueOf(record.getValue(COPYNUMBER.SEGMENTSTARTSUPPORT))).segmentEndSupport(SegmentSupport.valueOf(record.getValue(COPYNUMBER.SEGMENTENDSUPPORT))).averageActualBAF(record.getValue(COPYNUMBER.ACTUALBAF)).averageObservedBAF(record.getValue(COPYNUMBER.OBSERVEDBAF)).averageTumorCopyNumber(record.getValue(COPYNUMBER.COPYNUMBER_)).build());
}
Collections.sort(copyNumbers);
return copyNumbers;
}
use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.
the class StructuralVariantPloidyFactoryTest method testPurityAdjustedPloidy.
@Test
public void testPurityAdjustedPloidy() {
final StructuralVariantLeg leg = createLeg(1001, 1, 0.5);
final List<PurpleCopyNumber> copyNumbers = Lists.newArrayList(copyNumber(1, 1000, 2), copyNumber(1001, 200, 1));
Optional<ModifiableStructuralVariantLegPloidy> purePloidy = PURE_PLOIDY_FACTORY.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
assertPloidy(1d, purePloidy);
final PurityAdjuster diluted = new PurityAdjuster(Gender.FEMALE, 0.8, 1);
final StructuralVariantLegPloidyFactory<PurpleCopyNumber> dilutedFactory = new StructuralVariantLegPloidyFactory<>(diluted, PurpleCopyNumber::averageTumorCopyNumber);
Optional<ModifiableStructuralVariantLegPloidy> dilutedPloidy = dilutedFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
assertPloidy(1.25d, dilutedPloidy);
final PurityAdjuster male = new PurityAdjuster(Gender.MALE, 0.8, 1);
final StructuralVariantLegPloidyFactory<PurpleCopyNumber> maleFactory = new StructuralVariantLegPloidyFactory<>(male, PurpleCopyNumber::averageTumorCopyNumber);
Optional<ModifiableStructuralVariantLegPloidy> malePloidy = maleFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
assertPloidy(1.125d, malePloidy);
}
use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.
the class StructuralVariantPloidyFactoryTest method testExcludeNegativeAndZeroCopyNumbers.
@Test
public void testExcludeNegativeAndZeroCopyNumbers() {
final StructuralVariantLeg positiveLeg = createLeg(1001, 1, 0.25);
final StructuralVariantLeg negativeLeg = createLeg(2001, -1, 0.25);
final PurpleCopyNumber left = copyNumber(1, 1000, -0.01);
final PurpleCopyNumber right = copyNumber(2001, 3000, 0);
assertFalse(PURE_PLOIDY_FACTORY.create(positiveLeg, GenomeRegionSelectorFactory.create(singleton(left))).isPresent());
assertFalse(PURE_PLOIDY_FACTORY.create(negativeLeg, GenomeRegionSelectorFactory.create(singleton(right))).isPresent());
}
use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.
the class StructuralVariantPloidyFactoryTest method testSingleValidLeg.
@Test
public void testSingleValidLeg() {
final StructuralVariantLeg start = createLeg(1001, 1, 0.25);
final PurpleCopyNumber left = copyNumber(1, 1000, 4);
final PurpleCopyNumber middle = copyNumber(1001, 2000, 3);
final PurpleCopyNumber right = copyNumber(2001, 3000, 4);
final StructuralVariantLegs legs = ImmutableStructuralVariantLegs.builder().start(start).end(Optional.empty()).build();
final ListMultimap<String, PurpleCopyNumber> copyNumbers = copyNumbers(left, middle, right);
final List<StructuralVariantLegPloidy> ploidies = PURE_PLOIDY_FACTORY.create(legs, copyNumbers);
assertEquals(1, ploidies.size());
for (StructuralVariantLegPloidy ploidy : ploidies) {
assertEquals(1d, ploidy.averageImpliedPloidy(), EPSILON);
assertEquals(1d, ploidy.weight(), EPSILON);
}
}
use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.
the class CopyNumberDAO method writeCopyNumber.
void writeCopyNumber(@NotNull final String sample, @NotNull List<PurpleCopyNumber> copyNumbers) {
Timestamp timestamp = new Timestamp(new Date().getTime());
context.delete(COPYNUMBER).where(COPYNUMBER.SAMPLEID.eq(sample)).execute();
for (List<PurpleCopyNumber> splitCopyNumbers : Iterables.partition(copyNumbers, DB_BATCH_INSERT_SIZE)) {
InsertValuesStep12 inserter = context.insertInto(COPYNUMBER, COPYNUMBER.SAMPLEID, COPYNUMBER.CHROMOSOME, COPYNUMBER.START, COPYNUMBER.END, COPYNUMBER.COPYNUMBERMETHOD, COPYNUMBER.SEGMENTSTARTSUPPORT, COPYNUMBER.SEGMENTENDSUPPORT, COPYNUMBER.BAFCOUNT, COPYNUMBER.OBSERVEDBAF, COPYNUMBER.ACTUALBAF, COPYNUMBER.COPYNUMBER_, COPYNUMBER.MODIFIED);
splitCopyNumbers.forEach(x -> addCopynumberRecord(timestamp, inserter, sample, x));
inserter.execute();
}
}
Aggregations