All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.systemsgenetics.eqtlinteractionanalyser.eqtlinteractionanalyser.ExpressionDataset Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nl.systemsgenetics.eqtlinteractionanalyser.eqtlinteractionanalyser;

import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.image.BufferedImage;
import java.awt.image.*;
import java.awt.*;
import java.awt.geom.*;
import java.lang.Math;
import javax.imageio.*;
import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author lude
 */
public class ExpressionDataset {

    public double[][] rawData = null;
    public int nrSamples = 0;
    public int nrProbes = 0;
    public String[] probeNames = null;
    public String[] sampleNames = null;
    public HashMap hashSamples = new HashMap();
    public HashMap hashProbes = new HashMap();
    private HashMap hashProbesToInclude = null;
    private HashMap hashSamplesToInclude = null;
    public String fileName = null;

    public ExpressionDataset(String fileName) {
        if (fileName.endsWith(".binary")) {
            loadExpressionDataInBinaryFormat(fileName);
        } else {
            loadExpressionData(fileName, '\t');
        }
    }

    public ExpressionDataset(String fileName, char delimiter) {
        if (fileName.endsWith(".binary")) {
            loadExpressionDataInBinaryFormat(fileName);
        } else {
            loadExpressionData(fileName, delimiter);
        }
    }

    public ExpressionDataset(String fileName, char delimiter, HashMap hashProbesToInclude) {
        this.hashProbesToInclude = hashProbesToInclude;
        if (fileName.endsWith(".binary")) {
            loadExpressionDataInBinaryFormat(fileName);
        } else {
            loadExpressionData(fileName, delimiter);
        }
    }

    public ExpressionDataset(String fileName, char delimiter, HashMap hashProbesToInclude, HashMap hashSamplesToInclude) {
        this.hashProbesToInclude = hashProbesToInclude;
        this.hashSamplesToInclude = hashSamplesToInclude;
        if (fileName.endsWith(".binary")) {
            loadExpressionDataInBinaryFormat(fileName);
        } else {
            loadExpressionData(fileName, delimiter);
        }
    }

    public ExpressionDataset(int nrProbes, int nrSamples) {
        this.nrProbes = nrProbes;
        this.nrSamples = nrSamples;
        sampleNames = new String[nrSamples];
        for (int s=0; s2 && data[1].length() > 0 && data[1].equals("MultipleHits")) {
                dataIsInTriTyperFormat = true;
                sampleOffset = 9;

            }

            if (hashSamplesToInclude==null) {
                nrSamples = data.length - sampleOffset;
                sampleNames = new String[nrSamples];
                sampleIndex = new int[nrSamples];
                for (int s=0; s> 56);
                    buffer[bufferLoc + 1] = (byte) (bits >> 48 & 0xff);
                    buffer[bufferLoc + 2] = (byte) (bits >> 40 & 0xff);
                    buffer[bufferLoc + 3] = (byte) (bits >> 32 & 0xff);
                    buffer[bufferLoc + 4] = (byte) (bits >> 24 & 0xff);
                    buffer[bufferLoc + 5] = (byte) (bits >> 16 & 0xff);
                    buffer[bufferLoc + 6] = (byte) (bits >> 8 & 0xff);
                    buffer[bufferLoc + 7] = (byte) (bits & 0xff);
                    bufferLoc += 8;
                }
                try {
                    out.write(buffer);
                } catch (IOException e) {
                    System.err.println("Can't write to " + fileBinary.getName() + ": " + e.getMessage());
                    System.exit(1);
                }
            }
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            File fileProbes = new File(fileName + ".rows.txt");
            try {
                java.io.BufferedWriter outProbes = new java.io.BufferedWriter(new java.io.FileWriter(fileProbes));
                for (int p=0; p>> 24),
                    (byte) (value >>> 16),
                    (byte) (value >>> 8),
                    (byte) value};
    }

    private int byteArrayToInt(byte[] b) {
        return (b[0] << 24)
                + ((b[1] & 0xff) << 16)
                + ((b[2] & 0xff) << 8)
                + (b[3] & 0xff);
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy