From f7ad17016db811e2cf4a941d1adfb89093b21fa2 Mon Sep 17 00:00:00 2001 From: jmaguire Date: Sun, 22 Mar 2009 15:36:56 +0000 Subject: [PATCH] some reformatting and logic cleanup in the comparison functions git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@132 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/utils/GenomeLoc.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/core/java/src/org/broadinstitute/sting/utils/GenomeLoc.java b/core/java/src/org/broadinstitute/sting/utils/GenomeLoc.java index 0221662a5..196162168 100644 --- a/core/java/src/org/broadinstitute/sting/utils/GenomeLoc.java +++ b/core/java/src/org/broadinstitute/sting/utils/GenomeLoc.java @@ -186,35 +186,51 @@ public class GenomeLoc implements Comparable { // // Comparison operations // - public static int compareContigs( final String thisContig, final String thatContig ) { + public static int compareContigs( final String thisContig, final String thatContig ) + { if ( thisContig == thatContig ) + { + assert(false); return 0; + } - if ( refContigOrdering != null ) { - if ( ! refContigOrdering.containsKey(thisContig) ) { - if ( ! refContigOrdering.containsKey(thatContig) ) { + assert refContigOrdering.containsKey(thisContig);// : this; + assert refContigOrdering.containsKey(thatContig);// : that; + + if ( refContigOrdering != null ) + { + if ( ! refContigOrdering.containsKey(thisContig) ) + { + if ( ! refContigOrdering.containsKey(thatContig) ) + { // Use regular sorted order return thisContig.compareTo(thatContig); } - else { + else + { // this is always bigger if that is in the key set return 1; } } else if ( ! refContigOrdering.containsKey(thatContig) ) + { return -1; - else { + } + else + { assert refContigOrdering.containsKey(thisContig);// : this; assert refContigOrdering.containsKey(thatContig);// : that; final int thisO = refContigOrdering.get(thisContig); final int thatO = refContigOrdering.get(thatContig); + if ( thisO < thatO ) return -1; if ( thisO > thatO ) return 1; return 0; } } - else { + else + { return thisContig.compareTo(thatContig); } } @@ -235,4 +251,4 @@ public class GenomeLoc implements Comparable { if ( this.getStop() > that.getStop() ) return 1; return 0; } -} \ No newline at end of file +}