Exemplo n.º 1
0
static int flagOrphans(struct sqlConnection *conn, struct gbSelect* select,
                       struct hash *seqHash, struct gbStatusTbl* statusTbl)
/* find orphans in gbSeq table that were not found in gbStatus and flag them
 *in the status table */
{
struct hashCookie cookie;
struct hashEl* hel;
int numOrphans = 0;

/* Find orphans using seqHash.  This was previously implemented using
 *     SELECT seq.acc FROM seq LEFT JOIN gbStatus ON (seq.acc = gbStatus.acc)
 *      WHERE (seq.type = '%s') AND (seq.srcDb = '%s')
 *      AND (gbStatus.seq IS NULL);
 * however this proved many times slower than reading the sequences into
 * a hash.
 */

cookie = hashFirst(seqHash);
while ((hel = hashNext(&cookie)) != NULL)
    {
    if (!hel->val)
        {
        struct gbStatus *status = gbStatusTblFind(statusTbl, hel->name);
        if (status != NULL)
            {
            status->stateChg |= GB_ORPHAN;
            if (!(status->stateChg & GB_NEW))
                errAbort("oprhaned seq entry for %s is not flaged as new",
                         status->acc);
            numOrphans++;
            }
        else
            {
            /* Orphan, but not in table. This could be an entry that was
             * deleted from gbStatus table by hand. Leave versions empty */
            fprintf(stderr, "Warning: %s is orphaned, but not a new entry, deleting\n",
                    hel->name);
            status = gbStatusTblAdd(statusTbl, hel->name,  0, 0, select->type,
                                    select->release->srcDb, 0, 0, 0,
                                    "", "", 0);
            slAddHead(&statusTbl->deleteList, status);
            statusTbl->numDelete++;
            status->stateChg = GB_DELETED;
            }
        }
    }
return numOrphans;
}
Exemplo n.º 2
0
static boolean processEntry(struct sqlConnection *conn,
                            struct gbStatusTbl* statusTbl,
                            HGID faFileId, HGID pepFaId)
/* Parse and process the next ra entry, check to see if it is selected
 * for update. */
{
char* acc;
struct gbStatus* status;

if ((acc = gbMDParseEntry()) == NULL)
    return FALSE;

status = gbStatusTblFind(statusTbl, acc);
if ((status != NULL) && (status->selectProc != NULL) && (!status->metaDone)
    && (status->selectProc->modDate == raModDate))
    updateMetaData(conn, status, statusTbl, faFileId, pepFaId);
return TRUE;
}
Exemplo n.º 3
0
static struct gbStatus *lookupStatus(char *accver, struct gbStatusTbl* statusTbl,
                                     struct lineFile *lf, short *versionPtr)
/* get the status entry for an accession if it is selected, return NULL if not
 * selected */
{
char acc[GB_ACC_BUFSZ];
short version = gbSplitAccVer(accver, acc);
if (version < 0)
    errAbort("entry name \"%s\" is not a genbank accession with version: %s:%d",
             accver, lf->fileName, lf->lineIx);

struct gbStatus* status = gbStatusTblFind(statusTbl, acc);
if ((status != NULL) && (status->selectAlign != NULL)
    && (status->selectAlign->version == version))
    {
    if (versionPtr != NULL)
        *versionPtr = version;
    return status;
    }
else
    return NULL;
}