コード例 #1
0
ファイル: pslToChain.c プロジェクト: ucscGenomeBrowser/kent
void pslToChain(char *pslIn, char *chainOut)
/* pslToChain - Extract multiple psl records. */
{
struct lineFile *lf = pslFileOpen(pslIn);
int chainId = 1;
int ii;
FILE *f = mustOpen(chainOut, "w");
struct psl *psl;
struct chain chain;

while ((psl = pslNext(lf) ) != NULL)
    {
    if (psl->strand[1] == '-') 
        {
        if (ignoreError)
            continue;
        errAbort("PSL record on line %d has '-' for target strand which is not allowed.", lf->lineIx);
        }

    chain.score = pslScore(psl);
    chain.id = chainId++;
    chain.tName = psl->tName;
    chain.tSize = psl->tSize;
    chain.tStart = psl->tStart;
    chain.tEnd = psl->tEnd;
    chain.qName = psl->qName;
    chain.qSize = psl->qSize;
    chain.qStrand = psl->strand[0];

    if (psl->strand[0] == '-')
        {
        chain.qEnd = psl->qSize - psl->qStart;
        chain.qStart = psl->qSize - psl->qEnd;
        }
    else
        {
        chain.qStart = psl->qStart;
        chain.qEnd = psl->qEnd;
        }
    chainWriteHead(&chain,f);

    for(ii=0; ii < psl->blockCount; ii++)
	{
	fprintf(f, "%d", psl->blockSizes[ii]);
	if (ii < psl->blockCount - 1)
	    fprintf(f, "\t%d\t%d", psl->tStarts[ii+1]-(psl->tStarts[ii] + psl->blockSizes[ii]),
		psl->qStarts[ii+1]-(psl->qStarts[ii] + psl->blockSizes[ii]));
	fprintf(f,"\n");
	}


    pslFree(&psl);
    }
}
コード例 #2
0
ファイル: chain.c プロジェクト: ma-compbio/RACA
void chainWrite(struct chain *chain, FILE *f)
/* Write out chain to file in usual format*/
{
struct cBlock *b, *nextB;

chainWriteHead(chain, f);
for (b = chain->blockList; b != NULL; b = nextB)
    {
    nextB = b->next;
    fprintf(f, "%d", b->qEnd - b->qStart);
    if (nextB != NULL)
	fprintf(f, "\t%d\t%d", 
		nextB->tStart - b->tEnd, nextB->qStart - b->qEnd);
    fputc('\n', f);
    }
fputc('\n', f);
}