Search in sources :

Example 1 with InsertValuesStep21

use of org.jooq.InsertValuesStep21 in project hmftools by hartwigmedical.

the class StructuralVariantDAO method write.

void write(@NotNull final String sample, @NotNull final List<EnrichedStructuralVariant> variants) {
    Timestamp timestamp = new Timestamp(new Date().getTime());
    final Result<Record1<UInteger>> breakendsToDelete = context.select(STRUCTURALVARIANTBREAKEND.ID).from(STRUCTURALVARIANTBREAKEND).innerJoin(STRUCTURALVARIANT).on(STRUCTURALVARIANT.ID.eq(STRUCTURALVARIANTBREAKEND.STRUCTURALVARIANTID)).where(STRUCTURALVARIANT.SAMPLEID.eq(sample)).fetch();
    // first delete annotations
    context.delete(STRUCTURALVARIANTDISRUPTION).where(STRUCTURALVARIANTDISRUPTION.BREAKENDID.in(breakendsToDelete)).execute();
    context.delete(STRUCTURALVARIANTFUSION).where(STRUCTURALVARIANTFUSION.FIVEPRIMEBREAKENDID.in(breakendsToDelete)).execute();
    context.delete(STRUCTURALVARIANTBREAKEND).where(STRUCTURALVARIANTBREAKEND.ID.in(breakendsToDelete)).execute();
    // and then the structural variants
    context.delete(STRUCTURALVARIANT).where(STRUCTURALVARIANT.SAMPLEID.eq(sample)).execute();
    for (List<EnrichedStructuralVariant> batch : Iterables.partition(variants, DB_BATCH_INSERT_SIZE)) {
        InsertValuesStep21 inserter = context.insertInto(STRUCTURALVARIANT, STRUCTURALVARIANT.SAMPLEID, STRUCTURALVARIANT.STARTCHROMOSOME, STRUCTURALVARIANT.ENDCHROMOSOME, STRUCTURALVARIANT.STARTPOSITION, STRUCTURALVARIANT.ENDPOSITION, STRUCTURALVARIANT.STARTORIENTATION, STRUCTURALVARIANT.ENDORIENTATION, STRUCTURALVARIANT.STARTHOMOLOGYSEQUENCE, STRUCTURALVARIANT.ENDHOMOLOGYSEQUENCE, STRUCTURALVARIANT.INSERTSEQUENCE, STRUCTURALVARIANT.TYPE, STRUCTURALVARIANT.STARTAF, STRUCTURALVARIANT.ADJUSTEDSTARTAF, STRUCTURALVARIANT.ADJUSTEDSTARTCOPYNUMBER, STRUCTURALVARIANT.ADJUSTEDSTARTCOPYNUMBERCHANGE, STRUCTURALVARIANT.ENDAF, STRUCTURALVARIANT.ADJUSTEDENDAF, STRUCTURALVARIANT.ADJUSTEDENDCOPYNUMBER, STRUCTURALVARIANT.ADJUSTEDENDCOPYNUMBERCHANGE, STRUCTURALVARIANT.PLOIDY, STRUCTURALVARIANT.MODIFIED);
        batch.forEach(entry -> addRecord(timestamp, inserter, sample, entry));
        inserter.execute();
    }
}
Also used : EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) ImmutableEnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.ImmutableEnrichedStructuralVariant) InsertValuesStep21(org.jooq.InsertValuesStep21) Timestamp(java.sql.Timestamp) Date(java.util.Date) Record1(org.jooq.Record1)

Aggregations

EnrichedStructuralVariant (com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant)1 ImmutableEnrichedStructuralVariant (com.hartwig.hmftools.common.variant.structural.ImmutableEnrichedStructuralVariant)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 InsertValuesStep21 (org.jooq.InsertValuesStep21)1 Record1 (org.jooq.Record1)1