Exemplo n.º 1
0
void migratePsls(struct migrateAligns* migrate, unsigned pslFileType,
                 struct gbEntryCnts* counts, FILE* outPslFh)
/* Migrate selected PSL records */
{
char inPsl[PATH_LEN];
struct lineFile* inPslLf;
struct psl* psl;

gbAlignedGetPath(migrate->prevSelect, gPslFileGzExt[pslFileType], NULL, inPsl);

/* It's possible to end up here and not have a file if none of the sequences
 * aligned */
if (fileExists(inPsl))
    {
    gbVerbEnter(2, "migrating %ss from %s", gPslFileExt[pslFileType], inPsl);
    inPslLf = gzLineFileOpen(inPsl);
    while ((psl = pslNext(inPslLf)) != NULL)
        {
        migratePsl(migrate, pslFileType, counts, psl, inPsl, outPslFh);
        pslFree(&psl);
        }
    gzLineFileClose(&inPslLf);
    gbVerbLeave(2, "migrating %ss from %s", gPslFileExt[pslFileType], inPsl);
    }
}
void loadMgcStatus(struct sqlConnection *conn, char *mgcStatusTab, char *statusTblName)
/* load the mgcStatus or mgcFullStatus tables, return name loaded */
{
struct lineFile* inLf;
FILE *outFh;
char tmpFile[PATH_LEN];
gbVerbEnter(2, "loading %s", statusTblName);

/* uncompress to tmp file */
safef(tmpFile, sizeof(tmpFile), "%s/mgcStatus.%s.%d.tmp", workDir,
      getHost(), getpid());
inLf = gzLineFileOpen(mgcStatusTab);
outFh = gzMustOpen(tmpFile, "w");

while (mgcStatusTblCopyRow(inLf, outFh))
    continue;

gzClose(&outFh);
gzLineFileClose(&inLf);

mgcStatusTblCreate(conn, statusTblName);

sqlLoadTabFile(conn, tmpFile, statusTblName, SQL_TAB_FILE_ON_SERVER);
unlink(tmpFile);

gbVerbLeave(2, "loading %s", statusTblName);
}
Exemplo n.º 3
0
static void procOneGbffFile(char *inName, struct hash *estAuthorHash)
/* Process one genBank file in flat-file format into fa and ra files. */
{
struct lineFile *lf = gzLineFileOpen(inName);

while (gbfReadFields(lf))
    procGbEntry(lf, estAuthorHash);
gzLineFileClose(&lf);
}
Exemplo n.º 4
0
void copyRefSeqPepFa(struct gbUpdate* update,
                     char* outDir, char *gbFile)
/* copy a subset of the RefSeq peptide file for the select genes */
{
struct gbRelease* release = update->release;
char faInPath[PATH_LEN];
char faOutPath[PATH_LEN];
struct lineFile* inLf;
boolean copying = FALSE;
FILE* outFh;
char* line;

/* change the .gbff.Z suffix to .fsa.Z */
if (!endsWith(gbFile, ".gbff.Z"))
    errAbort("expected a file ending in .gbff.Z, got: %s", gbFile);
strcpy(faInPath, gbFile);
faInPath[strlen(faInPath)-7] = '\0';
strcat(faInPath, ".fsa.Z");

strcpy(faOutPath, outDir);
strcat(faOutPath, "/");
strcat(faOutPath, faInPath);

verbose(1, "copying from %s\n", faInPath);

/* copy selected, don't bother with fa readers */
inLf = gzLineFileOpen(faInPath);
outFh = gbMustOpenOutput(faOutPath);

while (lineFileNext(inLf, &line, NULL))
    {
    if (line[0] == '>')
        {
        char *geneAcc = parsePepGeneAcc(line);
        struct gbEntry* entry = NULL;
        if (geneAcc != NULL)
            entry = gbReleaseFindEntry(release, geneAcc);
        copying = ((entry != NULL) && (entry->selectVer > 0));
	verbose(2, "acc for pep: %s: %s\n", geneAcc,
		(copying ? "yes" : "no"));
        }
    if (copying)
        {
        fputs(line, outFh);
        fputc('\n', outFh);
        if (ferror(outFh))
            errnoAbort("write failed: %s: ", faOutPath);
        }
    }

gbOutputRename(faOutPath, &outFh);
gzLineFileClose(&inLf);
}
Exemplo n.º 5
0
static void processOIFile(struct sqlConnection *conn, struct gbSelect* select,
                          struct gbStatusTbl* statusTbl, char* oiPath)
/* Parse a psl file looking for accessions to add to the database. */
{
char *row[EST_ORIENT_INFO_NUM_COLS];
struct lineFile *oiLf = gzLineFileOpen(oiPath);
while (lineFileNextRow(oiLf, row, EST_ORIENT_INFO_NUM_COLS))
    {
    struct estOrientInfo* oi = estOrientInfoLoad(row);
    processOI(conn, select, statusTbl, oi, oiLf);
    estOrientInfoFree(&oi);
    }
gzLineFileClose(&oiLf);
}
Exemplo n.º 6
0
static void processPslFile(struct sqlConnection *conn, struct gbSelect* select,
                           struct gbStatusTbl* statusTbl, char* pslPath)
/* Parse a psl file looking for accessions to add to the database. */
{
char* row[PSL_NUM_COLS];
struct lineFile *pslLf = gzLineFileOpen(pslPath);
while (lineFileNextRow(pslLf, row, PSL_NUM_COLS))
    {
    struct psl* psl = pslLoad(row);
    processPsl(conn, select, statusTbl, psl, pslLf);
    pslFree(&psl);
    }
gzLineFileClose(&pslLf);
}
struct mgcLibraryTbl *mgcLibraryTblLoad(char *fileName)
/* load a file of mgcLibrary objects, building a hash by library id */
{
struct mgcLibraryTbl *mlt;
char *row[MGCLIBRARY_NUM_COLS];
char key[64];
struct lineFile *lf;
AllocVar(mlt);
mlt->idHash = hashNew(12); /* 4096 */

lf = gzLineFileOpen(fileName);
while (lineFileNextRowTab(lf, row, MGCLIBRARY_NUM_COLS))
    {
    struct mgcLibrary *mgcLibrary = mgcLibraryLoad(row);
    safef(key, sizeof(key), "%d", mgcLibrary->id_lib);
    hashAdd(mlt->idHash, key, mgcLibrary);
    }

gzLineFileClose(&lf);
return mlt;
}
Exemplo n.º 8
0
static void processOrgCatOi(struct gbSelect* select, unsigned orgCat)
/* process files in an update an organism category.  OIs are only available
 * for native, however this follow the structure of the PSL code */
{
char inOi[PATH_LEN], *row[EST_ORIENT_INFO_NUM_COLS];
struct lineFile* inOiLf;
unsigned orgCatsHold = select->orgCats;
select->orgCats = orgCat;

gbAlignedGetPath(select, "oi.gz", NULL, inOi);

inOiLf = gzLineFileOpen(inOi);
while (lineFileNextRowTab(inOiLf, row, EST_ORIENT_INFO_NUM_COLS))
    {
    struct estOrientInfo* oi = estOrientInfoLoad(row);
    processOi(select, oi);
    estOrientInfoFree(&oi);
    }
gzLineFileClose(&inOiLf);
select->orgCats = orgCatsHold;
}
Exemplo n.º 9
0
void copyIntronPsls(struct gbSelect* select, FILE* outPslFh,
                    struct recCounts* recCounts)
/* Copy an intron PSL file from the work directory if it exists */
{
char inPsl[PATH_LEN];
struct lineFile* inPslLf;
struct psl* psl;

gbAlignedGetPath(select, "intronPsl", gWorkDir, inPsl);
if (fileExists(inPsl))
    {
    gbVerbEnter(2, "installing from %s", inPsl);
    inPslLf = gzLineFileOpen(inPsl);
    while ((psl = pslNext(inPslLf)) != NULL)
        {
        copyIntronPsl(select, psl, inPsl, outPslFh, recCounts);
        pslFree(&psl);
        }
    gzLineFileClose(&inPslLf);
    gbVerbLeave(2, "installing from %s", inPsl);
    }
}
Exemplo n.º 10
0
void copyPsls(struct gbSelect* select, unsigned pslFileType, FILE* outPslFh,
              struct gbEntryCnts* counts)
/* Copy a PSL file from the work directory if it exists, count alignments
 * for index. */
{
char inPsl[PATH_LEN];
struct lineFile* inPslLf;
struct psl* psl;

gbAlignedGetPath(select, gPslFileExt[pslFileType], gWorkDir, inPsl);
if (fileExists(inPsl))
    {
    gbVerbEnter(2, "installing from %s", inPsl);
    inPslLf = gzLineFileOpen(inPsl);
    while ((psl = pslNext(inPslLf)) != NULL)
        {
        copyPsl(select, pslFileType, psl, inPsl, outPslFh, counts);
        pslFree(&psl);
        }
    gzLineFileClose(&inPslLf);
    gbVerbLeave(2, "installing from %s", inPsl);
    }
}
Exemplo n.º 11
0
void migrateOrientInfos(struct migrateAligns* migrate, FILE* outOiFh)
/* Migrate estOrientInfo records */
{
char inOi[PATH_LEN];
struct lineFile* inOiLf;
char *row[EST_ORIENT_INFO_NUM_COLS];

gbAlignedGetPath(migrate->prevSelect, "oi.gz", NULL, inOi);

if (fileExists(inOi))
    {
    gbVerbEnter(2, "migrating from %s", inOi);
    inOiLf = gzLineFileOpen(inOi);
    while (lineFileNextRowTab(inOiLf, row, ArraySize(row)))
        {
        struct estOrientInfo *oi = estOrientInfoLoad(row);
        migrateOrientInfo(migrate, oi, inOi, outOiFh);
        estOrientInfoFree(&oi);
        }
    gzLineFileClose(&inOiLf);
    gbVerbLeave(2, "migrating from %s", inOi);
    }
}
static struct sqlDeleter* buildReloadDeleter(char *reloadList, unsigned srcDb, char *tmpDir)
/* read reload list, building a deleter for the specified source DB */
{
struct sqlDeleter* deleter = NULL;
struct lineFile *lf = gzLineFileOpen(reloadList);
int cnt = 0;
char *row[1];

while (lineFileChopNext(lf, row, ArraySize(row)))
    {
    char *acc = trimSpaces(row[0]);
    if (gbGuessSrcDb(acc) == srcDb)
        {
        if (deleter == NULL)
            deleter = sqlDeleterNew(tmpDir, (gbVerbose >= 4));
        sqlDeleterAddAcc(deleter, acc);
        cnt++;
        gbVerbMsg(5, "%s delete for reloading", acc);
        }
    }
gzLineFileClose(&lf);
gbVerbMsg(1, "delete %d entries for reloading", cnt);
return deleter;
}
Exemplo n.º 13
0
void copyOrientInfos(struct gbSelect* select, FILE* outOiFh,
                     struct recCounts* recCounts)
/* Copy an OI file from the work directory, if it exists, count alignments
 * for index. */
{
char inOi[PATH_LEN];
struct lineFile* inOiLf;
char *row[EST_ORIENT_INFO_NUM_COLS];

gbAlignedGetPath(select, "oi", gWorkDir, inOi);
if (fileExists(inOi))
    {
    gbVerbEnter(2, "installing from %s", inOi);
    inOiLf = gzLineFileOpen(inOi);
    while (lineFileNextRowTab(inOiLf, row, ArraySize(row)))
        {
        struct estOrientInfo *oi = estOrientInfoLoad(row);
        copyOrientInfo(select, oi, inOi, outOiFh, recCounts);
        estOrientInfoFree(&oi);
        }
    gzLineFileClose(&inOiLf);
    gbVerbLeave(2, "installing from %s", inOi);
    }
}