Search in sources :

Example 1 with InsertValuesStep13

use of org.jooq.InsertValuesStep13 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();
}
Also used : Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) GeneAnnotation(com.hartwig.hmftools.svannotation.annotations.GeneAnnotation) StructuralVariantAnnotation(com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation) GeneDisruption(com.hartwig.hmftools.svannotation.annotations.GeneDisruption) InsertValuesStep13(org.jooq.InsertValuesStep13) Timestamp(java.sql.Timestamp) Date(java.util.Date) UInteger(org.jooq.types.UInteger) GeneFusion(com.hartwig.hmftools.svannotation.annotations.GeneFusion) UInteger(org.jooq.types.UInteger) InsertValuesStep2(org.jooq.InsertValuesStep2) InsertValuesStep3(org.jooq.InsertValuesStep3)

Aggregations

GeneAnnotation (com.hartwig.hmftools.svannotation.annotations.GeneAnnotation)1 GeneDisruption (com.hartwig.hmftools.svannotation.annotations.GeneDisruption)1 GeneFusion (com.hartwig.hmftools.svannotation.annotations.GeneFusion)1 StructuralVariantAnnotation (com.hartwig.hmftools.svannotation.annotations.StructuralVariantAnnotation)1 Transcript (com.hartwig.hmftools.svannotation.annotations.Transcript)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 InsertValuesStep13 (org.jooq.InsertValuesStep13)1 InsertValuesStep2 (org.jooq.InsertValuesStep2)1 InsertValuesStep3 (org.jooq.InsertValuesStep3)1 UInteger (org.jooq.types.UInteger)1