lib/chainToAxt.c File Reference

#include "common.h"
#include "chain.h"
#include "dnautil.h"
#include "dnaseq.h"
#include "axt.h"
#include "chainToAxt.h"

Include dependency graph for chainToAxt.c:

Go to the source code of this file.

Functions

static struct axtaxtFromBlocks (struct chain *chain, struct cBlock *startB, struct cBlock *endB, struct dnaSeq *qSeq, int qOffset, struct dnaSeq *tSeq, int tOffset)
axtchainToAxt (struct chain *chain, struct dnaSeq *qSeq, int qOffset, struct dnaSeq *tSeq, int tOffset, int maxGap, int maxChain)

Variables

static char const rcsid [] = "$Id: chainToAxt.c,v 1.4 2005/04/10 14:41:21 markd Exp $"


Function Documentation

static struct axt* axtFromBlocks ( struct chain chain,
struct cBlock startB,
struct cBlock endB,
struct dnaSeq qSeq,
int  qOffset,
struct dnaSeq tSeq,
int  tOffset 
) [static, read]

Definition at line 12 of file chainToAxt.c.

References AllocVar, axtScoreDnaDefault(), blockSize, cloneString(), dnaSeq::dna, needLargeMem(), cBlock::next, axt::qEnd, cBlock::qEnd, chain::qName, axt::qName, axt::qStart, cBlock::qStart, chain::qStrand, axt::qStrand, axt::qSym, axt::score, axt::symCount, axt::tEnd, cBlock::tEnd, chain::tName, axt::tName, axt::tStart, cBlock::tStart, axt::tStrand, and axt::tSym.

Referenced by chainToAxt().

00019 {
00020 int symCount = 0;
00021 int dq, dt, blockSize = 0, symIx = 0;
00022 struct cBlock *b, *a = NULL;
00023 struct axt *axt;
00024 char *qSym, *tSym;
00025 
00026 /* Make a pass through figuring out how big output will be. */
00027 for (b = startB; b != endB; b = b->next)
00028     {
00029     if (a != NULL)
00030         {
00031         dq = b->qStart - a->qEnd;
00032         dt = b->tStart - a->tEnd;
00033         symCount += dq + dt;
00034         }
00035     blockSize = b->qEnd - b->qStart;
00036     symCount += blockSize;
00037     a = b;
00038     }
00039 
00040 /* Allocate axt and fill in most fields. */
00041 AllocVar(axt);
00042 axt->qName = cloneString(chain->qName);
00043 axt->qStart = startB->qStart;
00044 axt->qEnd = a->qEnd;
00045 axt->qStrand = chain->qStrand;
00046 axt->tName = cloneString(chain->tName);
00047 axt->tStart = startB->tStart;
00048 axt->tEnd = a->tEnd;
00049 axt->tStrand = '+';
00050 axt->symCount = symCount;
00051 axt->qSym = qSym = needLargeMem(symCount+1);
00052 qSym[symCount] = 0;
00053 axt->tSym = tSym = needLargeMem(symCount+1);
00054 tSym[symCount] = 0;
00055 
00056 /* Fill in symbols. */
00057 a = NULL;
00058 for (b = startB; b != endB; b = b->next)
00059     {
00060     if (a != NULL)
00061         {
00062         dq = b->qStart - a->qEnd;
00063         dt = b->tStart - a->tEnd;
00064         if (dq == 0)
00065             {
00066             memset(qSym+symIx, '-', dt);
00067             memcpy(tSym+symIx, tSeq->dna + a->tEnd - tOffset, dt);
00068             symIx += dt;
00069             }
00070         else
00071             {
00072             assert(dt == 0);
00073             memset(tSym+symIx, '-', dq);
00074             memcpy(qSym+symIx, qSeq->dna + a->qEnd - qOffset, dq);
00075             symIx += dq;
00076             }
00077         }
00078     blockSize = b->qEnd - b->qStart;
00079     memcpy(qSym+symIx, qSeq->dna + b->qStart - qOffset, blockSize);
00080     memcpy(tSym+symIx, tSeq->dna + b->tStart - tOffset, blockSize);
00081     symIx += blockSize;
00082     a = b;
00083     }
00084 assert(symIx == symCount);
00085 
00086 /* Fill in score and return. */
00087 axt->score = axtScoreDnaDefault(axt);
00088 return axt;
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct axt* chainToAxt ( struct chain chain,
struct dnaSeq qSeq,
int  qOffset,
struct dnaSeq tSeq,
int  tOffset,
int  maxGap,
int  maxChain 
) [read]

Definition at line 91 of file chainToAxt.c.

References axtFromBlocks(), chain::blockList, cBlock::next, cBlock::qStart, slAddHead, slReverse(), and cBlock::tStart.

00099 {
00100 struct cBlock *startB = chain->blockList, *a = NULL, *b;
00101 struct axt *axtList = NULL, *axt;
00102 
00103 for (b = chain->blockList; b != NULL; b = b->next)
00104     {
00105     if (a != NULL)
00106         {
00107         int dq = b->qStart - a->qEnd;
00108         int dt = b->tStart - a->tEnd;
00109         if ((dq > 0 && dt > 0) || dt > maxGap || dq > maxGap || (b->tEnd - startB->tStart) > maxChain)
00110             {
00111             axt = axtFromBlocks(chain, startB, b, qSeq, qOffset, tSeq, tOffset);
00112             slAddHead(&axtList, axt);
00113             startB = b;
00114             }
00115         }
00116     a = b;
00117     }
00118 axt = axtFromBlocks(chain, startB, NULL, qSeq, qOffset, tSeq, tOffset);
00119 slAddHead(&axtList, axt);
00120 slReverse(&axtList);
00121 return axtList;
00122 }

Here is the call graph for this function:


Variable Documentation

char const rcsid[] = "$Id: chainToAxt.c,v 1.4 2005/04/10 14:41:21 markd Exp $" [static]

Definition at line 10 of file chainToAxt.c.


Generated on Tue Dec 25 19:37:44 2007 for blat by  doxygen 1.5.2