void SequenceWhack(Sequence *self, bool commit) { uint64_t dummyRows; VDatabaseRelease(self->db); if (self->tbl == NULL) return; (void)TableWriterSeq_Whack(self->tbl, commit, &dummyRows); }
LIB_EXPORT rc_t CC TableWriterSeq_Make(const TableWriterSeq** cself, VDatabase* db, uint32_t options, char const qual_quantization[]) { rc_t rc = 0; TableWriterSeq* self = NULL; char const *tblName = (options & ewseq_co_ColorSpace) ? "CS_SEQUENCE" : "SEQUENCE"; options |= ewseq_co_SaveQual; /* TODO: remove when ready */ if( cself == NULL || db == NULL ) { rc = RC(rcAlign, rcFormatter, rcConstructing, rcParam, rcNull); } else { self = calloc(1, sizeof(*self)); if( self == NULL ) { rc = RC(rcAlign, rcFormatter, rcConstructing, rcMemory, rcExhausted); } else { memcpy(self->cols, TableWriterSeq_cols, sizeof(TableWriterSeq_cols)); if( options & ewseq_co_AlignData ) { self->cols[ewseq_cn_TMP_KEY_ID].flags |= ewcol_Ignore; } else { self->cols[ewseq_cn_PRIMARY_ALIGNMENT_ID].flags |= ewcol_Ignore; self->cols[ewseq_cn_ALIGNMENT_COUNT].flags |= ewcol_Ignore; } if(options & ewseq_co_NoLabelData) { self->cols[ewseq_cn_LABEL].flags |= ewcol_Ignore; self->cols[ewseq_cn_LABEL_LEN].flags |= ewcol_Ignore; self->cols[ewseq_cn_LABEL_START].flags |= ewcol_Ignore; } if(options & ewseq_co_ColorSpace) { self->cols[ewseq_cn_READ].flags |= ewcol_Ignore; self->cols[ewseq_cn_CSREAD].flags &= ~ewcol_Ignore; self->cols[ewseq_cn_CSKEY].flags &= ~ewcol_Ignore; } if( options & ewseq_co_SpotGroup) { self->cols[ewseq_cn_SPOT_GROUP].flags &= ~ewcol_Ignore; } if( options & ewseq_co_TI) { self->cols[ewseq_cn_TI].flags &= ~ewcol_Ignore; } if( options & ewseq_co_SpotName) { self->cols[ewseq_cn_NAME].flags &= ~ewcol_Ignore; } if( (rc = TableWriter_Make(&self->base, db, tblName, "SEQUENCE")) == 0 ) { rc = TableWriter_AddCursor(self->base, self->cols, sizeof(self->cols)/sizeof(self->cols[0]), &self->cursor_id); } } if( rc == 0 ) { self->options = options; if (qual_quantization && strcmp(qual_quantization, "0") == 0) { self->options |= ewseq_co_FullQuality; } if( !(self->options & ewseq_co_FullQuality) ) { char const *quant_string = qual_quantization; if (quant_string == NULL || strcmp(quant_string, "1") == 0) { quant_string = "1:10,10:20,20:30,30:-"; } else if (strcmp(quant_string, "2") == 0) { quant_string = "1:30,30:-"; } if (!TableWriterSeq_InitQuantMatrix(self->discrete_qual, quant_string)) { rc = RC(rcAlign, rcFormatter, rcConstructing, rcParam, rcInvalid); } } } } if( rc == 0 ) { *cself = self; ALIGN_DBG("table %s", "created"); } else { TableWriterSeq_Whack(self, false, NULL); ALIGN_DBGERR(rc); } return rc; }