Package org.broad.igv.tdf

Examples of org.broad.igv.tdf.BufferedByteWriter


                                            List<PeakRecord> records) throws IOException {

        chrIndex.put(currentChr, peakWriter.getWrittenCount());

        // Compress data for chromosome, then write it out.
        BufferedByteWriter buffer = new BufferedByteWriter(100000);

        buffer.putNullTerminatedString(currentChr);
        buffer.putInt(records.size());
        for (PeakRecord record : records) {
            buffer.putInt(record.start);
            buffer.putInt(record.end);
            buffer.putFloat(record.score);
            for (int i = 0; i < record.timeScores.length; i++) {
                buffer.putFloat(record.timeScores[i]);
            }
        }

        byte[] bytes = buffer.getBytes();
        bytes = compressionUtils.compress(bytes);
        peakWriter.writeInt(bytes.length);
        peakWriter.write(bytes);

        records.clear();
View Full Code Here


        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "rw");
            raf.getChannel().position(0);
            // Write as little endian
            BufferedByteWriter buffer = new BufferedByteWriter();
            buffer.putLong(indexPosition);
            raf.write(buffer.getBytes());
            raf.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            if (raf != null) raf.close();
View Full Code Here

        //this.qValue = qValue;
    }


    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();
    }
View Full Code Here

                    if (currentChrBuffer != null) {
                        System.out.println(currentChr);
                        writeChrBuffer();
                    }
                    currentChr = chr;
                    currentChrBuffer = new BufferedByteWriter();
                }

                currentChrBuffer.put(feature.encodeBinary());

            }
View Full Code Here

    }

    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;

    }
View Full Code Here

    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);
    }
View Full Code Here

        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();
        }
    }
View Full Code Here

TOP

Related Classes of org.broad.igv.tdf.BufferedByteWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.