static void chkGbStatusGbEntry(struct gbSelect* select, struct gbEntry* entry, struct metaData* md) /* check entry fields against status fields */ { /* processed entry should be the one matching the aligned update */ struct gbAligned* aligned = gbEntryFindAlignedVer(entry, md->gbsVersion); if (aligned == NULL) gbError("%s.%d: no genbank gbIndex aligned object for gbStatus", md->acc, md->gbsVersion); else { /* search for a processed entry matching this data and version */ struct gbProcessed* processed = entry->processed; while ((processed != NULL) && !((processed->modDate == md->gbsModDate) && (processed->version == md->gbsVersion))) processed = processed->next; if (processed == NULL) gbError("%s: no gbIndex processed entry for version %d, moddate %s, update %s", md->acc, md->gbsVersion, gbFormatDate(md->gbsModDate), aligned->update->name); if (aligned->numAligns != md->gbsNumAligns) gbError("%s.%d: genbank index number of alignments (%d) does not match gbStatus (%d)", md->acc, md->gbsVersion, aligned->numAligns, md->gbsNumAligns); } }
struct gbAligned* getMigrateAligned(struct migrateAligns* migrate, char* accVer, char* refFile) /* check if an acc is select for migration, and if so return it's * new gbAligned object. */ { char acc[GB_ACC_BUFSZ]; unsigned version = gbSplitAccVer(accVer, acc); struct gbEntry* prevEntry = getEntry(migrate->prevSelect, acc, refFile); /* Check that this a select acc of the right version */ if ((prevEntry != NULL) && (prevEntry->clientFlags & MIGRATE_FLAG) && (version == prevEntry->selectVer)) { /* need to check that this is the update for the first aligned entry * with this version. This handled a case were the same version * was aligned in multiple updates. This normally shouldn't happend. */ struct gbAligned* prevAligned = gbEntryFindAlignedVer(prevEntry, version); if (prevAligned->update == migrate->prevSelect->update) { /* ok, not get the current entry. Only null if igored */ struct gbEntry* entry = getEntry(migrate->select, acc, refFile); if (entry != NULL) return gbEntryGetAligned(entry, migrate->select->update, version, NULL); } } return NULL; }
void createAlignedIndex(struct gbSelect* select, char* alignIdx) /* create an alignment index from the alignRecs stored in the index. * it is not renamed from the tmp file name here, just closed */ { struct gbProcessed* processed; FILE *alignIdxFh; /* setup output PSL files */ gbAlignedGetPath(select, "alidx", NULL, alignIdx); alignIdxFh = gbMustOpenOutput(alignIdx); /* visit all processed entries for this update */ for (processed = select->update->processed; processed != NULL; processed = processed->updateLink) { struct gbEntry* entry = processed->entry; if ((entry->clientFlags & (MIGRATE_FLAG|ALIGN_FLAG)) && (entry->orgCat & select->orgCats)) { struct gbAligned* aligned = gbEntryFindAlignedVer(entry, processed->version); int numAligns = ((aligned != NULL) ? aligned->numAligns : 0); gbAlignedWriteIdxRec(alignIdxFh, entry->acc, processed->version, numAligns); } } carefulClose(&alignIdxFh); }
struct gbAligned* findPrevAligned(struct gbSelect* prevSelect, struct gbProcessed* processed) /* Check to see if a accession is in the prevAligned. If the organism * category of the alignment doesn't match the entry, it will be ignored. * This can happen if organism aliases are added or the organism name changed. */ { struct gbAligned* prevAligned = NULL; /* default if no previous */ struct gbEntry* prevEntry = gbReleaseFindEntry(prevSelect->release, processed->entry->acc); if (prevEntry != NULL) prevAligned = gbEntryFindAlignedVer(prevEntry, processed->version); if ((prevAligned != NULL) && (prevAligned->alignOrgCat != processed->entry->orgCat)) return NULL; /* ignore due to category change */ else return prevAligned; }