public static void mergeTabixFiles(File output,List<File> files,List<Long> dataFileSizes) throws IOException {
  long pointerAdjust=0;
  final SequenceIndex[][] indexesSquared=new SequenceIndex[files.size()][];
  final String[][] sequenceNames=new String[files.size()][];
  TabixHeader mergedHeader=null;
  for (int i=0; i < files.size(); i++) {
    final File tbiFile=files.get(i);
    try (BlockCompressedInputStream bcis=new BlockCompressedInputStream(tbiFile)){
      final TabixHeader th=TabixHeader.readHeader(bcis);
      sequenceNames[i]=th.getSequenceNamesUnpacked();
      if (mergedHeader != null) {
        mergedHeader=TabixHeader.mergeHeaders(mergedHeader,th);
      }
 else {
        mergedHeader=th;
      }
      indexesSquared[i]=loadFileIndexes(bcis,th.getNumSequences(),pointerAdjust);
    }
     pointerAdjust+=dataFileSizes.get(i);
  }
  final List<SequenceIndex> indexes=collapseIndexes(indexesSquared,sequenceNames);
  TabixIndexer.mergeChunks(indexes);
  try (BlockCompressedOutputStream fos=new BlockCompressedOutputStream(output)){
    TabixIndexer.writeIndex(indexes,mergedHeader.getOptions(),Arrays.asList(mergedHeader.getSequenceNamesUnpacked()),fos);
  }
 }

public static void mergeTabixFiles ( File output , List < File > files , List < Long > dataFileSizes ) throws IOException { long pointerAdjust = 0 ; final SequenceIndex [ ] [ ] indexesSquared = new SequenceIndex [ files . size ( ) ] [ ] ; final String [ ] [ ] sequenceNames = new String [ files . size ( ) ] [ ] ; TabixHeader mergedHeader = null ; for ( int i = 0 ; i < files . size ( ) ; i ++ ) { final File tbiFile = files . get ( i ) ; try ( BlockCompressedInputStream bcis = new BlockCompressedInputStream ( tbiFile ) ) { final TabixHeader th = TabixHeader . readHeader ( bcis ) ; sequenceNames [ i ] = th . getSequenceNamesUnpacked ( ) ; if ( mergedHeader != null ) { mergedHeader = TabixHeader . mergeHeaders ( mergedHeader , th ) ; } else { mergedHeader = th ; } indexesSquared [ i ] = loadFileIndexes ( bcis , th . getNumSequences ( ) , pointerAdjust ) ; } pointerAdjust += dataFileSizes . get ( i ) ; } final List < SequenceIndex > indexes = collapseIndexes ( indexesSquared , sequenceNames ) ; TabixIndexer . mergeChunks ( indexes ) ; try ( BlockCompressedOutputStream fos = new BlockCompressedOutputStream ( output ) ) { TabixIndexer . writeIndex ( indexes , mergedHeader . getOptions ( ) , Arrays . asList ( mergedHeader . getSequenceNamesUnpacked ( ) ) , fos ) ; } }
merge indexes for files that will be concatenated .
