Beispiel #1
0
void copyPslXaToTab(char *pslFile, char *tabFile)
/* copy a single PSL XA to the tab file */
{
struct xAli *xa;
char *row[23];
struct lineFile *lf = lineFileOpen(pslFile, TRUE);
struct pipeline *pl = NULL;
FILE *tabFh = NULL;
if (noSort)
    tabFh = mustOpen(tabFile, "w");
else
    {
    if (pslCreateOpts & PSL_WITH_BIN)
	pl = pipelineOpen(outPipeBin, pipelineWrite, tabFile, NULL);
    else
	pl = pipelineOpen(outPipeNoBin, pipelineWrite, tabFile, NULL);
    tabFh = pipelineFile(pl);
    }
while (lineFileRow(lf, row))
    {
    xa = xAliLoad(row);
    if (pslCreateOpts & PSL_WITH_BIN)
        fprintf(tabFh, "%u\t", hFindBin(xa->tStart, xa->tEnd));
    xAliTabOut(xa, tabFh);
    xAliFree(&xa);
    }
lineFileClose(&lf);
if (noSort)
    carefulClose(&tabFh);
else
    {
    pipelineWait(pl);
    pipelineFree(&pl);
    }
}
Beispiel #2
0
void copyPslToTab(char *pslFile, char *tabFile)
/* copy a single PSL to the tab file */
{
struct psl *psl;
struct lineFile *lf = pslFileOpen(pslFile);
struct pipeline *pl = NULL;
FILE *tabFh = NULL;
if (noSort)
    tabFh = mustOpen(tabFile, "w");
else
    {
    if (pslCreateOpts & PSL_WITH_BIN)
	pl = pipelineOpen(outPipeBin, pipelineWrite, tabFile, NULL);
    else
	pl = pipelineOpen(outPipeNoBin, pipelineWrite, tabFile, NULL);
    tabFh = pipelineFile(pl);
    }
while ((psl = pslNext(lf)) != NULL)
    {
    if (pslCreateOpts & PSL_WITH_BIN)
        fprintf(tabFh, "%u\t", hFindBin(psl->tStart, psl->tEnd));
    pslTabOut(psl, tabFh);
    pslFree(&psl);
    }
lineFileClose(&lf);
if (noSort)
    carefulClose(&tabFh);
else
    {
    pipelineWait(pl);
    pipelineFree(&pl);
    }
}
Beispiel #3
0
void lineFileClose(struct lineFile **pLf)
/* Close up a line file. */
{
struct lineFile *lf;
if ((lf = *pLf) != NULL)
    {
    if (lf->pl != NULL)
        {
        pipelineWait(lf->pl);
        pipelineFree(&lf->pl);
        }
    else if (lf->fd > 0 && lf->fd != fileno(stdin))
	{
	close(lf->fd);
	freeMem(lf->buf);
	}
#ifdef USE_TABIX
    else if (lf->tabix != NULL)
	{
	if (lf->tabixIter != NULL)
	    ti_iter_destroy(lf->tabixIter);
	ti_close(lf->tabix);
	}
#endif // USE_TABIX
    freeMem(lf->fileName);
    metaDataFree(lf);
    freez(pLf);
    }
}
Beispiel #4
0
void textOutClose(struct pipeline **pCompressPipeline)
/* Flush and close stdout, wait for the pipeline to finish, and then free 
 * the pipeline object. */
{
if (pCompressPipeline && *pCompressPipeline)
    {
    fflush(stdout);
    fclose(stdout);
    pipelineWait(*pCompressPipeline);
    pipelineFree(pCompressPipeline);
    }
}
Beispiel #5
0
static void pslInputFree(struct pslInput **piPtr)
/* free pslInput object */
{
    struct pslInput *pi = *piPtr;
    if (pi != NULL)
    {
        assert(pi->pending == NULL);
        pipelineWait(pi->pl);
        pipelineFree(&pi->pl);
        freez(piPtr);
    }
}
Beispiel #6
0
void processFrameFiles(char *tabFile, int numFramesFiles, char **framesFiles)
/* combine and sort input files, adding bin column and write top tabFile */
{
/* sort by chrom location, accounting for bin column */
static char *cmd[] = {"sort", "-k", "2,2", "-k", "3,3n", NULL};
int i;
struct pipeline *pl = pipelineOpen1(cmd, pipelineWrite, tabFile, NULL);
FILE *sortFh = pipelineFile(pl);

for (i = 0; i < numFramesFiles; i++)
    processFrameFile(sortFh, framesFiles[i]);
pipelineWait(pl);
}
Beispiel #7
0
void lineFileClose(struct lineFile **pLf)
/* Close up a line file. */
{
struct lineFile *lf;
if ((lf = *pLf) != NULL)
    {
    if (lf->pl != NULL)
        {
        pipelineWait(lf->pl);
        pipelineFree(&lf->pl);
        }
    else if (lf->fd > 0 && lf->fd != fileno(stdin))
	{
	close(lf->fd);
	freeMem(lf->buf);
	}
    freeMem(lf->fileName);
    metaDataFree(lf);
    freez(pLf);
    }
}