00001 #include "log.h" 00002 #include "format.h" 00003 #include "segmentationUtil.h" 00004 00005 00006 00013 void performSegmentation (Array tars, Array wigs, char* targetName, double threshold, int maxGap, int minRun) 00014 { 00015 Tar *currTar; 00016 Wig *currWig,*nextWig; 00017 int i,j,endPosition; 00018 int countBelowThreshold; 00019 00020 i = 0; 00021 while (i < arrayMax (wigs)) { 00022 currWig = arrp (wigs,i,Wig); 00023 if (currWig->value < threshold) { 00024 i++; 00025 continue; 00026 } 00027 j = i + 1; 00028 endPosition = j; 00029 countBelowThreshold = 0; 00030 while (j < arrayMax (wigs)) { 00031 nextWig = arrp (wigs,j,Wig); 00032 if (nextWig->value < threshold) { 00033 countBelowThreshold++; 00034 if (countBelowThreshold >= maxGap) { 00035 break; 00036 } 00037 } 00038 else { 00039 countBelowThreshold = 0; 00040 endPosition = j; 00041 } 00042 j++; 00043 } 00044 if ((endPosition - 1 - currWig->position + 1) >= minRun) { 00045 currTar = arrayp (tars,arrayMax (tars),Tar); 00046 currTar->start = currWig->position; 00047 currTar->end = endPosition + 1; 00048 currTar->targetName = hlr_strdup (targetName); 00049 } 00050 i = j; 00051 } 00052 } 00053