use of com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation in project hmftools by hartwigmedical.
the class MySQLAnnotator method annotateVariant.
@NotNull
private StructuralVariantAnnotation annotateVariant(@NotNull EnrichedStructuralVariant variant) {
final StructuralVariantAnnotation annotation = new StructuralVariantAnnotation(variant);
annotation.annotations().addAll(annotateBreakend(variant, true, variant.start().chromosome(), variant.start().position()));
annotation.annotations().addAll(annotateBreakend(variant, false, variant.end().chromosome(), variant.end().position()));
return annotation;
}
use of com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation in project hmftools by hartwigmedical.
the class StructuralVariantAnalyzer method processFusions.
@NotNull
private List<GeneFusion> processFusions(final List<StructuralVariantAnnotation> annotations) {
// NERA: left is upstream, right is downstream
final List<List<Pair<Transcript, Transcript>>> fusionsPerVariant = Lists.newArrayList();
for (final StructuralVariantAnnotation annotation : annotations) {
final List<Pair<Transcript, Transcript>> fusions = Lists.newArrayList();
for (final GeneAnnotation startGene : annotation.start()) {
final boolean startUpstream = isUpstream(startGene);
for (final GeneAnnotation endGene : annotation.end()) {
final boolean endUpstream = isUpstream(endGene);
if (startUpstream == endUpstream) {
continue;
}
for (final Transcript t1 : intronic(startGene.transcripts())) {
for (final Transcript t2 : intronic(endGene.transcripts())) {
if (!isPotentiallyRelevantFusion(t1, t2)) {
continue;
}
if (startUpstream && t1.exonUpstreamPhase() == t2.exonDownstreamPhase()) {
fusions.add(Pair.of(t1, t2));
} else if (!startUpstream && t2.exonUpstreamPhase() == t1.exonDownstreamPhase()) {
fusions.add(Pair.of(t2, t1));
}
}
}
}
}
fusionsPerVariant.add(fusions);
}
return toReportableGeneFusions(fusionsPerVariant);
}
use of com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation in project hmftools by hartwigmedical.
the class StructuralVariantAnalyzer method processDisruptions.
@NotNull
private List<GeneDisruption> processDisruptions(final List<StructuralVariantAnnotation> annotations) {
final List<GeneAnnotation> geneAnnotations = Lists.newArrayList();
for (final StructuralVariantAnnotation annotation : annotations) {
@SuppressWarnings("ConstantConditions") final boolean pureIntronicDisruptionCanonical = annotation.start().stream().filter(gene -> gene.canonical() != null).anyMatch(gene -> annotation.end().stream().filter(other -> other.canonical() != null).anyMatch(other -> intronicDisruptionOnSameTranscript(gene.canonical(), other.canonical())));
if (pureIntronicDisruptionCanonical && annotation.variant().type() != StructuralVariantType.INV) {
continue;
}
geneAnnotations.addAll(annotation.annotations());
}
final Multimap<String, GeneAnnotation> geneMap = ArrayListMultimap.create();
geneAnnotations.forEach(g -> geneMap.put(g.geneName(), g));
final List<GeneDisruption> disruptions = Lists.newArrayList();
for (final String geneName : geneMap.keySet()) {
for (final GeneAnnotation gene : geneMap.get(geneName)) {
for (final Transcript transcript : gene.transcripts()) {
final GeneDisruption disruption = ImmutableGeneDisruption.builder().reportable(inHmfPanel(gene) && transcript.isCanonical()).linkedAnnotation(transcript).build();
disruptions.add(disruption);
}
}
}
return disruptions;
}
use of com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation in project hmftools by hartwigmedical.
the class StructuralVariantAnnotationDAO method write.
@SuppressWarnings("unchecked")
public void write(final StructuralVariantAnalysis analysis) {
final Timestamp timestamp = new Timestamp(new Date().getTime());
final Map<Transcript, Integer> id = Maps.newHashMap();
// NERA: load transcript annotations
for (final StructuralVariantAnnotation annotation : analysis.annotations()) {
for (final GeneAnnotation geneAnnotation : annotation.annotations()) {
final InsertValuesStep13 inserter = context.insertInto(STRUCTURALVARIANTBREAKEND, STRUCTURALVARIANTBREAKEND.MODIFIED, STRUCTURALVARIANTBREAKEND.ISSTARTEND, STRUCTURALVARIANTBREAKEND.STRUCTURALVARIANTID, STRUCTURALVARIANTBREAKEND.GENE, STRUCTURALVARIANTBREAKEND.GENEID, STRUCTURALVARIANTBREAKEND.TRANSCRIPTID, STRUCTURALVARIANTBREAKEND.ISCANONICALTRANSCRIPT, STRUCTURALVARIANTBREAKEND.STRAND, STRUCTURALVARIANTBREAKEND.EXONRANKUPSTREAM, STRUCTURALVARIANTBREAKEND.EXONPHASEUPSTREAM, STRUCTURALVARIANTBREAKEND.EXONRANKDOWNSTREAM, STRUCTURALVARIANTBREAKEND.EXONPHASEDOWNSTREAM, STRUCTURALVARIANTBREAKEND.EXONMAX);
for (final Transcript transcript : geneAnnotation.transcripts()) {
inserter.values(timestamp, geneAnnotation.isStart(), transcript.parent().variant().primaryKey(), geneAnnotation.geneName(), geneAnnotation.stableId(), transcript.transcriptId(), transcript.isCanonical(), geneAnnotation.strand(), transcript.exonUpstream(), transcript.exonUpstreamPhase(), transcript.exonDownstream(), transcript.exonDownstreamPhase(), transcript.exonMax());
}
final List<UInteger> ids = inserter.returning(STRUCTURALVARIANTBREAKEND.ID).fetch().getValues(0, UInteger.class);
if (ids.size() != geneAnnotation.transcripts().size()) {
throw new RuntimeException("not all transcripts were inserted successfully");
}
for (int i = 0; i < ids.size(); i++) {
id.put(geneAnnotation.transcripts().get(i), ids.get(i).intValue());
}
}
}
// NERA: load fusions
final InsertValuesStep3 fusionInserter = context.insertInto(STRUCTURALVARIANTFUSION, STRUCTURALVARIANTFUSION.ISREPORTED, STRUCTURALVARIANTFUSION.FIVEPRIMEBREAKENDID, STRUCTURALVARIANTFUSION.THREEPRIMEBREAKENDID);
for (final GeneFusion fusion : analysis.fusions()) {
fusionInserter.values(fusion.reportable(), id.get(fusion.upstreamLinkedAnnotation()), id.get(fusion.downstreamLinkedAnnotation()));
}
fusionInserter.execute();
// NERA: load disruptions
final InsertValuesStep2 disruptionInserter = context.insertInto(STRUCTURALVARIANTDISRUPTION, STRUCTURALVARIANTDISRUPTION.ISREPORTED, STRUCTURALVARIANTDISRUPTION.BREAKENDID);
for (final GeneDisruption disruption : analysis.disruptions()) {
disruptionInserter.values(disruption.reportable(), id.get(disruption.linkedAnnotation()));
}
disruptionInserter.execute();
}
Aggregations