static void testCalculateZScore(CuTest *testCase) { for(int64_t i=0; i<100; i++) { int64_t n = st_randomInt(0, 100); int64_t m = st_randomInt(0, 100); int64_t k = st_randomInt(1, 10000); double theta = st_random() > 0.05 ? st_random() : 0.0; double zScore = calculateZScore(n, m, k, theta); double zScoreSlow = calculateZScoreSlow(n, m, k, theta); st_logDebug("The slow computed score: %f the fast computed score: %f, n: %" PRIi64 " m: %" PRIi64 " k: %" PRIi64 ", theta: %lf\n", zScoreSlow, zScore, n, m, k, theta); CuAssertDblEquals(testCase, zScoreSlow, zScore, 0.000001); } }
void ClusterSize( const std::vector<int>& inputData, int densityWin, std::map< int, Hotspot* >& filteredHotspots, const std::vector< int >& mappableCounts ) { // finally go through and determine the number of library clones contained // in filterwidth, also get the maximum inter-cluster width // TODO: leftindex might not be properly initialized int contcount,leftindex = -1, rightindex = -1,leftdens,rightdens,dencount; double leftcent, rightcent; int halfDensityWin = densityWin / 2; /* double probz,meanz,sdz; */ std::map<int, Hotspot* >::iterator iter; for( iter = filteredHotspots.begin( ); iter != filteredHotspots.end( ); ++iter) { Hotspot *currHotspot = iter->second; leftcent = currHotspot->averagePos - currHotspot->filterWidth / 2; rightcent = currHotspot->averagePos + currHotspot->filterWidth / 2; leftdens = currHotspot->averagePos - halfDensityWin; rightdens = currHotspot->averagePos + halfDensityWin; contcount=0; dencount=0; unsigned int libIdx; for (libIdx = 0; libIdx < inputData.size(); libIdx++) { // for every tag on that chrome if ((inputData[libIdx] >= leftcent) && (inputData[libIdx] <= rightcent)) { if (contcount==0) { leftindex=libIdx; } rightindex=libIdx; contcount++; } if ((inputData[libIdx] >= leftdens) && (inputData[libIdx] <= rightdens)) { if(dencount == 0) { currHotspot->filterDensIndexLeft = libIdx; } dencount++; } if (inputData[libIdx] > rightdens && inputData[libIdx] > rightcent) { break; } } currHotspot->filterDensIndexRight = libIdx - 1; currHotspot->filterSize = contcount; currHotspot->filterDist = inputData[rightindex] - inputData[leftindex] + 1; // changed to add 1 -- RET currHotspot->minSite = inputData[currHotspot->filterIndexLeft]; currHotspot->maxSite = inputData[currHotspot->filterIndexRight]; int uniquelyMappableSitesInWindow = countMappableSites( currHotspot->averagePos, densityWin, densityWinSmall, mappableCounts ); // Following counts tags in the nearest 50kb window starting on a 10kb boundary, to // match the windows used in countMappableSites. int dencount2 = countDensity2( currHotspot->averagePos, inputData ); currHotspot->filteredZScoreAdjusted = calculateZScore( lround( currHotspot->filterWidth), currHotspot->filterSize, densityWin, dencount2, uniquelyMappableSitesInWindow ); } return; }