private int writeIndex() throws IOException { // compress and write BufferedByteWriter buff = new BufferedByteWriter(); buff.putInt(chrPositionMap.size()); for (Map.Entry<String, IndexEntry> entry : chrPositionMap.entrySet()) { IndexEntry ie = entry.getValue(); buff.putNullTerminatedString(entry.getKey()); buff.putLong(ie.position); buff.putInt(ie.size); } byte[] bytes = buff.getBytes(); write(bytes); return bytes.length; }
private void writeHeader() throws IOException { // Magic number -- 4 bytes byte[] magicNumber = new byte[]{'E', 'Q', 'T', 'L'}; BufferedByteWriter buffer = new BufferedByteWriter(); buffer.put(magicNumber); buffer.putInt(version); // Reserve space for the master index pointer and byte count. // The actual values will be written at the end indexPositionPosition = buffer.bytesWritten(); buffer.putLong(0l); // File position for start of index buffer.putInt(0); // Size in bytes of index final byte[] bytes = buffer.getBytes(); write(bytes); }
public void writeTo(BufferedByteWriter fos) throws IOException { fos.putNullTerminatedString(TDFTile.Type.fixedStep.toString()); fos.putInt(getSize()); fos.putInt(start); fos.putFloat((float) span); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { fos.putFloat(data[i][j]); } } }
public byte [] encodeBinary() throws IOException { BufferedByteWriter writer = new BufferedByteWriter(); writer.putNullTerminatedString(snp); writer.putNullTerminatedString(chr); writer.putInt(position); writer.putNullTerminatedString(geneId); writer.putNullTerminatedString(geneName); //writer.putFloat(tStat); writer.putFloat(pValue); //writer.putFloat(qValue); return writer.getBytes(); }
private void writeDatasets() throws IOException { for (TDFDataset dataset : datasetCache.values()) { long position = bytesWritten; BufferedByteWriter buffer = new BufferedByteWriter(); dataset.write(buffer); write(buffer.getBytes()); int nBytes = (int) (bytesWritten - position); datasetIndex.put(dataset.getName(), new IndexEntry(position, nBytes)); } }
public void write(BufferedByteWriter dos) throws IOException { writeAttributes(dos); writeString(dos, dataType.toString()); dos.putFloat(tileWidth); // dos.writeFloat(binWidth); dos.putInt(tilePositions.length); for (int i = 0; i < tilePositions.length; i++) { dos.putLong(tilePositions[i]); dos.putInt(tileSizes[i]); } }
currentChrBuffer = new BufferedByteWriter(); currentChrBuffer.put(feature.encodeBinary());
public void putFloat(float f) throws IOException { int v = Float.floatToIntBits(f); putInt(v); }
/** * Write a string as a null terminated character sequence. * <p/> * IGV requires all strings to be ascii, so single byte storaged is enough * * @param dos * @param s * @throws java.io.IOException */ public void writeString(BufferedByteWriter dos, String s) throws IOException { dos.putNullTerminatedString(s); }
public void putDouble(Double f) throws IOException { long v = Double.doubleToLongBits(f); putLong(v); }
private void writeChrBuffer() throws IOException { // compress and write byte[] rawBytes = currentChrBuffer.getBytes(); byte[] compressedBytes = rawBytes; //compressionUtils.compress(rawBytes); int position = bytesWritten; int size = compressedBytes.length; write(compressedBytes); chrPositionMap.put(currentChr, new IndexEntry(position, size)); }
private void writeGroups() throws IOException { for (TDFGroup group : groupCache.values()) { long position = bytesWritten; BufferedByteWriter buffer = new BufferedByteWriter(); group.write(buffer); write(buffer.getBytes()); int nBytes = (int) (bytesWritten - position); groupIndex.put(group.getName(), new IndexEntry(position, nBytes)); } }
public void write(BufferedByteWriter dos) throws IOException { writeAttributes(dos); writeString(dos, dataType.toString()); dos.putFloat(tileWidth); // dos.writeFloat(binWidth); dos.putInt(tilePositions.length); for (int i = 0; i < tilePositions.length; i++) { dos.putLong(tilePositions[i]); dos.putInt(tileSizes[i]); } }
public void putFloat(float f) throws IOException { int v = Float.floatToIntBits(f); putInt(v); }
/** * Write a string as a null terminated character sequence. * <p/> * IGV requires all strings to be ascii, so single byte storaged is enough * * @param dos * @param s * @throws java.io.IOException */ public void writeString(BufferedByteWriter dos, String s) throws IOException { dos.putNullTerminatedString(s); }
private void writeIndexPosition(String file, long indexPosition, int nbytes) { try { RandomAccessFile raf = new RandomAccessFile(file, "rw"); raf.getChannel().position(indexPositionPosition); // Write as little endian BufferedByteWriter buffer = new BufferedByteWriter(); buffer.putLong(indexPosition); buffer.putInt(nbytes); raf.write(buffer.getBytes()); raf.close(); } catch (IOException ex) { ex.printStackTrace(); } }
BufferedByteWriter buffer = new BufferedByteWriter(24); buffer.put(magicNumber); buffer.putInt(version); indexPositionPosition = buffer.bytesWritten(); buffer.putLong(0l); buffer.putInt(0); write(buffer.getBytes()); buffer = new BufferedByteWriter(24); buffer.putInt(windowFunctions.size()); buffer.putNullTerminatedString(wf.toString()); buffer.putNullTerminatedString(trackType.toString()); buffer.put(trackLineBuffer); buffer.putInt(trackNames.length); for (String nm : trackNames) { buffer.putNullTerminatedString(nm); buffer.putNullTerminatedString(genomeId); buffer.putInt(flags); byte[] bytes = buffer.getBytes();
public void writeTo(BufferedByteWriter fos) throws IOException { // File type fos.putNullTerminatedString(TDFTile.Type.variableStep.toString()); fos.putInt(tileStart); fos.putFloat((float)span); int nPositions = start.length; int nSamples = data.length; fos.putInt(nPositions); for (int i = 0; i < nPositions; i++) { fos.putInt(start[i]); } fos.putInt(nSamples); for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[i].length; j++) { fos.putFloat(data[i][j]); } } }
private void writeGroups() throws IOException { for (TDFGroup group : groupCache.values()) { long position = bytesWritten; BufferedByteWriter buffer = new BufferedByteWriter(); group.write(buffer); write(buffer.getBytes()); int nBytes = (int) (bytesWritten - position); groupIndex.put(group.getName(), new IndexEntry(position, nBytes)); } }
void writeAttributes(BufferedByteWriter dos) throws IOException { dos.putInt(attributes.size()); for (Map.Entry<String, String> entry : attributes.entrySet()) { writeString(dos, entry.getKey()); writeString(dos, entry.getValue()); } }