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

eqtlmappingpipeline.binarymeta.meta.cis.CisBinaryConverter Maven / Gradle / Ivy

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eqtlmappingpipeline.binarymeta.meta.cis;

import eqtlmappingpipeline.binarymeta.meta.MetaSettings;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import umcg.genetica.console.ProgressBar;
import umcg.genetica.io.Gpio;
import umcg.genetica.io.bin.BinaryFile;
import umcg.genetica.io.trityper.bin.BinaryResultDataset;
import umcg.genetica.io.trityper.bin.BinaryResultProbe;
import umcg.genetica.io.trityper.bin.BinaryResultSNP;

/**
 *
 * @author harm-jan
 */
public class CisBinaryConverter {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
	// TODO code application logic here
//	if (args.length < 1) {
//	    System.out.println("Usage: converter settings.xml");
//	    System.exit(0);
//	}
        String settingsfile = "/Volumes/Data2/MetaAnalysisSoftware/settings/2011-12-06-CIS-40PCs-4GWAS-GeneticVectorsNotRemoved.xml";
	CisBinaryConverter c = new CisBinaryConverter(settingsfile);
	try {
	    c.run();
	} catch (IOException ex) {
	    Logger.getLogger(CisBinaryConverter.class.getName()).log(Level.SEVERE, null, ex);
	}
    }
    private final MetaSettings m_settings;

    public CisBinaryConverter(String settings) {
	m_settings = new MetaSettings();
	m_settings.parse(settings, null, null);

//         m_settings =  null;
    }

    public void run() throws IOException {

	ArrayList datasetLocations = m_settings.getDatasetlocations();
	ArrayList datasetNames = m_settings.getDatasetnames();
	ArrayList datasetAnnot = m_settings.getDatasetannotations();
//        ArrayList datasetLocations = new ArrayList();
//        datasetLocations.add("d:\\BinData\\");
//        ArrayList datasetNames = new ArrayList();
//        datasetNames.add("Dataset");
	int nrPerm = m_settings.getNrPermutations();
//        int nrPerm = 1;
	int nrprocs = Runtime.getRuntime().availableProcessors() / 2;
//	ExecutorService threadPool = Executors.newFixedThreadPool(nrprocs);

	System.out.println(nrprocs + " procs.");



//	ArrayBlockingQueue inputqueue = new ArrayBlockingQueue(nrprocs);
//	ArrayBlockingQueue>> outputqueue = new ArrayBlockingQueue>>(nrprocs);
////	CompletionService>> pool = new ExecutorCompletionService>>(threadPool, queue);

	Gpio.createDir(m_settings.getOutput());
	System.out.println("Found " + datasetLocations.size() + " datasets..");
	for (int d = 0; d < datasetLocations.size(); d++) {



	    System.out.println("Starting for " + datasetNames.get(d));
	    for (int perm = 0; perm < nrPerm + 1; perm++) {

		String datasetName = "Dataset";

		BinaryResultDataset dataset = new BinaryResultDataset(datasetLocations.get(d), datasetName, perm);
		BinaryResultSNP[] snps = dataset.getSnps();
		BinaryResultProbe[] probes = dataset.getProbes();

		int nrProbes = dataset.getNumProbes();

		String outfile = null;
		if (perm == 0) {
		    outfile = m_settings.getOutput() + datasetNames.get(d) + "-eQTLs.dat";
		} else {
		    outfile = m_settings.getOutput() + datasetNames.get(d) + "-PermutedDataPermutationRound-" + perm + ".dat";
		}

		BinaryFile bf = new BinaryFile(outfile, true);

//		CalcThread[] threads = new CalcThread[nrprocs];
//		for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy