--- orig/SOAPdenovo-V1.05/src/63mer/bubble.c 2011-02-22 07:10:34.000000000 +0100 +++ src/bubble.c 2014-04-21 15:00:41.650723014 +0200 @@ -66,6 +66,8 @@ static int slowSeqLength; static Time * times; +static int * nodeCounts; + static unsigned int * previous; static unsigned int expCounter; static unsigned int * expanded; @@ -376,6 +378,8 @@ int Choice1, Choice2, Choice3; int maxScore; + int minOverlap=overlaplen/2; + if ( length1 == 0 || length2 == 0 ) { caseA++; @@ -388,11 +392,13 @@ return 0; } + /* if ( length1 < overlaplen - 1 || length2 < overlaplen - 1 ) { caseB++; return 0; } +*/ /* if (length1 < overlaplen || length2 < overlaplen){ @@ -426,6 +432,16 @@ maxScore = Fmatrix[length1][length2]; maxLength = ( length1 > length2 ? length1 : length2 ); + if(maxScore == maxLength) + return 1; + + if(length1 < minOverlap || length2 < minOverlap ) + { + caseB++; + return 0; + } + + if ( maxScore < maxLength - DIFF ) { caseC++; @@ -1740,6 +1756,13 @@ fflush ( stdout ); } + int nodeCount=nodeCounts[origin]+1; + + if(nodeCount>MAXNODELENGTH) + return; + + nodeCounts[destination]=nodeCount; + totalTime = originTime + arcTime; /* if(destination==289129||destination==359610){ @@ -1843,10 +1866,48 @@ } } */ + +static void tourBusCleanup() +{ + int i; + ARC * parc; + + for(i=0;ito_ed; + + times[target] = -1; + previous[target] = 0; + dheapNodes[target] = NULL; + + parc = parc->next; + } + } + +} + static void tourBus ( unsigned int startingPoint ) { unsigned int currentNode = startingPoint; + + unsigned int index; + + if(startingPoint % 10000 == 0) + printf("tourBus() ************************************************************************************************** FROM %i \n",startingPoint); + times[startingPoint] = 0; + nodeCounts[startingPoint] = 0; + previous[startingPoint] = currentNode; while ( currentNode > 0 ) @@ -1858,8 +1919,91 @@ if ( currentNode > 0 ) { rnodeCounter++; } } + + tourBusCleanup(); } + +void dumpEdges() +{ + int i; + ARC *parc; + + for ( i = 1; i <= num_ed; i++ ) //num_ed + { + EDGE *edge=edge_array+i; + + if (edge->deleted) + continue; + + printf("Edge %i:\n",i); + + if(edge->length>0) + printTightString(edge->seq, edge->length); + else + printf("\n"); + + int hasA=0, hasC=0, hasG=0, hasT=0; + + parc=edge->arcs; + while(parc!=NULL) + { + int toEd=parc->to_ed; + + EDGE *toEdge=edge_array+toEd; + + if(toEdge->length>0) + { + char ch=getCharInTightString(toEdge->seq,0); + switch(ch) + { + case 0: + hasA++; + break; + case 1: + hasC++; + break; + case 2: + hasT++; + break; + case 3: + hasG++; + break; + } + } + + parc=parc->next; + } + + if(hasA>1 || hasC>1 || hasT>1 || hasG>1) + { + printf("%i %i %i %i\n", hasA, hasC, hasT, hasG); + } + + parc=edge->arcs; + while(parc!=NULL) + { + int toEd=parc->to_ed; + + EDGE *toEdge=edge_array+toEd; + + printf("(%i) ",toEd); + + if(toEdge->length>0) + printTightString(toEdge->seq, toEdge->length); + else + printf("\n"); + + parc=parc->next; + + } + + + printf("\n"); + } +} + + void bubblePinch ( double simiCutoff, char * outfile, int M ) { unsigned int index, counter = 0; @@ -1884,24 +2028,25 @@ if ( M <= 1 ) { - MAXNODELENGTH = 3; + MAXNODELENGTH = 10; DIFF = 2; } else if ( M == 2 ) { - MAXNODELENGTH = 9; + MAXNODELENGTH = 20; DIFF = 3; } else { MAXNODELENGTH = 30; - DIFF = 10; + DIFF = 4; } printf ( "start to pinch bubbles, cutoff %f, MAX NODE NUM %d, MAX DIFF %d\n", cutoff, MAXNODELENGTH, DIFF ); createRVmemo(); times = ( Time * ) ckalloc ( ( num_ed + 1 ) * sizeof ( Time ) ); + nodeCounts = (int * )ckalloc ((num_ed + 1) * sizeof (int)); previous = ( unsigned int * ) ckalloc ( ( num_ed + 1 ) * sizeof ( unsigned int ) ); expanded = ( unsigned int * ) ckalloc ( ( num_ed + 1 ) * sizeof ( unsigned int ) ); dheapNodes = ( DFibHeapNode ** ) ckalloc ( ( num_ed + 1 ) * sizeof ( DFibHeapNode * ) ); @@ -1916,6 +2061,7 @@ dheap = newDFibHeap(); eligibleStartingPoints = ( unsigned int * ) ckalloc ( ( num_ed + 1 ) * sizeof ( unsigned int ) ); + resetNodeStatus(); //determineEligibleStartingPoints(); createArcLookupTable(); @@ -1927,7 +2073,7 @@ //printf("starting point %d with length %d\n",startingNode,edge_array[startingNode].length); expCounter = 0; tourBus ( startingNode ); - updateNodeStatus(); +// updateNodeStatus(); } resetNodeStatus(); @@ -1942,6 +2088,7 @@ free ( ( void * ) eligibleStartingPoints ); destroyDHeap ( dheap ); free ( ( void * ) dheapNodes ); + free ( ( void * ) nodeCounts ); free ( ( void * ) times ); free ( ( void * ) previous ); free ( ( void * ) expanded );