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();
}
}
Aggregations