static void makeRepairs(struct brokenRefPepTbl *brpTbl, struct sqlConnection *conn, struct extFileTbl* extFileTbl, boolean dryRun) /* make repairs once data is collected */ { static char *tmpDir = "/var/tmp"; struct hashCookie cookie; struct hashEl *hel; int repairCnt = 0; int dropCnt = 0; struct seqTbl* seqTbl = seqTblNew(conn, tmpDir, (gbVerbose > 3)); struct sqlDeleter* seqTblDeleter = sqlDeleterNew(tmpDir, (gbVerbose > 3)); cookie = hashFirst(brpTbl->protAccHash); while ((hel = hashNext(&cookie)) != NULL) { struct brokenRefPep *brp = hel->val; if ((brp->mrnaAcc != NULL) && (brp->newFaOff >= 0)) { refPepRepairOne(conn, brp, seqTbl, extFileTbl, dryRun); repairCnt++; } else { refPepDropOne(conn, brp, seqTblDeleter, dryRun); dropCnt++; } } if (dryRun) { gbVerbMsg(1, "%s: would have repaired %d refseq protein gbExtFile entries", sqlGetDatabase(conn), repairCnt); gbVerbMsg(1, "%s: would have dropped %d refseq protein gbExtFile entries", sqlGetDatabase(conn), dropCnt); } else { seqTblCommit(seqTbl, conn); gbVerbMsg(1, "%s: repaired %d refseq protein gbExtFile entries", sqlGetDatabase(conn), repairCnt); sqlDeleterDel(seqTblDeleter, conn, SEQ_TBL, "acc"); gbVerbMsg(1, "%s: dropped %d refseq protein gbExtFile entries", sqlGetDatabase(conn), dropCnt); } }
void gbMetaDataInit(struct sqlConnection *conn, unsigned srcDb, struct dbLoadOptions* options, char *gbdbGenBank, char *tmpDir) /* initialize for parsing metadata */ { gOptions = options; gSrcDb = srcDb; gGbdbGenBank[0] = '\0'; if (gbdbGenBank != NULL) strcpy(gGbdbGenBank, gbdbGenBank); strcpy(gTmpDir, tmpDir); if (seqTbl == NULL) seqTbl = seqTblNew(conn, gTmpDir, (gbVerbose >= 4)); if (imageCloneTbl == NULL) imageCloneTbl = imageCloneTblNew(conn, gTmpDir, (gbVerbose >= 4)); if (!sqlTableExists(conn, "gbCdnaInfo")) { sqlUpdate(conn, gbCdnaInfoCreate); haveGi = TRUE; haveMol = TRUE; } else { haveGi = sqlFieldIndex(conn, "gbCdnaInfo", "gi") >= 0; haveMol = sqlFieldIndex(conn, "gbCdnaInfo", "mol") >= 0; if (haveMol && !haveGi) errAbort("must have gi column to have mol"); } setGeneTblFlags(conn, options); if (!sqlTableExists(conn, "gbMiscDiff")) sqlUpdate(conn, gbMiscDiffCreate); if (!sqlTableExists(conn, "gbWarn")) sqlUpdate(conn, gbWarnCreate); if (gbCdnaInfoUpd == NULL) gbCdnaInfoUpd = sqlUpdaterNew("gbCdnaInfo", gTmpDir, (gbVerbose >= 4), &allUpdaters); if (gSrcDb == GB_REFSEQ) { if (!sqlTableExists(conn, "refSeqStatus")) { sqlUpdate(conn, refSeqStatusCreate); haveRsMol = TRUE; } else { haveRsMol = sqlFieldIndex(conn, "refSeqStatus", "mol") >= 0; } if (refSeqStatusUpd == NULL) refSeqStatusUpd = sqlUpdaterNew("refSeqStatus", gTmpDir, (gbVerbose >= 4), &allUpdaters); if (!sqlTableExists(conn, "refSeqSummary")) sqlUpdate(conn, refSeqSummaryCreate); if (refSeqSummaryUpd == NULL) refSeqSummaryUpd = sqlUpdaterNew("refSeqSummary", gTmpDir, (gbVerbose >= 4), &allUpdaters); if (!sqlTableExists(conn, "refLink")) sqlUpdate(conn, refLinkCreate); if (refLinkUpd == NULL) refLinkUpd = sqlUpdaterNew("refLink", gTmpDir, (gbVerbose >= 4), &allUpdaters); } }