@Override public int[] sequenceLengths(final long start,final long end) throws IOException {
  final int entrySize=mIndex.getVersion() >= IndexFile.PER_SEQUENCE_CHECKSUM_VERSION ? (mIndex.hasQuality() ? 6 : 5) : 4;
  final long internalStart=start + mStart;
  final long internalEnd=end + mStart;
  final int[] ret=new int[(int)(internalEnd - internalStart)];
  if (ret.length == 0) {
    return ret;
  }
  if (mIndex.getMaxLength() == mIndex.getMinLength()) {
    Arrays.fill(ret,(int)mIndex.getMaxLength());
    return ret;
  }
  final byte[] buffer=new byte[entrySize * 1024];
  final DataFileIndex dataIndex=mSequenceManager.sequenceIndex();
  final long[] numSequences=new long[dataIndex.numberEntries()];
  int startFileNo=-1;
  int endFileNo=-1;
  for (int i=0; i < numSequences.length; i++) {
    if (i > 0) {
      numSequences[i]=numSequences[i - 1] + dataIndex.numberSequences(i);
    }
 else {
      numSequences[0]=dataIndex.numberSequences(0);
    }
    if (internalStart < numSequences[i]) {
      if (startFileNo == -1) {
        startFileNo=i;
      }
      if (internalEnd < numSequences[i]) {
        endFileNo=i;
        break;
      }
    }
  }
  final long startLower=startFileNo == 0 ? 0 : numSequences[startFileNo - 1];
  final long endLower=endFileNo < 1 ? 0 : numSequences[endFileNo - 1];
  int seqNo=0;
  for (int i=startFileNo; (endFileNo == -1 || i <= endFileNo) && i < numSequences.length; i++) {
    try (RandomAccessFile raf=new RandomAccessFile(SdfFileUtils.sequencePointerFile(mDirectory,i),"r")){
      final long pos;
      if (i == startFileNo) {
        pos=(internalStart - startLower) * entrySize;
        raf.seek(pos);
      }
 else {
        pos=0;
      }
      final long endPos=endFileNo == i ? (internalEnd - endLower) * entrySize : raf.length();
      seqNo=sequenceLengthsHelper(raf,buffer,ret,seqNo,pos,endPos,entrySize);
      if (endFileNo != i && seqNo > 0) {
        final long fileLength=dataIndex.dataSize(i);
        ret[seqNo - 1]=ret[seqNo - 1] - (int)fileLength;
      }
 else {
        if (seqNo != ret.length) {
          throw new CorruptSdfException("Should have read " + ret.length + " sequence pointers, got "+ seqNo);
        }
        raf.read();
        ret[seqNo - 1]-=raf.readInt();
      }
    }
   }
  ret[ret.length - 1]=0 - ret[ret.length - 1];
  return ret;
}

@ Override public int [ ] sequenceLengths ( final long start , final long end ) throws IOException { final int entrySize = mIndex . getVersion ( ) >= IndexFile . PER_SEQUENCE_CHECKSUM_VERSION ? ( mIndex . hasQuality ( ) ? 6 : 5 ) : 4 ; final long internalStart = start + mStart ; final long internalEnd = end + mStart ; final int [ ] ret = new int [ ( int ) ( internalEnd - internalStart ) ] ; if ( ret . length == 0 ) { return ret ; } if ( mIndex . getMaxLength ( ) == mIndex . getMinLength ( ) ) { Arrays . fill ( ret , ( int ) mIndex . getMaxLength ( ) ) ; return ret ; } final byte [ ] buffer = new byte [ entrySize * 1024 ] ; final DataFileIndex dataIndex = mSequenceManager . sequenceIndex ( ) ; final long [ ] numSequences = new long [ dataIndex . numberEntries ( ) ] ; int startFileNo = - 1 ; int endFileNo = - 1 ; for ( int i = 0 ; i < numSequences . length ; i ++ ) { if ( i > 0 ) { numSequences [ i ] = numSequences [ i - 1 ] + dataIndex . numberSequences ( i ) ; } else { numSequences [ 0 ] = dataIndex . numberSequences ( 0 ) ; } if ( internalStart < numSequences [ i ] ) { if ( startFileNo == - 1 ) { startFileNo = i ; } if ( internalEnd < numSequences [ i ] ) { endFileNo = i ; break ; } } } final long startLower = startFileNo == 0 ? 0 : numSequences [ startFileNo - 1 ] ; final long endLower = endFileNo < 1 ? 0 : numSequences [ endFileNo - 1 ] ; int seqNo = 0 ; for ( int i = startFileNo ; ( endFileNo == - 1 || i <= endFileNo ) && i < numSequences . length ; i ++ ) { try ( RandomAccessFile raf = new RandomAccessFile ( SdfFileUtils . sequencePointerFile ( mDirectory , i ) , "r" ) ) { final long pos ; if ( i == startFileNo ) { pos = ( internalStart - startLower ) * entrySize ; raf . seek ( pos ) ; } else { pos = 0 ; } final long endPos = endFileNo == i ? ( internalEnd - endLower ) * entrySize : raf . length ( ) ; seqNo = sequenceLengthsHelper ( raf , buffer , ret , seqNo , pos , endPos , entrySize ) ; if ( endFileNo != i && seqNo > 0 ) { final long fileLength = dataIndex . dataSize ( i ) ; ret [ seqNo - 1 ] = ret [ seqNo - 1 ] - ( int ) fileLength ; } else { if ( seqNo != ret . length ) { throw new CorruptSdfException ( "Should have read " + ret . length + " sequence pointers, got " + seqNo ) ; } raf . read ( ) ; ret [ seqNo - 1 ] -= raf . readInt ( ) ; } } } ret [ ret . length - 1 ] = 0 - ret [ ret . length - 1 ] ; return ret ; }
puts lengths of sequences in an array and returns it . lightly tested
