]> git.donarmstrong.com Git - mothur.git/blobdiff - sharedmorisitahorn.cpp
This is mothur v 1.2.0 - the April ~24, 2009 release
[mothur.git] / sharedmorisitahorn.cpp
index 579f56a80da8733fa68ea507f9346d32a8760d59..8c5cf9263f32910aaf4f577a9a252e34dcd865d0 100644 (file)
@@ -32,18 +32,16 @@ EstOutput MorHorn::getValues(SharedRAbundVector* shared1, SharedRAbundVector* sh
                        tempA = shared1->getAbundance(j);
                        tempB = shared2->getAbundance(j);
                        
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {
-                               if (Atotal != 0)        { sumSharedA = (tempA / (float)Atotal); }
-                               if (Btotal != 0)        { sumSharedB = (tempB / (float)Btotal); }
-                       
-                               a += sumSharedA * sumSharedA;
-                               b += sumSharedB * sumSharedB;
-                               d += sumSharedA * sumSharedB;
-                       }
+                       a += tempA * tempA;
+                       b += tempB * tempB;
+                       d += tempA * tempB;
                }
 
-               morhorn = (2 * d) / (float) (a + b);
+               a /= double(Atotal * Atotal);
+               b /= double(Btotal * Btotal);
+               d /= double(Atotal * Btotal);
+               
+               morhorn = (2 * d) / (a + b);
                
                if (isnan(morhorn) || isinf(morhorn)) { morhorn = 0; }