include/gappedExtension.h File Reference

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

Go to the source code of this file.

Functions

gappedExtensiongappedExtension_build (struct ungappedExtension *ungappedExtension, struct PSSMatrix PSSMatrix, int4 subjectSize, unsigned char *subject, struct unpackRegion *unpackRegion, int4 dropoff)
void gappedExtension_printBeforeRow (int4 *row, unsigned char *subject, unsigned char *rowDropoff, unsigned char *columnDropoff)
void gappedExtension_printAfterRow (int4 *row, unsigned char *subject, unsigned char *rowDropoff, unsigned char *columnDropoff)
void gappedExtension_score (struct gappedExtension *gappedExtension)
void gappedExtension_prune (struct gappedExtension *gappedExtension, struct ungappedExtension *ungappedExtension)
void gappedExtension_free ()


Function Documentation

struct gappedExtension* gappedExtension_build ( struct ungappedExtension ungappedExtension,
struct PSSMatrix  PSSMatrix,
int4  subjectSize,
unsigned char *  subject,
struct unpackRegion unpackRegion,
int4  dropoff 
) [read]

Definition at line 34 of file gappedExtension.c.

References dpResults::best, dpResults::bestScore, blast_dloc, ungappedExtension::end, gappedExtension_dpAfterSeed(), gappedExtension_dpBeforeSeed(), gappedExtension_joinTraces(), gappedExtension_traceAfterSeed(), gappedExtension_traceBeforeSeed(), global_malloc(), int4, PSSMatrix::length, PSSMatrix::matrix, ungappedExtension::nominalScore, parameters_verboseDloc, PSSMatrix_chop(), coordinate::queryOffset, trace::queryStart, ungappedExtension::seed, ungappedExtension::start, PSSMatrix::strandLength, coordinate::subjectOffset, trace::subjectStart, gappedExtension::trace, trace::traceCodes, and unpackRegion::unpackedSubject.

Referenced by alignments_getTracebacks().

00037 {
00038         struct coordinate seed;
00039         unsigned char *choppedSubject;
00040         struct dpResults beforeDpResults, afterDpResults;
00041         struct trace beforeTrace, afterTrace, trace;
00042         struct PSSMatrix choppedPSSMatrix;
00043         int4 choppedSubjectSize;
00044         struct gappedExtension* gappedExtension;
00045     int4 strandOffset = 0;
00046 
00047         // Perform dynamic programming for points before the seed
00048         seed = ungappedExtension->seed;
00049     if (seed.queryOffset > PSSMatrix.strandLength)
00050     {
00051             // If query position is in the second strand, remove first strand from PSSM
00052         strandOffset = PSSMatrix.strandLength;
00053                 seed.queryOffset -= PSSMatrix.strandLength;
00054                 PSSMatrix = PSSMatrix_chop(PSSMatrix, PSSMatrix.strandLength);
00055     }
00056     else
00057     {
00058         // Otherwise remove second strand
00059         PSSMatrix.length = PSSMatrix.strandLength;
00060     }
00061 
00062     beforeDpResults = gappedExtension_dpBeforeSeed(PSSMatrix, dropoff, seed, unpackRegion);
00063 
00064         // Trace back and create the trace which specifies the first half of the alignment
00065         beforeTrace = gappedExtension_traceBeforeSeed(beforeDpResults, seed);
00066 
00067         // Chop the start off the query and subject so they begin at the seed
00068         choppedPSSMatrix = PSSMatrix_chop(PSSMatrix, seed.queryOffset);
00069         choppedSubject = subject + seed.subjectOffset;
00070         choppedSubjectSize = subjectSize - (seed.subjectOffset);
00071 
00072         // Perform dynamic programming for points after the seed
00073         afterDpResults = gappedExtension_dpAfterSeed(choppedPSSMatrix, dropoff, unpackRegion,
00074                                                  choppedSubjectSize, seed.subjectOffset);
00075 
00076         // Trace back to get the trace for the seed onwards
00077         afterTrace = gappedExtension_traceAfterSeed(afterDpResults, choppedPSSMatrix.length);
00078 
00079         // Join afterTrace to the end of beforeTrace
00080         trace = gappedExtension_joinTraces(beforeTrace, afterTrace);
00081         free(afterTrace.traceCodes);
00082 
00083     // Adjust coordinates if extension was performed in the second strand
00084     afterDpResults.best.queryOffset += strandOffset;
00085     beforeDpResults.best.queryOffset += strandOffset;
00086         trace.queryStart += strandOffset;
00087 
00088         // Create gapped extension
00089         gappedExtension = (struct gappedExtension*)global_malloc(sizeof(struct gappedExtension));
00090         gappedExtension->trace = trace;
00091         gappedExtension->next = NULL;
00092 
00093         // Start of afterTrace is end of the gapped extension, but we need to add seed position
00094         // to get correct offset
00095         gappedExtension->queryEnd = seed.queryOffset + afterTrace.queryStart + strandOffset;
00096         gappedExtension->subjectEnd = seed.subjectOffset + afterTrace.subjectStart;
00097 
00098 //      if (dloc == 88197331)
00099 //              printf("final[%d,%d,%d](%d)\n", beforeDpResults.bestScore, afterDpResults.bestScore,
00100 //              choppedPSSMatrix.matrix[0][unpackRegion->unpackedSubject[seed.subjectOffset]], seed.queryOffset);
00101 
00102         // Determine score by combining score from the two traces, and the match score at
00103         // the seed position
00104         gappedExtension->nominalScore = beforeDpResults.bestScore + afterDpResults.bestScore
00105                        + choppedPSSMatrix.matrix[0][unpackRegion->unpackedSubject[seed.subjectOffset]];
00106 
00107     // Update ungappedExtension start/end
00108     ungappedExtension->start.queryOffset = trace.queryStart;
00109     ungappedExtension->end.queryOffset = gappedExtension->queryEnd;
00110     ungappedExtension->start.subjectOffset = trace.subjectStart;
00111     ungappedExtension->end.subjectOffset = gappedExtension->subjectEnd;
00112         ungappedExtension->nominalScore = gappedExtension->nominalScore;
00113 
00114     #ifdef VERBOSE
00115     if (parameters_verboseDloc == blast_dloc)
00116     {
00117         printf("Gapped Extension from %d,%d to %d,%d score %d\n", trace.queryStart, trace.subjectStart,
00118                gappedExtension->queryEnd, gappedExtension->subjectEnd, gappedExtension->nominalScore);
00119     }
00120     #endif
00121 
00122     return gappedExtension;
00123 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gappedExtension_free (  ) 

Definition at line 1383 of file gappedExtension.c.

References gappedExtension_insertQrow, gappedExtension_insertSrow, gappedExtension_matchRow, gappedExtension_traceback, and gappedExtension_tracebackData.

Referenced by main().

01384 {
01385         // Free memory used by traceback array
01386     free(gappedExtension_traceback);
01387     free(gappedExtension_tracebackData);
01388 
01389 //    printf("gappedExtension_tracebackAlloc=%d\n", gappedExtension_tracebackAlloc);
01390 
01391     // Free memory used to store row scores
01392     free(gappedExtension_matchRow);
01393     free(gappedExtension_insertQrow);
01394     free(gappedExtension_insertSrow);
01395 }

Here is the caller graph for this function:

void gappedExtension_printAfterRow ( int4 *  row,
unsigned char *  subject,
unsigned char *  rowDropoff,
unsigned char *  columnDropoff 
)

Definition at line 1438 of file gappedExtension.c.

References dpResults::best, and int4.

Referenced by bytepackGappedScoring_dpAfterSeed(), fasterBytepackGappedScoring_dpAfterSeed(), gappedScoring_dpAfterSeed(), and tableGappedScoring_dpAfterSeed().

01440 {
01441         // TODO: Adjust to work with wrap-around
01442         unsigned char* subjectPosition = subject;
01443     int4 *oldRow, *best;
01444 
01445         while (subjectPosition < columnDropoff)
01446         {
01447                 printf("     ");
01448                 subjectPosition++;
01449                 row++;
01450         }
01451 
01452     best = oldRow = row;
01453 
01454         while (subjectPosition < rowDropoff)
01455         {
01456         if (*row > *best)
01457                 best = row;
01458                 row++;
01459                 subjectPosition++;
01460         }
01461 
01462     row = oldRow; subjectPosition = columnDropoff;
01463 
01464     while (subjectPosition < rowDropoff)
01465         {
01466         if (row == best)
01467                         printf("%4d*", *row);
01468         else
01469                         printf("%4d ", *row);
01470                 row++;
01471                 subjectPosition++;
01472         }
01473 
01474         printf("\n");
01475 }

Here is the caller graph for this function:

void gappedExtension_printBeforeRow ( int4 *  row,
unsigned char *  subject,
unsigned char *  rowDropoff,
unsigned char *  columnDropoff 
)

Definition at line 1398 of file gappedExtension.c.

References dpResults::best, and int4.

Referenced by bytepackGappedScoring_dpBeforeSeed(), fasterBytepackGappedScoring_dpBeforeSeed(), gappedScoring_dpBeforeSeed(), and tableGappedScoring_dpBeforeSeed().

01400 {
01401         // TODO: Adjust to work with wrap-around
01402         unsigned char* subjectPosition = subject;
01403     int4 *oldRow, *best;
01404 
01405         while (subjectPosition < rowDropoff)
01406         {
01407                 printf("     ");
01408                 subjectPosition++;
01409                 row++;
01410         }
01411 
01412     best = oldRow = row;
01413 
01414         while (subjectPosition < columnDropoff)
01415         {
01416         if (*row > *best)
01417                 best = row;
01418                 row++;
01419                 subjectPosition++;
01420         }
01421 
01422     row = oldRow; subjectPosition = rowDropoff;
01423 
01424     while (subjectPosition < columnDropoff)
01425         {
01426         if (row == best)
01427                         printf("%4d*", *row);
01428         else
01429                         printf("%4d ", *row);
01430                 row++;
01431                 subjectPosition++;
01432         }
01433 
01434         printf("\n");
01435 }

Here is the caller graph for this function:

void gappedExtension_prune ( struct gappedExtension gappedExtension,
struct ungappedExtension ungappedExtension 
)

Definition at line 138 of file gappedExtension.c.

References ungappedExtension::end, int4, trace::length, ungappedExtension::next, coordinate::queryOffset, trace::queryStart, ungappedExtension::start, coordinate::subjectOffset, trace::subjectStart, gappedExtension::trace, and trace::traceCodes.

00140 {
00141         int4 queryPosition, subjectPosition;
00142         unsigned char* traceCodes;
00143         int4 count = 0, offset;
00144         struct trace trace;
00145         struct ungappedExtension *currentExtension, *previousExtension;
00146 
00147         // Get trace start point and tracecodes
00148         trace = gappedExtension->trace;
00149         queryPosition = trace.queryStart;
00150         subjectPosition = trace.subjectStart;
00151         traceCodes = trace.traceCodes;
00152 
00153         // Determine start offset
00154         offset = subjectPosition - queryPosition;
00155 
00156         // For each position in the trace
00157         while (count < trace.length)
00158         {
00159                 // Cycle through ungapped extensions and check if they overlap
00160                 // with this part of the gapped extension
00161                 previousExtension = ungappedExtension;
00162                 currentExtension = ungappedExtension->next;
00163                 while (currentExtension != NULL)
00164                 {
00165                         // If on same offset, within start and end of the ungappedExtension
00166                         if (currentExtension->start.subjectOffset -
00167                 currentExtension->start.queryOffset == offset &&
00168                             currentExtension->start.queryOffset <= queryPosition &&
00169                                 currentExtension->end.queryOffset >= queryPosition)
00170                         {
00171                                 // Remove current ungappedExtension from the list
00172                                 previousExtension->next = currentExtension->next;
00173                                 currentExtension = previousExtension->next;
00174                         }
00175                         else
00176                         {
00177                                 previousExtension = currentExtension;
00178                                 currentExtension = currentExtension->next;
00179                         }
00180                 }
00181 
00182                 // A match
00183                 if (traceCodes[count] == 0)
00184                 {
00185                         queryPosition++;
00186                         subjectPosition++;
00187                 }
00188                 // An insertion wrt. query
00189                 else if (traceCodes[count] == 1)
00190                 {
00191                         subjectPosition++;
00192                         offset++;
00193                 }
00194                 // An insertion wrt. subject
00195                 else
00196                 {
00197                         queryPosition++;
00198                         offset--;
00199                 }
00200                 count++;
00201         }
00202 }

void gappedExtension_score ( struct gappedExtension gappedExtension  ) 

Definition at line 127 of file gappedExtension.c.

References gappedExtension::eValue, gappedExtension::nominalScore, gappedExtension::normalizedScore, statistics_gappedCalculateEvalue(), and statistics_gappedNominal2normalized().

Referenced by alignments_getTracebacks(), search_nucleotideSsearch(), and search_proteinSsearch().

00128 {
00129         gappedExtension->normalizedScore
00130                 = statistics_gappedNominal2normalized(gappedExtension->nominalScore);
00131 
00132         gappedExtension->eValue
00133                 = statistics_gappedCalculateEvalue(gappedExtension->normalizedScore);
00134 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Wed Dec 19 20:49:05 2007 for fsa-blast by  doxygen 1.5.2