Java Code Examples for htsjdk.tribble.util.LittleEndianOutputStream#writeFloat()

The following examples show how to use htsjdk.tribble.util.LittleEndianOutputStream#writeFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatrixZoomData.java    From JuiceboxLegacy with MIT License 6 votes vote down vote up
private void dumpPearsons(PrintWriter pw, LittleEndianOutputStream les, ExpectedValueFunction df) throws IOException {
    BasicMatrix pearsons = getPearsons(df);
    if (pearsons != null) {
        int dim = pearsons.getRowDimension();
        for (int i = 0; i < dim; i++) {
            for (int j = 0; j < dim; j++) {
                float output = pearsons.getEntry(i, j);
                if (les != null) les.writeFloat(output);
                else pw.print(output + " ");
            }
            if (les == null) pw.println();
        }
        pw.flush();
    } else {
        log.error("Pearson's not available at zoom " + zoom);
    }
}
 
Example 2
Source File: Preprocessor.java    From Juicebox with MIT License 6 votes vote down vote up
private void writeZoomHeader(MatrixZoomDataPP zd, LittleEndianOutputStream los) throws IOException {

        int numberOfBlocks = zd.blockNumbers.size();
        los.writeString(zd.getUnit().toString());  // Unit
        los.writeInt(zd.getZoom());     // zoom index,  lowest res is zero
        los.writeFloat((float) zd.getSum());      // sum
        los.writeFloat((float) zd.getOccupiedCellCount());
        los.writeFloat((float) zd.getPercent5());
        los.writeFloat((float) zd.getPercent95());
        los.writeInt(zd.getBinSize());
        los.writeInt(zd.getBlockBinCount());
        los.writeInt(zd.getBlockColumnCount());
        los.writeInt(numberOfBlocks);

        zd.blockIndexPosition = los.getWrittenCount();

        // Placeholder for block index
        for (int i = 0; i < numberOfBlocks; i++) {
            los.writeInt(0);
            los.writeLong(0L);
            los.writeInt(0);
        }

    }
 
Example 3
Source File: ScratchPad.java    From JuiceboxLegacy with MIT License 5 votes vote down vote up
public static void writeHeader(String path) throws IOException {

        File f = new File(path);

        FileOutputStream fos = new FileOutputStream(f);
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        LittleEndianOutputStream los = new LittleEndianOutputStream(bos);

        // Magic number - 4 bytes
        los.writeByte('h');
        los.writeByte('i');
        los.writeByte('c');
        los.writeByte(0);

        // Version number
        los.writeInt(1);

        // Genome --
        los.writeString("hg19");

        // Chromosomes
        los.writeString("14");
        los.writeString("14");

        // Resolution (bin size)
        los.writeInt(5000);

        // Statistics, other attributes
        los.writeFloat(-0.004103539418429137f);
        los.writeFloat(0.03536746241152287f);
        los.writeInt(21458);  // # rows, assuming square matrix

        los.close();
        bos.close();
        fos.close();

    }
 
Example 4
Source File: Pearsons.java    From Juicebox with MIT License 5 votes vote down vote up
private void writeHeader(LittleEndianOutputStream les, int dim, float lower, float upper) throws IOException {

        // Magic number - 4 bytes
        les.writeByte('h');
        les.writeByte('i');
        les.writeByte('c');
        les.writeByte(0);

        // Version number
        les.writeInt(1);

        // Genome --
        les.writeString(dataset.getGenomeId());

        // Chromosomes
        les.writeString(chromosome1.getName());
        les.writeString(chromosome1.getName());

        // Resolution (bin size)
        les.writeInt(binSize);

        // Statistics, other attributes
        les.writeFloat(lower);  // this is supposed to be lower quartile
        les.writeFloat(upper);  // this is supposed to be upper quartile
        les.writeInt(dim);  // # rows
        les.writeInt(dim);  // # cols
        les.writeInt(BLOCK_TILE);
    }