/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package data.cerevisiae.basehoar2004tata;
import fork.lib.base.file.io.txt.ReadTable;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
/**
*
* @author forksapien
*/
public class PrepareTata {
protected File f;
public ArrayList<String> ta, tl;
public PrepareTata(File f) throws IOException{
this.f=f;
init();
}
protected void init() throws IOException{
ta= new ArrayList<>();
tl= new ArrayList<>();
String[][] arr= new ReadTable(f).getTableAsArray();
for( int i=0; i<arr.length ; i++ ){
String[] r= arr[i];
if(r.length>4){
String id= r[0];
String clas= r[4];
if(clas.equals("1")){
ta.add(id);
}else{
tl.add(id);
}
}
}
}
public void writeToFile(File out) throws IOException{
out.getParentFile().mkdirs();
BufferedWriter bw= new BufferedWriter(new FileWriter(out));
bw.write(">TATA\n");
for( int i=0; i<ta.size() ; i++ ){
bw.write(ta.get(i)+"\n");
}
bw.write(">TATAless\n");
for( int i=0; i<tl.size() ; i++ ){
bw.write(tl.get(i)+"\n");
}
bw.close();
}
public static void main(String[] args) throws Exception {
File dir= new File("/home/forksapien/mystudy/phd/files");
File f= new File(dir+"/anno/sacCer1/raw/Basehoar_2004_TATA.txt");
PrepareTata pp= new PrepareTata(f);
File out= new File(dir+"/anno/sacCer1/clas/Basehoar_2004_TATA_TATA-less.txt");
pp.writeToFile(out);
}
}