Buggy code:
os . close ( ) ; outputFile = ( CoOccurLibrary . OUTPUT_DIRECTORY ) + "variantCounts.dat" ; System . out . print ( ( ( "writing<seq2seq4repair_space>to<seq2seq4repair_space>" + outputFile ) + "<seq2seq4repair_space>...\n" ) ) ; os = new DataOutputStream ( new FileOutputStream ( outputFile ) ) ; os . writeInt ( ( ( 2 * ( CoOccurLibrary . windowSize ) ) + 1 ) ) ; os . writeInt ( CoOccurLibrary . numPos ) ; os . writeInt ( CoOccurLibrary . setHeaderFlags ( true , true , 4 , 4 ) ) ; for ( int i = 0 ; i < ( CoOccurLibrary . numPos ) ; i ++ ) { for ( int dj = - ( CoOccurLibrary . windowSize ) ; dj <= ( CoOccurLibrary . windowSize ) ; dj ++ ) { int j = i + dj ; if ( ( j < 0 ) || ( j >= ( CoOccurLibrary . numPos ) ) ) continue ; int [ ] curVal = CoOccurLibrary . variantCounts [ i ] [ j ] ; if ( ( ( ( ( curVal [ 0 ] ) + ( curVal [ 1 ] ) ) + ( curVal [ 2 ] ) ) + ( curVal [ 3 ] ) ) == 0 ) continue ; os . writeInt ( ( ( i * ( ( ( CoOccurLibrary . windowSize ) * 2 ) + 1 ) ) + ( dj + ( CoOccurLibrary . windowSize ) ) ) ) ; for ( int n = 0 ; n < 4 ; n ++ ) { os . writeInt ( curVal [ n ] ) ; } } } os . flush ( ) ; os . close ( ) ; outputFile = ( CoOccurLibrary . OUTPUT_DIRECTORY ) + "baseCounts.dat" ; System . out . print ( ( ( "writing<seq2seq4repair_space>to<seq2seq4repair_space>" + outputFile ) + "<seq2seq4repair_space>...<seq2seq4repair_space>\n" ) ) ; os = new DataOutputStream ( new FileOutputStream ( outputFile ) ) ; os . writeInt ( 1 ) ; os . writeInt ( CoOccurLibrary . numPos ) ; os . writeInt ( CoOccurLibrary . setHeaderFlags ( true , true , 4 , 1 ) ) ; for ( int i = 0 ; i < ( CoOccurLibrary . numPos ) ; i ++ ) { int [ ] curVal = CoOccurLibrary . baseCounts [ i ] ; if ( ( ( ( ( curVal [ 0 ] ) + ( curVal [ 1 ] ) ) + ( curVal [ 2 ] ) ) + ( curVal [ 3 ] ) ) == 0 ) continue ; os . writeInt ( i ) ; for ( int n = 0 ; n < 4 ; n ++ ) { os . writeInt ( curVal [ n ] ) ; } } os . flush ( ) ; os . close ( ) ; outputFile = ( CoOccurLibrary . OUTPUT_DIRECTORY ) + "fullCounts.dat" ; System . out . print ( ( ( "writing<seq2seq4repair_space>to<seq2seq4repair_space>" + outputFile ) + "<seq2seq4repair_space>...<seq2seq4repair_space>\n" ) ) ; os = new DataOutputStream ( new FileOutputStream ( outputFile ) ) ; os . writeInt ( ( ( 2 * ( CoOccurLibrary . windowSize ) ) + 1 ) ) ; os . writeInt ( CoOccurLibrary . numPos ) ; os . writeInt ( CoOccurLibrary . setHeaderFlags ( true , true , 4 , 4 ) ) ; for ( Map . Entry < PosPair , Map < CooccuringBases , Integer > > pos : CoOccurLibrary . cooccurCounts . entrySet ( ) ) { int i = pos . getKey ( ) . i ; int j = pos . getKey ( ) . j ; int absIndex = ( i * ( ( ( CoOccurLibrary . windowSize ) * 2 ) + 1 ) ) + ( ( j - i ) + ( CoOccurLibrary . windowSize ) ) ; os . writeInt ( absIndex ) ; os . writeByte ( pos . getValue ( ) . size ( ) ) ; for ( Map . Entry < CooccuringBases , Integer > counts : pos . getValue ( ) . entrySet ( ) ) { os . writeByte ( counts . getKey ( ) . baseByte ( ) ) ; os . writeInt ( counts . getValue ( ) ) ; } } os . flush ( ) ; os . close ( ) ; outputFile = ( CoOccurLibrary . OUTPUT_DIRECTORY ) + "reference.dat" ; System . out . print ( ( ( "writing<seq2seq4repair_space>to<seq2seq4repair_space>" + outputFile ) + "<seq2seq4repair_space>...<seq2seq4repair_space>\n" ) ) ; os = new DataOutputStream ( new FileOutputStream ( outputFile ) ) ; <START_BUG> os . writeInt ( 1 ) ; <END_BUG> os . writeInt ( CoOccurLibrary . numPos ) ; os . writeInt ( CoOccurLibrary . setHeaderFlags ( true , true , 4 , 4 ) ) ; int curByte = 0 ; int numInByte = 0 ; for ( int n = 0 ; n < ( CoOccurLibrary . numPos ) ; n ++ ) { if ( ( ++ numInByte ) > 4 ) { os . writeByte ( curByte ) ; curByte = 0 ; numInByte = 1 ; } int thisBase = CoOccurLibrary . getRefAtPos ( n ) ; if ( thisBase == ( - 1 ) ) thisBase = 0 ; curByte = ( curByte << 2 ) | thisBase ; } for ( int n = numInByte ; n < 4 ; n ++ ) { curByte <<= 2 ; } os . writeByte ( curByte ) ; os . flush ( ) ; os . close ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } else { try { String outputFile = CoOccurLibrary . OUTPUT_DIRECTORY ; switch ( metric ) { case DIFF_FROM_EXPECTED : outputFile += "conjProbDiff.csv" ; break ; case OUTLIER_DIFF_FROM_EXPECTED : outputFile += "conjProbDiff-outliers.csv" ;

Fix:
os . writeInt ( ( ( 2 * ( CoOccurLibrary . windowSize ) ) + 1 ) ) ;