void sqlDeleterAddAcc(struct sqlDeleter* sd, char* acc) /* Add an accession to list to to delete. */ { if (sd->deletesDone) errAbort("sqlDeleter: can't add accessions after a delete has been done"); #ifdef COPY_TO_DELETE_HACK /* always use direct if no tmp dir */ if ((sd->accCount < sd->directMax) || (sd->tmpDir[0] == '\0')) { struct slName* accRec = lmAlloc(sd->lm, sizeof(struct slName)+strlen(acc)); strcpy(accRec->name, acc); slAddHead(&sd->accs, accRec); } else { if (sd->accLoader == NULL) initLoader(sd); sqlUpdaterAddRow(sd->accLoader, "%s", acc); } #else { struct slName* accRec = lmAlloc(sd->lm, sizeof(struct slName)+strlen(acc)); strcpy(accRec->name, acc); slAddHead(&sd->accs, accRec); } #endif sd->accCount++; }
static void refSeqSummaryUpdate(struct sqlConnection *conn, struct gbStatus* status) /* Update the refSeqSummary table for the current entry */ { /* only add to table if we actually have something */ if (((raRefSeqSummary->stringSize > 0) || (raRefSeqCompleteness != NULL)) && (status->stateChg & (GB_NEW|GB_META_CHG))) { char query[256]; unsigned sumNew; char* summary = sqlEscapeString2(alloca(2*raRefSeqSummary->stringSize+1), raRefSeqSummary->string); if (raRefSeqCompleteness == NULL) raRefSeqCompleteness = "Unknown"; /* If sequence may not be new, but summary could be. This table is * sparse, so must check it */ if (status->stateChg & GB_NEW) sumNew = TRUE; else { sqlSafef(query, sizeof(query), "SELECT count(*) from refSeqSummary " "WHERE mrnaAcc = '%s'", raAcc); sumNew = (sqlQuickNum(conn, query) == 0); } if (sumNew) sqlUpdaterAddRow(refSeqSummaryUpd, "%s\t%s\t%s", raAcc, raRefSeqCompleteness, summary); else sqlUpdaterModRow(refSeqSummaryUpd, 1, "completeness='%s', summary='%s'" " WHERE mrnaAcc='%s'", raRefSeqCompleteness, summary, raAcc); } }
static void gbWarnUpdate(struct gbStatus* status, struct sqlConnection *conn) /* update gbWarn table */ { if (status->stateChg & (GB_NEW|GB_META_CHG|GB_REBUILD_DERIVED)) { if (gbWarnUpd == NULL) gbWarnUpd = sqlUpdaterNew("gbWarn", gTmpDir, (gbVerbose >= 4), &allUpdaters); sqlUpdaterAddRow(gbWarnUpd, "%s\t%s", raAcc, raWarn); } }
static void refSeqStatusUpdate(struct gbStatus* status) /* Update the refSeqStatus table for the current entry */ { if (status->stateChg & GB_NEW) { if (haveRsMol) sqlUpdaterAddRow(refSeqStatusUpd, "%s\t%s\t%s", raAcc, raRefSeqStatus, raMol); else sqlUpdaterAddRow(refSeqStatusUpd, "%s\t%s", raAcc, raRefSeqStatus); } else if (status->stateChg & GB_META_CHG) { if (haveRsMol) sqlUpdaterModRow(refSeqStatusUpd, 1, "status='%s', mol='%s' WHERE mrnaAcc='%s'", raRefSeqStatus, raMol, raAcc); else sqlUpdaterModRow(refSeqStatusUpd, 1, "status='%s' WHERE mrnaAcc='%s'", raRefSeqStatus, raAcc); } }
static void initLoader(struct sqlDeleter* sd) /* setup loader and copy access to tab file */ { struct slName* acc; sd->accLoader = sqlUpdaterNew(GB_DELETE_TMP, sd->tmpDir, sd->verbose, NULL); for (acc = sd->accs; acc != NULL; acc = acc->next) sqlUpdaterAddRow(sd->accLoader, "%s", acc->name); sd->useDeleteJoin = TRUE; sd->accs = NULL; /* mark as not in use (list in localmem) */ }
static void gbMiscDiffUpdate(struct gbStatus* status, struct sqlConnection *conn) /* update gbMiscDiff table */ { if (status->stateChg & (GB_NEW|GB_META_CHG|GB_REBUILD_DERIVED)) { if (gbMiscDiffUpd == NULL) gbMiscDiffUpd = sqlUpdaterNew("gbMiscDiff", gTmpDir, (gbVerbose >= 4), &allUpdaters); struct gbMiscDiff *gmd; for (gmd = raMiscDiffs; gmd != NULL; gmd = gmd->next) sqlUpdaterAddRow(gbMiscDiffUpd, "%s\t%d\t%d\t%s\t%s\t%s", gmd->acc, gmd->mrnaStart, gmd->mrnaEnd, gbSqlStrOrNullTabVar(gmd->notes), gbSqlStrOrNullTabVar(gmd->gene), gbSqlStrOrNullTabVar(gmd->replacement)); } }
static void refLinkUpdate(struct sqlConnection *conn, struct gbStatus* status) /* Update the refLink table for the current entry */ { int geneId; char *gen = emptyForNull(raFieldCurVal("gen")); char *pro = emptyForNull(raFieldCurVal("pro")); gen = sqlEscapeString2(alloca(2*strlen(gen)+1), gen); pro = sqlEscapeString2(alloca(2*strlen(pro)+1), pro); /* can either have locus id (old locus link db) or gene id, or both, * in which case the geneId is used */ geneId = (raGeneId != 0) ? raGeneId : raLocusLinkId; if (status->stateChg & GB_NEW) sqlUpdaterAddRow(refLinkUpd, "%s\t%s\t%s\t%s\t%u\t%u\t%u\t%u", gen, pro, raAcc, raProtAcc, raFieldCurId("gen"), raFieldCurId("pro"), geneId, raOmimId); else if (status->stateChg & GB_META_CHG) sqlUpdaterModRow(refLinkUpd, 1, "name='%s', product='%s', protAcc='%s', " "geneName=%u, prodName=%u, locusLinkId=%u, " "omimId=%u where mrnaAcc='%s'", gen, pro, raProtAcc, raFieldCurId("gen"), raFieldCurId("pro"), geneId, raOmimId, raAcc); }
static void gbCdnaInfoUpdate(struct gbStatus* status, struct sqlConnection *conn) /* Update the mrna table for the current entry */ { if (status->stateChg & GB_NEW) { if (haveMol) sqlUpdaterAddRow(gbCdnaInfoUpd, "%u\t%s\t%u\t%s\t%s\t%c\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%s", status->gbSeqId, raAcc, raVersion, gbFormatDate(raModDate), ((status->type == GB_MRNA) ? "mRNA" : "EST"), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut"), raGi, raMol); else if (haveGi) sqlUpdaterAddRow(gbCdnaInfoUpd, "%u\t%s\t%u\t%s\t%s\t%c\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u", status->gbSeqId, raAcc, raVersion, gbFormatDate(raModDate), ((status->type == GB_MRNA) ? "mRNA" : "EST"), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut"), raGi); else sqlUpdaterAddRow(gbCdnaInfoUpd, "%u\t%s\t%u\t%s\t%s\t%c\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u\t%u", status->gbSeqId, raAcc, raVersion, gbFormatDate(raModDate), ((status->type == GB_MRNA) ? "mRNA" : "EST"), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut")); } else if (status->stateChg & GB_META_CHG) { if (haveMol) sqlUpdaterModRow(gbCdnaInfoUpd, 1, "version='%u', moddate='%s', direction='%c', " "source=%u, organism=%u, library=%u, mrnaClone=%u, sex=%u, " "tissue=%u, development=%u, cell=%u, cds=%u, keyword=%u, " "description=%u, geneName=%u, productName=%u, author=%u, gi=%u, mol='%s' " "WHERE id=%u", raVersion, gbFormatDate(raModDate), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut"), raGi, raMol, status->gbSeqId); else if (haveGi) sqlUpdaterModRow(gbCdnaInfoUpd, 1, "version='%u', moddate='%s', direction='%c', " "source=%u, organism=%u, library=%u, mrnaClone=%u, sex=%u, " "tissue=%u, development=%u, cell=%u, cds=%u, keyword=%u, " "description=%u, geneName=%u, productName=%u, author=%u, gi=%u " "WHERE id=%u", raVersion, gbFormatDate(raModDate), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut"), raGi, status->gbSeqId); else sqlUpdaterModRow(gbCdnaInfoUpd, 1, "version='%u', moddate='%s', direction='%c', " "source=%u, organism=%u, library=%u, mrnaClone=%u, sex=%u, " "tissue=%u, development=%u, cell=%u, cds=%u, keyword=%u, " "description=%u, geneName=%u, productName=%u, author=%u " "WHERE id=%u", raVersion, gbFormatDate(raModDate), raDir, raFieldCurId("src"), raFieldCurId("org"), raFieldCurId("lib"), raFieldCurId("clo"), raFieldCurId("sex"), raFieldCurId("tis"), raFieldCurId("dev"), raFieldCurId("cel"), raFieldCurId("cds"), raFieldCurId("key"), raFieldCurId("def"), raFieldCurId("gen"), raFieldCurId("pro"), raFieldCurId("aut"), status->gbSeqId); } }