use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.
the class PurityDAO method write.
void write(@NotNull final String sample, @NotNull final PurityContext purity, @NotNull final PurpleQC checks) {
final FittedPurity bestFit = purity.bestFit();
final FittedPurityScore score = purity.score();
Timestamp timestamp = new Timestamp(new Date().getTime());
context.delete(PURITY).where(PURITY.SAMPLEID.eq(sample)).execute();
context.insertInto(PURITY, PURITY.VERSION, PURITY.SAMPLEID, PURITY.PURITY_, PURITY.GENDER, PURITY.STATUS, PURITY.QCSTATUS, PURITY.NORMFACTOR, PURITY.SCORE, PURITY.PLOIDY, PURITY.DIPLOIDPROPORTION, PURITY.MINDIPLOIDPROPORTION, PURITY.MAXDIPLOIDPROPORTION, PURITY.MINPURITY, PURITY.MAXPURITY, PURITY.MINPLOIDY, PURITY.MAXPLOIDY, PURITY.POLYCLONALPROPORTION, PURITY.MODIFIED).values(purity.version(), sample, bestFit.purity(), purity.gender().toString(), purity.status().toString(), checks.status().toString(), bestFit.normFactor(), bestFit.score(), bestFit.ploidy(), bestFit.diploidProportion(), score.minDiploidProportion(), score.maxDiploidProportion(), score.minPurity(), score.maxPurity(), score.minPloidy(), score.maxPloidy(), purity.polyClonalProportion(), timestamp).execute();
}
use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.
the class PurityDAO method readPurityContext.
@Nullable
PurityContext readPurityContext(@NotNull final String sample) {
@Nullable Record result = context.select().from(PURITY).where(PURITY.SAMPLEID.eq(sample)).fetchOne();
if (result == null) {
return null;
}
final FittedPurity purity = ImmutableFittedPurity.builder().purity(result.getValue(PURITY.PURITY_)).normFactor(result.getValue(PURITY.NORMFACTOR)).score(result.getValue(PURITY.SCORE)).diploidProportion(result.getValue(PURITY.DIPLOIDPROPORTION)).ploidy(result.getValue(PURITY.PLOIDY)).build();
final FittedPurityScore score = ImmutableFittedPurityScore.builder().minPurity(result.getValue(PURITY.MINPURITY)).maxPurity(result.getValue(PURITY.MAXPURITY)).minPloidy(result.getValue(PURITY.MINPLOIDY)).maxPloidy(result.getValue(PURITY.MAXPLOIDY)).minDiploidProportion(result.getValue(PURITY.MINDIPLOIDPROPORTION)).maxDiploidProportion(result.getValue(PURITY.MAXDIPLOIDPROPORTION)).build();
return ImmutablePurityContext.builder().bestFit(purity).score(score).version(result.getValue(PURITY.VERSION)).gender(Gender.valueOf(result.getValue(PURITY.GENDER))).polyClonalProportion(result.getValue(PURITY.POLYCLONALPROPORTION)).status(FittedPurityStatus.valueOf(result.getValue(PURITY.STATUS))).build();
}
use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.
the class PatientReporter method analyseGenomeData.
@NotNull
private GenomeAnalysis analyseGenomeData(@NotNull final String sample, @NotNull final String runDirectory) throws IOException {
LOGGER.info(" Loading somatic snv and indels...");
final List<SomaticVariant> variants = PatientReporterHelper.loadPassedSomaticVariants(sample, runDirectory);
LOGGER.info(" " + variants.size() + " somatic passed snps, mnps and indels loaded for sample " + sample);
LOGGER.info(" Analyzing somatic snp/mnp and indels....");
final VariantAnalysis variantAnalysis = variantAnalyzer().run(variants);
LOGGER.info(" Loading purity numbers...");
final PurityContext context = PatientReporterHelper.loadPurity(runDirectory, sample);
if (context.status().equals(FittedPurityStatus.NO_TUMOR)) {
LOGGER.warn("PURPLE DID NOT DETECT A TUMOR. Proceed with utmost caution!");
}
final FittedPurity purity = context.bestFit();
final FittedPurityScore purityScore = context.score();
final List<PurpleCopyNumber> purpleCopyNumbers = PatientReporterHelper.loadPurpleCopyNumbers(runDirectory, sample);
final List<GeneCopyNumber> panelGeneCopyNumbers = PatientReporterHelper.loadPurpleGeneCopyNumbers(runDirectory, sample).stream().filter(x -> reporterData().panelGeneModel().panel().contains(x.gene())).collect(Collectors.toList());
LOGGER.info(" " + purpleCopyNumbers.size() + " purple copy number regions loaded for sample " + sample);
LOGGER.info(" Analyzing purple somatic copy numbers...");
final PurpleAnalysis purpleAnalysis = ImmutablePurpleAnalysis.builder().gender(context.gender()).status(context.status()).fittedPurity(purity).fittedScorePurity(purityScore).copyNumbers(purpleCopyNumbers).panelGeneCopyNumbers(panelGeneCopyNumbers).build();
final Path structuralVariantVCF = PatientReporterHelper.findStructuralVariantVCF(runDirectory);
LOGGER.info(" Loading structural variants...");
final List<StructuralVariant> structuralVariants = StructuralVariantFileLoader.fromFile(structuralVariantVCF.toString(), true);
LOGGER.info(" Enriching structural variants with purple data.");
final List<EnrichedStructuralVariant> enrichedStructuralVariants = purpleAnalysis.enrichStructuralVariants(structuralVariants);
LOGGER.info(" Analysing structural variants...");
final StructuralVariantAnalysis structuralVariantAnalysis = structuralVariantAnalyzer().run(enrichedStructuralVariants, false);
return ImmutableGenomeAnalysis.of(sample, variantAnalysis, purpleAnalysis, structuralVariantAnalysis);
}
Aggregations