Example #1
0
  public byte[] toByteArray() {
    final ByteBuffer buf = ByteBuffer.allocate(1024);
    buf.order(ByteOrder.LITTLE_ENDIAN);
    buf.put(stopByte);
    ITF8.writeUnsignedITF8(externalId, buf);

    buf.flip();
    final byte[] array = new byte[buf.limit()];
    buf.get(array);

    return array;
  }
Example #2
0
  public void readBlocks(InputStream is, int nBlocks) throws IOException {

    LittleEndianDataInputStream lis = new LittleEndianDataInputStream(is);
    for (int i = 0; i < nBlocks; i++) {

      int compressionMethod = lis.read();
      int contentType = lis.read();
      int contentId = ITF8.readUnsignedITF8(lis);
      int size = ITF8.readUnsignedITF8(lis);
      int rawSize = ITF8.readUnsignedITF8(lis);

      byte[] blockData = new byte[size];
      lis.readFully(blockData);

      blockData = uncompress(blockData, compressionMethod);

      String tmp = new String(blockData);

      if (major >= 3) {
        int checksum = CramInt.int32(lis);
      }
    }
  }
Example #3
0
  public void readContainerHeader(long position) throws IOException {

    SeekableStream ss = IGVSeekableStreamFactory.getInstance().getStreamFor(path);
    ss.seek(position);

    BufferedInputStream bis = new BufferedInputStream(ss);

    int length = CramInt.int32(bis);

    int refSeqId = ITF8.readUnsignedITF8(bis);
    int startPos = ITF8.readUnsignedITF8(bis);
    int alignmentSpan = ITF8.readUnsignedITF8(bis);
    int nRecords = ITF8.readUnsignedITF8(bis);
    int recordCounter = ITF8.readUnsignedITF8(bis);
    int bases = ITF8.readUnsignedITF8(bis);
    int nBlocks = ITF8.readUnsignedITF8(bis);
    int[] landmarks = CramArray.array(bis);
    if (major >= 3) {
      int checksum = CramInt.int32(bis);
    }
    readBlocks(bis, nBlocks);
  }
Example #4
0
 public void fromByteArray(final byte[] data) {
   final ByteBuffer buf = ByteBuffer.wrap(data);
   buf.order(ByteOrder.LITTLE_ENDIAN);
   stopByte = buf.get();
   externalId = ITF8.readUnsignedITF8(buf);
 }