inc/blastParse.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  blastFile
struct  blastQuery
struct  blastGappedAli
struct  blastBlock

Functions

blastFileblastFileReadAll (char *fileName)
blastFileblastFileOpenVerify (char *fileName)
blastQueryblastFileNextQuery (struct blastFile *bf)
blastGappedAliblastFileNextGapped (struct blastFile *bf, struct blastQuery *bq)
blastBlockblastFileNextBlock (struct blastFile *bf, struct blastQuery *bq, struct blastGappedAli *bga)
void blastFileFree (struct blastFile **pBf)
void blastFileFreeList (struct blastFile **pList)
void blastQueryFree (struct blastQuery **pBq)
void blastQueryFreeList (struct blastQuery **pList)
void blastGappedAliFree (struct blastGappedAli **pBga)
void blastGappedAliFreeList (struct blastGappedAli **pList)
void blastBlockFree (struct blastBlock **pBb)
void blastBlockFreeList (struct blastBlock **pList)
void blastBlockPrint (struct blastBlock *bb, FILE *out)
void blastGappedAliPrint (struct blastGappedAli *ba, FILE *out)
void blastQueryPrint (struct blastQuery *bq, FILE *out)


Function Documentation

void blastBlockFree ( struct blastBlock **  pBb  ) 

Definition at line 694 of file blastParse.c.

References freeMem(), freez(), blastBlock::qSym, and blastBlock::tSym.

Referenced by blastBlockFreeList(), and nextBlock().

00696 {
00697 struct blastBlock *bb = *pBb;
00698 if (bb != NULL)
00699     {
00700     freeMem(bb->qSym);
00701     freeMem(bb->tSym);
00702     freez(pBb);
00703     }
00704 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastBlockFreeList ( struct blastBlock **  pList  ) 

Definition at line 706 of file blastParse.c.

References blastBlockFree(), and blastBlock::next.

Referenced by blastGappedAliFree().

00708 {
00709 struct blastBlock *el, *next;
00710 for (el = *pList; el != NULL; el = next)
00711     {
00712     next = el->next;
00713     blastBlockFree(&el);
00714     }
00715 *pList = NULL;
00716 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastBlockPrint ( struct blastBlock bb,
FILE *  out 
)

Definition at line 718 of file blastParse.c.

References blastBlock::insertCount, blastBlock::matchCount, blastBlock::qEnd, blastBlock::qStart, blastBlock::qSym, blastBlock::tEnd, blastBlock::totalCount, blastBlock::tStart, and blastBlock::tSym.

Referenced by blastGappedAliPrint().

00720 {
00721 fprintf(out, "    blk: %d-%d <=> %d-%d tcnt=%d mcnt=%d icnt=%d\n",
00722         bb->qStart, bb->qEnd,  bb->tStart, bb->tEnd,
00723         bb->totalCount, bb->matchCount, bb->insertCount);
00724 fprintf(out, "        Q: %s\n", bb->qSym);
00725 fprintf(out, "        T: %s\n", bb->tSym);
00726 }

Here is the caller graph for this function:

void blastFileFree ( struct blastFile **  pBf  ) 

Definition at line 615 of file blastParse.c.

References blastQueryFreeList(), blastFile::buildDate, blastFile::fileName, freeMem(), freez(), blastFile::lf, lineFileClose(), blastFile::program, blastFile::queries, and blastFile::version.

Referenced by blastFileFreeList().

00617 {
00618 struct blastFile *bf = *pBf;
00619 if (bf != NULL)
00620     {
00621     lineFileClose(&bf->lf);
00622     freeMem(bf->fileName);
00623     freeMem(bf->program);
00624     freeMem(bf->version);
00625     freeMem(bf->buildDate);
00626     blastQueryFreeList(&bf->queries);
00627     freez(pBf);
00628     }
00629 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastFileFreeList ( struct blastFile **  pList  ) 

Definition at line 631 of file blastParse.c.

References blastFileFree(), and blastFile::next.

00633 {
00634 struct blastFile *el, *next;
00635 for (el = *pList; el != NULL; el = next)
00636     {
00637     next = el->next;
00638     blastFileFree(&el);
00639     }
00640 *pList = NULL;
00641 }

Here is the call graph for this function:

struct blastBlock* blastFileNextBlock ( struct blastFile bf,
struct blastQuery bq,
struct blastGappedAli bga 
) [read]

Definition at line 601 of file blastParse.c.

References FALSE, and nextBlock().

Referenced by blastFileNextGapped().

00605 {
00606 struct blastBlock *bb = NULL;
00607 boolean skip = FALSE;
00608 
00609 while (((bb = nextBlock(bf, bq, bga, &skip)) == NULL) && skip)
00610     continue; /* skip to next one */
00611 
00612 return bb;
00613 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct blastGappedAli* blastFileNextGapped ( struct blastFile bf,
struct blastQuery bq 
) [read]

Definition at line 286 of file blastParse.c.

References AllocVar, bfError(), bfNeedNextLine(), bfNextLine(), bfSkipBlankLines(), blastFileNextBlock(), blastGappedAli::blocks, chopLine, cloneString(), decomma(), blastGappedAli::query, sameString, slAddHead, slReverse(), startsWith(), blastGappedAli::targetName, blastGappedAli::targetSize, TRACE_LEVEL, and verbose().

Referenced by blastFileNextQuery().

00289 {
00290 char *line;
00291 char *words[16];
00292 int wordCount;
00293 struct blastGappedAli *bga;
00294 struct blastBlock *bb;
00295 int lenSearch;
00296 
00297 verbose(TRACE_LEVEL, "blastFileNextGapped\n");
00298 AllocVar(bga);
00299 bga->query = bq;
00300 
00301 /* First line should be query. */
00302 if (!bfSkipBlankLines(bf))
00303     return NULL;
00304 line = bfNextLine(bf);
00305 if (startsWith("  Database:", line))
00306     return NULL;
00307 if (line[0] != '>')
00308     bfError(bf, "Expecting >target");
00309 bga->targetName = cloneString(line+1); 
00310 
00311 /* Process something like:
00312  *      Length = 100000
00313  * however this follows a possible multi-line description, so be specified
00314  * and limit how far we can scan
00315  */
00316 for (lenSearch=0; lenSearch<25; lenSearch++)
00317         {
00318         line = bfNeedNextLine(bf);
00319         wordCount = chopLine(line, words);
00320         if (wordCount == 3 && sameString(words[0], "Length") &&  sameString(words[1], "=")
00321             && isdigit(words[2][0]))
00322                 break;
00323         }
00324 if (lenSearch>=25)
00325     bfError(bf, "Expecting Length =");
00326 decomma(words[2]);
00327 bga->targetSize = atoi(words[2]);
00328 
00329 /* Get all the blocks. */
00330 while ((bb = blastFileNextBlock(bf, bq, bga)) != NULL)
00331     {
00332     slAddHead(&bga->blocks, bb);
00333     }
00334 slReverse(&bga->blocks);
00335 return bga;
00336 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct blastQuery* blastFileNextQuery ( struct blastFile bf  )  [read]

Definition at line 237 of file blastParse.c.

References AllocVar, bfNeedNextLine(), bfSearchForLine(), bfUnexpectedEof(), blastFileNextGapped(), blastQueryPrint(), DUMP_LEVEL, blastQuery::gapped, lineFileReuse(), parseDatabaseLines(), parseQueryLines(), slAddHead, slReverse(), stringIn, TRACE_LEVEL, verbose(), and verboseLevel().

Referenced by blastFileReadAll().

00239 {
00240 char *line;
00241 struct blastQuery *bq;
00242 struct blastGappedAli *bga;
00243 AllocVar(bq);
00244 
00245 verbose(TRACE_LEVEL, "blastFileNextQuery\n");
00246 
00247 /* find and parse Query= */
00248 line = bfSearchForLine(bf, "Query=");
00249 if (line == NULL)
00250     return NULL;
00251 parseQueryLines(bf, line, bq);
00252 
00253 /* find and parse Database: */
00254 line = bfSearchForLine(bf, "Database:");
00255 if (line == NULL)
00256     bfUnexpectedEof(bf);
00257 parseDatabaseLines(bf, line, bq);
00258 
00259 /* Seek to beginning of first gapped alignment. */
00260 for (;;)
00261     {
00262     line = bfNeedNextLine(bf);
00263     if (line[0] == '>')
00264         {
00265         lineFileReuse(bf->lf);
00266         break;
00267         }
00268     if (stringIn("No hits found", line) != NULL)
00269         break;
00270     }
00271 
00272 /* Read in gapped alignments. */
00273 while ((bga = blastFileNextGapped(bf, bq)) != NULL)
00274     {
00275     slAddHead(&bq->gapped, bga);
00276     }
00277 slReverse(&bq->gapped);
00278 if (verboseLevel() >= DUMP_LEVEL)
00279     {
00280     verbose(DUMP_LEVEL, "blastFileNextQuery result:\n");
00281     blastQueryPrint(bq, stderr);
00282     }
00283 return bq;
00284 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct blastFile* blastFileOpenVerify ( char *  fileName  )  [read]

Definition at line 108 of file blastParse.c.

References AllocVar, bfBadHeader(), bfNeedNextLine(), blastFile::buildDate, chopLine, cloneString(), blastFile::fileName, blastFile::lf, lineFileOpen(), blastFile::program, TRUE, blastFile::version, and wildMatch().

Referenced by blastFileReadAll().

00110 {
00111 struct blastFile *bf;
00112 char *line;
00113 char *words[16];
00114 int wordCount;
00115 struct lineFile *lf;
00116 
00117 AllocVar(bf);
00118 bf->lf = lf = lineFileOpen(fileName, TRUE);
00119 bf->fileName = cloneString(fileName);
00120 
00121 /* Parse first line - something like: */
00122 line = bfNeedNextLine(bf);
00123 wordCount = chopLine(line, words);
00124 if (wordCount < 3)
00125     bfBadHeader(bf);
00126 bf->program = cloneString(words[0]);
00127 bf->version = cloneString(words[1]);
00128 bf->buildDate = cloneString(words[2]);
00129 if (!wildMatch("*BLAST*", bf->program))
00130     bfBadHeader(bf);
00131 if (!isdigit(bf->version[0]))
00132     bfBadHeader(bf);
00133 if (bf->buildDate[0] != '[')
00134     bfBadHeader(bf);
00135 return bf;
00136 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct blastFile* blastFileReadAll ( char *  fileName  )  [read]

Definition at line 13 of file blastParse.c.

References blastFileNextQuery(), blastFileOpenVerify(), blastFile::lf, lineFileClose(), blastFile::queries, slAddHead, and slReverse().

00015 {
00016 struct blastFile *bf;
00017 struct blastQuery *bq;
00018 
00019 bf = blastFileOpenVerify(fileName);
00020 while ((bq = blastFileNextQuery(bf)) != NULL)
00021     {
00022     slAddHead(&bf->queries, bq);
00023     }
00024 slReverse(&bf->queries);
00025 lineFileClose(&bf->lf);
00026 return bf;
00027 }

Here is the call graph for this function:

void blastGappedAliFree ( struct blastGappedAli **  pBga  ) 

Definition at line 669 of file blastParse.c.

References blastBlockFreeList(), blastGappedAli::blocks, freeMem(), freez(), and blastGappedAli::targetName.

Referenced by blastGappedAliFreeList().

00671 {
00672 struct blastGappedAli *bga = *pBga;
00673 if (bga != NULL)
00674     {
00675     freeMem(bga->targetName);
00676     blastBlockFreeList(&bga->blocks);
00677     freez(pBga);
00678     }
00679 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastGappedAliFreeList ( struct blastGappedAli **  pList  ) 

Definition at line 681 of file blastParse.c.

References blastGappedAliFree(), and blastGappedAli::next.

Referenced by blastQueryFree().

00683 {
00684 struct blastGappedAli *el, *next;
00685 for (el = *pList; el != NULL; el = next)
00686     {
00687     next = el->next;
00688     blastGappedAliFree(&el);
00689     }
00690 *pList = NULL;
00691 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastGappedAliPrint ( struct blastGappedAli ba,
FILE *  out 
)

Definition at line 728 of file blastParse.c.

References blastBlockPrint(), blastGappedAli::blocks, blastBlock::next, blastGappedAli::query, blastQuery::query, and blastGappedAli::targetName.

Referenced by blastQueryPrint().

00730 {
00731 struct blastBlock *bb;
00732 fprintf(out, "%s <=> %s\n", ba->query->query, ba->targetName);
00733 for (bb = ba->blocks; bb != NULL; bb = bb->next)
00734     {
00735     blastBlockPrint(bb, out);
00736     }
00737 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastQueryFree ( struct blastQuery **  pBq  ) 

Definition at line 643 of file blastParse.c.

References blastGappedAliFreeList(), blastQuery::database, freeMem(), freez(), blastQuery::gapped, and blastQuery::query.

Referenced by blastQueryFreeList().

00645 {
00646 struct blastQuery *bq;
00647 if ((bq = *pBq) != NULL)
00648     {
00649     freeMem(bq->query);
00650     freeMem(bq->database);
00651     blastGappedAliFreeList(&bq->gapped);
00652     freez(pBq);
00653     }
00654 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastQueryFreeList ( struct blastQuery **  pList  ) 

Definition at line 656 of file blastParse.c.

References blastQueryFree(), and blastQuery::next.

Referenced by blastFileFree().

00658 {
00659 struct blastQuery *el, *next;
00660 for (el = *pList; el != NULL; el = next)
00661     {
00662     next = el->next;
00663     blastQueryFree(&el);
00664     }
00665 *pList = NULL;
00666 }

Here is the call graph for this function:

Here is the caller graph for this function:

void blastQueryPrint ( struct blastQuery bq,
FILE *  out 
)

Definition at line 739 of file blastParse.c.

References blastGappedAliPrint(), blastQuery::gapped, and blastGappedAli::next.

Referenced by blastFileNextQuery().

00741 {
00742 struct blastGappedAli *ba;
00743 for (ba = bq->gapped; ba != NULL; ba = ba->next)
00744     blastGappedAliPrint(ba, out);
00745 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 18:43:03 2007 for blat by  doxygen 1.5.2