Permalink
Browse files

Fixes overflow from numSeqs datatype

  • Loading branch information...
1 parent d0d35b0 commit bdac5073b09423c2910efe6a08ad98eb807492fe @mothur-westcott mothur-westcott committed Sep 7, 2016
Showing with 22 additions and 21 deletions.
  1. +21 −20 source/commands/sensspeccommand.cpp
  2. +1 −1 source/commands/sensspeccommand.h
@@ -295,7 +295,7 @@ int SensSpecCommand::process(map<string, int>& seqMap, ListVector*& list, bool&
try {
string label = list->getLabel();
- int numSeqs = list->getNumSeqs();
+ long long numSeqs = list->getNumSeqs();
int numOTUs = list->getNumBins();
if(getCutoff == 1){
@@ -431,6 +431,7 @@ int SensSpecCommand::process(map<string, int>& seqMap, ListVector*& list, bool&
}
}
}
+
falseNegatives = distanceMap.size();
trueNegatives = numSeqs * (numSeqs-1)/2 - (falsePositives + falseNegatives + truePositives);
@@ -554,25 +555,25 @@ void SensSpecCommand::setUpOutput(){
void SensSpecCommand::outputStatistics(string label, string cutoff){
try{
- double tp = (double) truePositives;
- double fp = (double) falsePositives;
- double tn = (double) trueNegatives;
- double fn = (double) falseNegatives;
-
- double p = tp + fn;
- double n = fp + tn;
- double pPrime = tp + fp;
- double nPrime = tn + fn;
-
- double sensitivity = tp / p;
- double specificity = tn / n;
- double positivePredictiveValue = tp / pPrime;
- double negativePredictiveValue = tn / nPrime;
- double falseDiscoveryRate = fp / pPrime;
-
- double accuracy = (tp + tn) / (p + n);
- double matthewsCorrCoef = (tp * tn - fp * fn) / sqrt(p * n * pPrime * nPrime); if(p == 0 || n == 0){ matthewsCorrCoef = 0; }
- double f1Score = 2.0 * tp / (p + pPrime);
+ long long tp = truePositives;
+ long long fp = falsePositives;
+ long long tn = trueNegatives;
+ long long fn = falseNegatives;
+
+ long long p = tp + fn;
+ long long n = fp + tn;
+ long long pPrime = tp + fp;
+ long long nPrime = tn + fn;
+
+ double sensitivity = tp / (double) p;
+ double specificity = tn / (double)n;
+ double positivePredictiveValue = tp / (double)pPrime;
+ double negativePredictiveValue = tn / (double)nPrime;
+ double falseDiscoveryRate = fp / (double)pPrime;
+
+ double accuracy = (tp + tn) / (double)(p + n);
+ double matthewsCorrCoef = (tp * tn - fp * fn) / (double)sqrt(p * n * pPrime * nPrime); if(p == 0 || n == 0){ matthewsCorrCoef = 0; }
+ double f1Score = 2.0 * tp / (double)(p + pPrime);
if(p == 0) { sensitivity = 0; matthewsCorrCoef = 0; }
@@ -47,7 +47,7 @@ class SensSpecCommand : public Command {
vector<string> outputNames;
set<string> labels; //holds labels to be used
- long long truePositives, falsePositives, trueNegatives, falseNegatives;
+ long long truePositives, falsePositives, trueNegatives, falseNegatives;
bool abort, allLines, square;
double cutoff;
int precision;

0 comments on commit bdac507

Please sign in to comment.