From c7f4674fe2bd7e6b3ec4d0befabca792a44b3629 Mon Sep 17 00:00:00 2001 From: chartl Date: Mon, 23 May 2011 21:00:52 +0000 Subject: [PATCH] Great! Contracts is working. Fixing some misspecified ones. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5854 348d0f76-0448-11de-a6fe-93d51630548a --- .../org/broadinstitute/sting/utils/MannWhitneyU.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/java/src/org/broadinstitute/sting/utils/MannWhitneyU.java b/java/src/org/broadinstitute/sting/utils/MannWhitneyU.java index fac04db1d..9509cee40 100755 --- a/java/src/org/broadinstitute/sting/utils/MannWhitneyU.java +++ b/java/src/org/broadinstitute/sting/utils/MannWhitneyU.java @@ -64,8 +64,8 @@ public class MannWhitneyU { * @param lessThanOther - either Set1 or Set2 * @return - u-based z-approximation, and p-value associated with the test (p-value is exact for small n,m) */ - @Requires({"validateObservations(observations)", "lessThanOther != null"}) - @Ensures({"result != null", "! Double.isInfinite(result.getFirst())", "! Double.isInfinite(result.getSecond())"}) + @Requires({"lessThanOther != null"}) + @Ensures({"validateObservations(observations) || Double.isNaN(result.getFirst())","result != null", "! Double.isInfinite(result.getFirst())", "! Double.isInfinite(result.getSecond())"}) public Pair runOneSidedTest(USet lessThanOther) { long u = calculateOneSidedU(observations, lessThanOther); int n = lessThanOther == USet.SET1 ? sizeSet1 : sizeSet2; @@ -84,7 +84,7 @@ public class MannWhitneyU { * @return a pair holding the u and p-value. */ @Ensures({"result != null", "! Double.isInfinite(result.getFirst())", "! Double.isInfinite(result.getSecond())"}) - @Requires({"validateObservations(observations)"}) + //@Requires({"validateObservations(observations)"}) public Pair runTwoSidedTest() { Pair uPair = calculateTwoSidedU(observations); long u = uPair.first; @@ -218,7 +218,7 @@ public class MannWhitneyU { * @param observed - the observed data * @return the minimum of the U counts (set1 dominates 2, set 2 dominates 1) */ - @Requires({"observed != null", "observed.size() > 0", "validateObservations(observed)"}) + @Requires({"observed != null", "observed.size() > 0"}) @Ensures({"result != null","result.first > 0"}) public static Pair calculateTwoSidedU(TreeSet> observed) { int set1SeenSoFar = 0; @@ -255,7 +255,7 @@ public class MannWhitneyU { * @param dominator - the set that is hypothesized to be stochastically dominating * @return the u-statistic associated with the hypothesis that dominator stochastically dominates the other set */ - @Requires({"observed != null","dominator != null","observed.size() > 0","validateObservations(observed)"}) + @Requires({"observed != null","dominator != null","observed.size() > 0"}) @Ensures({"result >= 0"}) public static long calculateOneSidedU(TreeSet> observed,USet dominator) { long otherBeforeDominator = 0l; @@ -281,7 +281,7 @@ public class MannWhitneyU { * @param twoSided: whether the test is two sided or not. The recursive formula is symmetric, multiply by two for two-sidedness. * @return the probability under the hypothesis that all sequences are equally likely of finding a set-two entry preceding a set-one entry "u" times. */ - @Requires({"m > 0","n > 0","u > 0"}) + @Requires({"m > 0","n > 0","u >= 0"}) @Ensures({"result != null","! Double.isInfinite(result.getFirst())", "! Double.isInfinite(result.getSecond())"}) public static Pair calculatePRecursively(int n, int m, long u, boolean twoSided) { if ( m > 8 && n > 5 ) { throw new StingException(String.format("Please use the appropriate (normal or sum of uniform) approximation. Values n: %d, m: %d",n,m)); }