static wbool outputMatch( char *where, size_t read, wbool disp ) { wbool done; char *endrec; int i; done = FALSE; if( where >= &Buff[read] ) { done = TRUE; // this is the string we added to buffer! we're done buffer } else if( disp ) { if( PrtFn ) { if( FOut != NULL ) { fprintf( FOut, FOutFmt, FName ); fprintf( FOut, "\n" ); } if( PrtFiles && !PrtAll ) { printFileName(); } PrtFn = FALSE; } MatchCount++; TotalMatchCount++; if( PrtMatch ) { i = Context + 1; for( ;; ) { // scan back to beginning of the record if( where == Buff ) break; if( *where == '\n' ) { if( --i == 0 ) { ++where; break; } } --where; } endrec = where; i = Context * 2 + 1; while( --i >= 0 ) { do { // find the end of record ++endrec; } while( *endrec != '\n' && endrec != (Buff + read + 1) ); } if( PrtLines ) { printf( "%.5u: ", Recs ); if( Context ) printf( "\r\n" ); } dumpMatch( where, endrec - where + 1 ); } if( QuitFirst || OnePerFile ) { done = TRUE; ExitStatus = 1; } } return( done ); }
void findRepeats(SeqStructPtr seqP) { int curPos; Boolean anyMatchThisSeq, matchAtThisPos; MatchStruct match; memset( (char *)&match, 0, sizeof(MatchStruct) ); /* clear match struct */ anyMatchThisSeq = False; /* avoid dumping description more than once. */ /* loop on all positions in the sequence. note that a match will advance curPos past all matching chars to the first unmatched char. */ while ( match.curPos <= seqP->seqLen) { /* now loop on all the different lengths of repeats we're looking for (i.e. di, tri, tetra nucleotides. if we find a match at a shorter repeat length, forego testing for longer lengths. */ match.testLen = MIN_UNIT_LENGTH; matchAtThisPos = False; while ((match.testLen <= MAX_UNIT_LENGTH) && (!matchAtThisPos)) { /* initialize the state of the match */ match.curScore = 0; /* no points yet */ match.testCtr = 0; /* no chars tested yet */ match.testPos = match.curPos + match.testLen; match.insertions = 0; match.deletions = 0; match.missense = 0; /* there are some things we don't want to test for (IGNORE - ignoring single repeat) */ if (! ignoreSeq(seqP,&match)) matchAtThisPos = testForNRepeat(seqP, &match); else matchAtThisPos = False; if (! matchAtThisPos) match.testLen++; } if (matchAtThisPos) { dumpMatch(seqP,&match,anyMatchThisSeq); anyMatchThisSeq |= matchAtThisPos; match.curPos = match.testPos; } else match.curPos++; /* no, so advance to next base. */ } }