use of com.hartwig.hmftools.common.variant.snpeff.VariantAnnotation in project hmftools by hartwigmedical.
the class BachelorEligibility method processVariant.
@NotNull
private Collection<EligibilityReport> processVariant(final VariantContext variant, final String patient, final String sample, final EligibilityReport.ReportType type) {
if (variant.isFiltered()) {
return Collections.emptyList();
}
// we will skip when an ALT is not present in the sample
final Genotype genotype = variant.getGenotype(sample);
if (genotype == null || !(genotype.isHomVar() || genotype.isHet())) {
return Collections.emptyList();
}
// gather up the relevant alleles
VariantModel sampleVariant = new VariantModel(sample, variant);
// for(SnpEff snpEff : sampleVariant.SampleAnnotations)
// {
// if(snpEff.Transcript.contains("ENST00000357654"))
// {
// LOGGER.debug("matched SAMPLED transcriptId: gene({}) allele({}) effects({})",
// snpEff.GeneName, snpEff.getAllele(), snpEff.AllEffects);
//
// for(String effect : snpEff.Effects)
// {
// LOGGER.debug("transcript({}) with effect({})", snpEff.Transcript, effect);
// }
// }
// }
// apply the all relevant tests to see if this program has been matched
final List<String> matchingPrograms = programs.stream().filter(program -> program.vcfProcessor().test(sampleVariant)).map(BachelorProgram::name).collect(Collectors.toList());
List<EligibilityReport> reportList = Lists.newArrayList();
if (matchingPrograms.size() > 0) {
// found a match, not collect up the details and write them to the output file
LOGGER.info("program match found, first entry({}) ", matchingPrograms.get(0));
}
// just apply the search criteria once, and create a report for any full match
for (BachelorProgram program : programs) {
if (!program.vcfProcessor().test(sampleVariant)) {
continue;
}
String programName = program.name();
// found a match, not collect up the details and write them to the output file
LOGGER.info("match found: program({}) ", programName);
for (VariantAnnotation snpEff : sampleVariant.sampleAnnotations()) {
// re-check that this variant is one that is relevant
if (!program.panelTranscripts().contains(snpEff.featureID())) {
LOGGER.debug("uninteresting transcript({})", snpEff.featureID());
continue;
}
boolean found = false;
for (String requiredEffect : program.requiredEffects()) {
if (snpEff.effects().contains(requiredEffect)) {
found = true;
break;
}
}
if (!found) {
LOGGER.debug("uninteresting effects({})", snpEff.effects());
continue;
}
// now we have the correct allele and transcript ID as required by the XML
// so write a complete record to the output file
LOGGER.info("matched allele({}) transcriptId({}) effect({})", snpEff.allele(), snpEff.featureID(), snpEff.effects());
EligibilityReport report = ImmutableEligibilityReport.builder().patient(patient).source(type).program(programName).id(variant.getID()).genes(snpEff.gene()).transcriptId(snpEff.featureID()).chrom(variant.getContig()).pos(variant.getStart()).ref(variant.getReference().toString()).alts(snpEff.allele()).effects(snpEff.effects()).build();
reportList.add(report);
}
}
if (!reportList.isEmpty()) {
LOGGER.info("writing {} matched reports", reportList.size());
}
return reportList;
// final String alts = variant.getAlternateAlleles().stream().map(Object::toString).collect(Collectors.joining("|"));
// final String effects = String.join("|", sampleVariant.SampleAnnotations.stream().flatMap(a -> a.Effects.stream()).collect(Collectors.toSet()));
// final String genes = String.join("|", sampleVariant.SampleAnnotations.stream().map(a -> a.GeneName).collect(Collectors.toSet()));
// return matchingPrograms.stream()
// .map(p -> ImmutableEligibilityReport.builder()
// .patient(patient)
// .source(type)
// .program(p)
// .id(variant.getID())
// .genes(genes)
// .transcriptId("TransId")
// .chrom(variant.getContig())
// .pos(variant.getStart())
// .ref(variant.getReference().toString())
// .alts(alts)
// .effects(effects)
// .build())
// .collect(Collectors.toList());
}
Aggregations