@Throws(IOException::class) fun tbiIndexToUniqueString(`is`: InputStream?): String? { val ret = StringBuilder() val buf = ByteArray(4096) readIOFully(`is`, buf, 4) val header = String(buf, 0, 4) ret.append("Header correct: ").append(header == "TBI") .append(com.sun.tools.javac.util.StringUtils.LS) readIOFully(`is`, buf, 4) val numRefs: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 0) ret.append("numRefs: ").append(numRefs).append(com.sun.tools.javac.util.StringUtils.LS) readIOFully(`is`, buf, 28) val format: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 0) val colSeq: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 4) val colBeg: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 8) val colEnd: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 12)val meta: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 16) val skip: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 20) val refNameLength: Int = ByteArrayIOUtils.bytesToIntLittleEndian(buf, 24) val formatStr: String formatStr = TbiFormat.values().get(format and 0xffff).name() ret.append("Format: ").append(formatStr).append(" 0-based: ") .append(format and 0x10000 != 0).append(com.sun.tools.javac.util.StringUtils.LS) ret.append("Columns: (refName:Start-End) ").append(colSeq).append(":").append(colBeg).append("-").append(colEnd).append(com.sun.tools.javac.util.StringUtils.LS) ret.append("Meta: ").append(meta.toChar()).append(com.sun.tools.javac.util.StringUtils.LS) ret.append("Skip: ").append(skip).append(com.sun.tools.javac.util.StringUtils.LS) val names = ByteArray(refNameLength) readIOFully(`is`, names, names.size) ret.append("Sequence names: ") var first = true var off = 0 for (i in 0 until numRefs) {var newOff = off while (newOff < names.size && names[newOff] != 0) { newOff++ } if (!first) { ret.append(", ") } ret.append(String(names, off, newOff - off)) off = newOff + 1 first = false } ret.append(com.sun.tools.javac.util.StringUtils.LS) ret.append(indicesToUniqueString(`is`, numRefs)) .append(com.sun.tools.javac.util.StringUtils.LS) return ret.toString() }
Creates a string representation of the TABIX index