Package data.cerevisiae.harbison

Source Code of data.cerevisiae.harbison.Harbison2004Summary

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package data.cerevisiae.harbison;

import common.inspect.GeneSet;
import fork.lib.base.Print;
import fork.lib.base.file.io.txt.ReadTable;
import fork.lib.base.file.management.Dirs;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

/**
*
* @author forksapien
*/
public class Harbison2004Summary {
   
   
protected File f;
   
    public Harbison2004Summary(File f){
        this.f=f;
    }
   
   
   
   
   
public void writeToFile(File out) throws Exception{
    out.getParentFile().mkdirs();
    String[][] arr= new ReadTable(f).getTableAsArray();
    String[] cns= arr[0];
    for(int i=1; i<cns.length ; i++){
        String tf= cns[i];
        tf= tf.replace("_YPD", "");
        tf= tf.replace("(", "");
        tf= tf.replace(")", "");
        tf= tf.replace(" ", "_");
        tf= tf.toUpperCase();
        cns[i]= tf;
    }
    BufferedWriter bw= new BufferedWriter(new FileWriter(out));
    for(int i=1; i<arr.length ; i++){
        String[] r= arr[i];
        String id= r[0];
        int n=0;
        String tfs= "";
        for(int j=1; j<r.length ; j++){
            String tf= cns[j];
            double pv= Double.parseDouble(r[j]);
            if(pv<0.001){
                n++;
                tfs+=tf+"/";
            }
        }
        bw.write(id+"\t"+n+"\t"+tfs+"\n");
    }
    bw.close();
   
}


   
   


public static void main(String[] args) throws Exception{ //debug
    File dir= Dirs.getFile("dir");
    File f= new File(dir+"/other_datasets/harbison_2004/pvalbygene_forpaper_abbr.txt");
    Harbison2004Summary hh= new Harbison2004Summary(f);

    hh.writeToFile(new File(f.getParentFile()+"/summary.txt"));
   
}
   
   
}
TOP

Related Classes of data.cerevisiae.harbison.Harbison2004Summary

TOP
Copyright © 2018 www.massapi.com. 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.