public static TDFTile createTile(byte[] buffer, int nSamples) throws IOException { ByteBuffer byteBuffer = ByteBuffer.wrap(buffer); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); String typeString = StringUtils.readString(byteBuffer); TDFTile.Type type = TDFTile.Type.valueOf(typeString); switch (type) { case fixedStep: return new TDFFixedTile(byteBuffer, nSamples); case variableStep: return new TDFVaryTile(byteBuffer, nSamples); case bed: case bedWithName: return new TDFBedTile(byteBuffer, nSamples, type); default: throw new RuntimeException("Unknown tile type: " + type.toString()); } }
public static TDFTile createTile(byte[] buffer, int nSamples) throws IOException { ByteBuffer byteBuffer = ByteBuffer.wrap(buffer); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); String typeString = StringUtils.readString(byteBuffer); TDFTile.Type type = TDFTile.Type.valueOf(typeString); switch (type) { case fixedStep: return new TDFFixedTile(byteBuffer, nSamples); case variableStep: return new TDFVaryTile(byteBuffer, nSamples); case bed: case bedWithName: return new TDFBedTile(byteBuffer, nSamples, type); default: throw new RuntimeException("Unknown tile type: " + type.toString()); } }
public void writeTo(BufferedByteWriter fos) throws IOException { // File type TDFTile.Type type = names == null ? TDFTile.Type.bed : TDFTile.Type.bedWithName; fos.putNullTerminatedString(type.toString()); int nPositions = start.length; int nSamples = data.length; fos.putInt(nPositions); for (int i = 0; i < nPositions; i++) { fos.putInt(start[i]); } for (int i = 0; i < nPositions; i++) { fos.putInt(end[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]); } } // Optionally record feature names if (type == TDFTile.Type.bedWithName) { for (int i = 0; i < nPositions; i++) { fos.putNullTerminatedString(names[i]); } } }
public void writeTo(BufferedByteWriter fos) throws IOException { // File type TDFTile.Type type = names == null ? TDFTile.Type.bed : TDFTile.Type.bedWithName; fos.putNullTerminatedString(type.toString()); int nPositions = start.length; int nSamples = data.length; fos.putInt(nPositions); for (int i = 0; i < nPositions; i++) { fos.putInt(start[i]); } for (int i = 0; i < nPositions; i++) { fos.putInt(end[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]); } } // Optionally record feature names if (type == TDFTile.Type.bedWithName) { for (int i = 0; i < nPositions; i++) { fos.putNullTerminatedString(names[i]); } } }
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]); } } }
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]); } } }
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 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]); } } }