code: public static int[] calculateBlockGap(int[][][] optAln){
  
  		//Initialize the array to be returned
  		int [] blockGap = new int[optAln.length];
  
  		//Loop for every block and look in both chains for non-contiguous residues.
  		for (int i=0; i<optAln.length; i++){
  			int gaps = 0; //the number of gaps in that block
  			int last1 = 0; //the last residue position in chain 1
  			int last2 = 0; //the last residue position in chain 2
  			//Loop for every position in the block
  			for (int j=0; j<optAln[i][0].length; j++){
  				//If the first position is evaluated initialize the last positions
  				if (j==0){
  					last1 = optAln[i][0][j];
  					last2 = optAln[i][1][j];
  				}
  				else{
  					//If one of the positions or both are not contiguous increment the number of gaps
  					if (optAln[i][0][j] > last1+1 || optAln[i][1][j] > last2+1){
  						gaps++;
  						last1 = optAln[i][0][j];
  						last2 = optAln[i][1][j];
  					}
  					//Otherwise just set the last position to the current one
  					else{
  						last1 = optAln[i][0][j];
  						last2 = optAln[i][1][j];
  					}
  				}
  			}
  			blockGap[i] = gaps;
  		}
  		return blockGap;
  	}
docs: Method that calculates the number of gaps in each subunit block of an optimal AFP alignment.
  
  INPUT: an optimal alignment in the format int[][][].
  OUTPUT: an int[] array of <order> length containing the gaps in each block as int[block].