/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package data.cerevisiae.tfpwm;
import fork.lib.base.file.FileName;
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 ToSummary {
protected File f;
public ToSummary(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> 4){
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+"/data/tf/all_zhu_2009_yeast-tf_sacCer1-xu_gene_five_150.0.txt");
ToSummary hh= new ToSummary(f);
hh.writeToFile(new File(f.getParentFile()+"/summary_zhu_150.txt"));
}
}