Package data.cerevisiae.region.wt4krlen

Source Code of data.cerevisiae.region.wt4krlen.Select

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

import fork.lib.base.file.io.txt.ReadTable;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.text.DecimalFormat;

/**
*
* @author forksapien
*/
public class Select {
   
   
public static void main(String[] args) throws Exception {
    File dir= new File("/home/forksapien/mystudy/phd/files");
    File d= new File(dir+"/anno/bed/len/score");
    String a= "742";
    String b= "743";
    File sd= new File(d+"/select_change");
    sd.mkdirs();
    //double fold= 1.5; double diff= 30;
    //double fold= 2; double diff= 40;
    double fold= 2; double diff= 30;
   
    File fa= new File(d+"/score_norm_"+a+"_len_150.bed");
    File fb= new File(d+"/score_norm_"+b+"_len_150.bed");
   
    ReadTable rt= new ReadTable(fa);
    String[][] a1= rt.getTableAsArray();
    rt= new ReadTable(fb);
    String[][] a2= rt.getTableAsArray();
   
    DecimalFormat df= new DecimalFormat("#.##");
    String tag= a+"_"+b+"_"+fold+"_"+diff;
    BufferedWriter bwup= new BufferedWriter(new FileWriter(new File(sd+"/select_"+tag+"_up.bed")));
    BufferedWriter bwdown= new BufferedWriter(new FileWriter(new File(sd+"/select_"+tag+"_down.bed")));
    BufferedWriter bwn= new BufferedWriter(new FileWriter(new File(sd+"/select_"+tag+"_nochange.bed")));
    for( int i=0; i<a1.length ; i++ ){
        String[] r1= a1[i];
        String[] r2= a2[i];
        double v1= Double.parseDouble(r1[4]);
        double v2= Double.parseDouble(r2[4]);
        String l= r1[0]+"\t"+r1[1]+"\t"+r1[2]+"\t"+r1[3]+"\t"+ df.format(v1)+"_"+df.format(v2)+ "\t" +r1[5]+"\n";
        //String l= r1[0]+"\t"+r1[1]+"\t"+r1[2]+"\t"+r1[3]+"\t"+ "0"+ "\t" +r1[5]+"\n";
        if( (v1/v2)>fold && (v1-v2)>diff  ){
            bwdown.write(l);
        }else if( (v2/v1)>fold && (v2-v1)>diff ){
            bwup.write(l);
        }else{
            bwn.write(l);
        }
    }
   
    bwup.close();
    bwdown.close();
    bwn.close();
}


}

TOP

Related Classes of data.cerevisiae.region.wt4krlen.Select

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.