コード例 #1
0
boolean copyFastaRec(struct gbSelect* select, struct gbFa* inFa,
                     struct outFa* nativeFa, struct outFa* xenoFa)
/* Read and copy a record to one of the output files, if selected */
{
char acc[GB_ACC_BUFSZ];
unsigned version;
struct gbEntry* entry;

if (!gbFaReadNext(inFa))
    return FALSE; /* EOF */

version = gbSplitAccVer(inFa->id, acc);
entry = gbReleaseFindEntry(select->release, acc);
if (entry != NULL)
    {
    char* seq = gbFaGetSeq(inFa);
    if (strlen(seq) < MIN_SEQ_SIZE)
        {
        if (gbVerbose >= 3)
            gbVerbPr(3, "skip %s, less than minimum sequence size", inFa->id);
        }
    else if ((version == entry->selectVer) && (entry->clientFlags & ALIGN_FLAG))
        {
        outFaWrite(((entry->orgCat == GB_NATIVE) ? nativeFa : xenoFa),  inFa);
        if (gbVerbose >= 3)
            gbVerbPr(3, "aligning %s %s", inFa->id,
                     gbOrgCatName(entry->orgCat));
        }
    else if ((version == entry->selectVer) && (entry->clientFlags & MIGRATE_FLAG))
        {
        if (gbVerbose >= 3)
            gbVerbPr(3, "migrating %s %s", inFa->id,
                     gbOrgCatName(entry->orgCat));
        }
    else 
        {
        assert(version != entry->selectVer);
        if (gbVerbose >= 3)
            gbVerbPr(3, "skip %s, wrong version %s != %d", 
                     gbOrgCatName(entry->orgCat), inFa->id,
                     entry->selectVer);
        }
    }
else
    {
    if (gbVerbose >= 3)
        gbVerbPr(3, "skip %s, no entry", inFa->id);
    }

return TRUE;
}
コード例 #2
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void copyPsl(struct gbSelect* select, unsigned pslFileType,
             struct psl* psl, char* inPsl,
             FILE* outPslFh, struct gbEntryCnts* counts)
/* Copy a PSL. */
{
char acc[GB_ACC_BUFSZ];
int version = gbSplitAccVer(psl->qName, acc);
struct gbAligned* aligned;
struct gbEntry* entry = getEntry(select, acc, inPsl);
if (entry == NULL)
    errAbort("no entry for %s %s in %s", gPslFileExt[pslFileType],
             psl->qName, inPsl);
aligned = gbEntryGetAligned(entry, select->update, version, NULL);
pslTabOut(psl, outPslFh);
if (pslFileType == MAIN_PSL_FILE)
    {
    /* count main psls in index. */
    gbAlignedCount(aligned, 1);
    /* increment accession count if this is * the first one */
    gbCountNeedAligned(counts, entry,
                           ((aligned->numAligns == 1) ? 1 : 0), 1);
    }
else
    {
    /* for rawPsl and intronPsl only count PSLs */
    gbCountNeedAligned(counts, entry, 0, 1);
    }
if (gbVerbose >= 3)
    gbVerbPr(3, "installing %s %s %s.%d", gbOrgCatName(entry->orgCat),
             gPslFileExt[pslFileType], acc, version);
}
コード例 #3
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void migrateAligned(struct gbSelect* select, struct gbSelect* prevSelect,
                    struct gbAlignInfo* alignInfo, struct outputFiles* out,
                    struct recCounts* recCounts)
/* Migrate existing aligned PSLs from an earlier release. */
{
int orgCatIdx = gbOrgCatIdx(select->orgCats);
struct gbUpdate* prevUpdateHold = prevSelect->update;
struct gbUpdate* prevUpdate;
struct migrateAligns migrate;
ZeroVar(&migrate);
migrate.select = select;
migrate.prevSelect = prevSelect;

/* traverse all updates in the previous release */
gbVerbEnter(1, "migrating alignments");
for (prevUpdate = prevSelect->release->updates; prevUpdate != NULL;
     prevUpdate = prevUpdate->next)
    {
    prevSelect->update = prevUpdate;
    migrateAlignedUpdate(prevSelect, &migrate, out, recCounts);
    }
prevSelect->update = prevUpdateHold;
recCountsSum(recCounts, &migrate.counts);
if (migrate.counts.pslCnts.recCnt[orgCatIdx] != alignInfo->migrate.recCnt[orgCatIdx])
    errAbort("expected to migrate %d %s PSLs, found %d",
             alignInfo->migrate.recCnt[orgCatIdx], gbOrgCatName(select->orgCats),
             migrate.counts.pslCnts.recCnt[orgCatIdx]);
gbVerbLeave(1, "migrating alignments");
}
コード例 #4
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void migratePsl(struct migrateAligns* migrate, unsigned pslFileType,
                struct gbEntryCnts* counts, struct psl* psl,
                char* inPsl, FILE* outPslFh)
/* Migrate PSL, if it's accession and version are flagged */
{
struct gbAligned* aligned = getMigrateAligned(migrate, psl->qName, inPsl);
if (aligned != NULL)
    {
    pslTabOut(psl, outPslFh);

    if (pslFileType == MAIN_PSL_FILE)
        {
        /* count main psls in index. */
        gbAlignedCount(aligned, 1);
        /* increment accession count if this is the first one */
        gbCountNeedAligned(counts, aligned->entry,
                           ((aligned->numAligns == 1) ? 1 : 0), 1);
        }
    else
        {
        /* for rawPsl and intronPsl only count PSLs */
        gbCountNeedAligned(counts, aligned->entry, 0, 1);
        }
    if (gbVerbose >= 3)
        gbVerbPr(3, "migrating %s %s %s",
                 gbOrgCatName(aligned->entry->orgCat), 
                 gPslFileExt[pslFileType], psl->qName);
    }
}
コード例 #5
0
static boolean loadEnabled(unsigned srcDb, unsigned type,
                           unsigned orgCat)
/* is load enabled for (srcDb, type, orgCat) */
{
struct dbLoadAttr* attr
    = dbLoadOptionsGetAttr(&gOptions, srcDb, type, orgCat);
verbose(1, "%s %s %s: %s\n", gbSrcDbName(srcDb), gbTypeName(type),
        gbOrgCatName(orgCat), (attr->load ? "enabled" : "disabled"));
return attr->load;
}
コード例 #6
0
void outFaClose(struct outFa* outFa)
/* close file and output file path.  Doesn't delete object */
{
if (outFa->fa != NULL)
    {
    printf("alignFa: %s %s %d %lld\n", outFa->fa->fileName,
           gbOrgCatName(outFa->select.orgCats), outFa->numSeqs,
           outFa->numBases);
    gbFaClose(&outFa->fa);
    carefulClose(&outFa->polyAFh);
    }
}
コード例 #7
0
ファイル: gbAlignCommon.c プロジェクト: davidhoover/kent
static void flagNeedAligned(struct gbSelect* select,
                            struct gbSelect* prevSelect,
                            struct gbProcessed* processed,
                            struct gbAlignInfo* alignInfo)
/* Function called for each sequence to set alignment and migrate flags.  The
 * migrate flag is set in the previous and curent entries, the align flag set
 * in only in current ones. */
{
struct gbAligned* prevAligned = NULL;
if (prevSelect != NULL)
    prevAligned = findPrevAligned(prevSelect, processed);

/* Migrate if same acc is aligned in the previous release and passed other
 * checks, otherwise mark the entry for alignment. */
if ((prevAligned != NULL) && canMigrate(processed, prevAligned))
    {
    struct gbEntry* prevEntry = prevAligned->entry;
    prevEntry->selectVer = prevAligned->version;
    prevEntry->clientFlags |= MIGRATE_FLAG;
    processed->entry->clientFlags |= MIGRATE_FLAG;
    prevAligned->update->selectAlign |= prevEntry->orgCat;
    gbCountNeedAligned(&alignInfo->migrate, prevEntry, 1, prevAligned->numAligns);
    if (gbVerbose >= 3)
        gbVerbPr(3, "migrate %s %s.%d %d psls", 
                 gbOrgCatName(prevEntry->orgCat), prevEntry->acc,
                 prevAligned->version, prevAligned->numAligns);
    }
else
    {
    struct gbEntry* entry = processed->entry;
    entry->selectVer = processed->version;
    entry->clientFlags |= ALIGN_FLAG;
    processed->update->selectProc |= entry->orgCat;
    gbCountNeedAligned(&alignInfo->align, entry, 1, 0);
    if (gbVerbose >= 3)
        gbVerbPr(3, "align %s %s.%d", gbOrgCatName(entry->orgCat),
                 entry->acc, processed->version);
    }
}
コード例 #8
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void migrateOrientInfo(struct migrateAligns* migrate,
                       struct estOrientInfo* oi, char* inOi, FILE* outOiFh)
/* Migrate a estOrientInfo row, if it's accession and version are flagged */
{
struct gbAligned* aligned = getMigrateAligned(migrate, oi->name, inOi);
if (aligned != NULL)
    {
    if (gbVerbose >= 3)
        gbVerbPr(3, "migrating %s oi %s",
                 gbOrgCatName(aligned->entry->orgCat), oi->name);
    estOrientInfoTabOut(oi, outOiFh);
    /* just count records */
    gbCountNeedAligned(&migrate->counts.oiCnts, aligned->entry, 0, 1);
    }
}
コード例 #9
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void copyIntronPsl(struct gbSelect* select, struct psl* psl, char* inPsl,
                   FILE* outPslFh, struct recCounts* recCounts)
/* Copy an intronPsl. */
{
char acc[GB_ACC_BUFSZ];
struct gbEntry* entry;
gbSplitAccVer(psl->qName, acc);
entry = getEntry(select, acc, inPsl);
if (entry != NULL)
    {
    if (gbVerbose >= 3)
        gbVerbPr(3, "installing %s intronPsl %s", gbOrgCatName(entry->orgCat),
                 psl->qName);
    pslTabOut(psl, outPslFh);
    /* just count records */
    gbCountNeedAligned(&recCounts->intronPslCnts, entry, 0, 1);
    }
}
コード例 #10
0
ファイル: gbAlignInstall.c プロジェクト: davidhoover/kent
void copyOrientInfo(struct gbSelect* select, struct estOrientInfo* oi,
                    char* inOi, FILE* outOiFh, struct recCounts* recCounts)
/* Copy a orientInfo record. */
{
char acc[GB_ACC_BUFSZ];
struct gbEntry* entry;
gbSplitAccVer(oi->name, acc);
entry = getEntry(select, acc, inOi);
if (entry != NULL)
    {
    if (gbVerbose >= 3)
        gbVerbPr(3, "installing %s oi %s", gbOrgCatName(entry->orgCat),
                 oi->name);
    estOrientInfoTabOut(oi, outOiFh);
    /* just count records */
    gbCountNeedAligned(&recCounts->oiCnts, entry, 0, 1);
    }
}
コード例 #11
0
void chkMetaDataGbEntry(struct metaDataTbls* metaDataTbls,
                        struct gbSelect* select, struct gbEntry* entry)
/* Check metadata against a gbEntry object */
{
struct metaData* md = metaDataTblsGet(metaDataTbls, entry->acc);
md->inGbIndex = TRUE;
md->inGbAlign = (entry->aligned != NULL);
md->isNative = (entry->orgCat == GB_NATIVE);  /* FIXME: dup field */
md->typeFlags |= ((entry->orgCat == GB_NATIVE) ? GB_NATIVE : GB_XENO);
md->excluded = ((entry->orgCat & select->orgCats) == 0);

if (md->inGbStatus)
    {
    if (md->excluded)
        gbError("%s: excluded (%s) entry should not be in gbStatus table",
                gbOrgCatName(entry->orgCat), entry->acc);
    else
        chkGbStatusGbEntry(select, entry, md);
    }
}