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 +}