Package data.cerevisiae.harbison

Source Code of data.cerevisiae.harbison.Combine

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

import fork.lib.base.collection.NamedTable;
import fork.lib.base.file.FileName;
import fork.lib.base.file.io.txt.ReadTable;
import fork.lib.base.file.management.Dirs;
import java.io.File;

/**
*
* @author forksapien
*/
public class Combine {
   
protected File[] fs;
   
   
    public Combine(File[] fs){
        this.fs=fs;
    }
   
   
   
   
public void writeToFile(File out) throws Exception{
    out.getParentFile().mkdirs();
    NamedTable<String,String, String> tab= new NamedTable<>();
   
    for(int i=0; i<fs.length ; i++){
        File f= fs[i];
        String cn= FileName.getBaseName(f);
        tab.appendEmptyColumn(cn);
        ReadTable rt= new ReadTable(f);
        String[] rns= rt.getColumn(3);
        String[] vs= rt.getColumn(4);
        for(int j=0; j<rns.length ; j++){
            String rn= rns[j];
            String v= vs[j];
            if(!tab.containsRow(rn)){
                tab.appendEmptyRow(rn);
            }
            tab.setValueAt(v, rn, cn);
        }
    }
   
    tab.setNullValues("NAN");
    tab.writeToFile(out);
}
   
   
   
   
   
   
   
public static void main(String[] args) throws Exception{ //debug
    File dir= Dirs.getFile("dir");
    File d= new File(dir+"/data/chip-seq/norm/score/sacCer1-xu");
   
    String ty= "742-wt_r1";
   
    File dd= new File(d+"/"+ ty);
   
    Combine cc= new Combine(new File[]{
        new File(dd+"/"+ty+"_sacCer1-xu_gene_five_150.0.bed"),
        new File(dd+"/"+ty+"_sacCer1-xu_gene_five_0.150.bed"),
        new File(dd+"/"+ty+"_sacCer1-xu_gene_cds_300.300.bed"),
        new File(dd+"/"+ty+"_sacCer1-xu_gene_three_150.0.bed"),
        new File(dir+"/other_datasets/lee_2007/norm/score/742-lee2007_sacCer1-xu_gene_five_150.0.bed"),
        new File(dir+"/other_datasets/lee_2007/norm/score/742-lee2007_sacCer1-xu_gene_five_0.150.bed"),
        new File(dir+"/other_datasets/lee_2007/norm/score/742-lee2007_sacCer1-xu_gene_cds_300.300.bed"),
        new File(dir+"/data/rna/norm/score/sacCer1-xu/742-wt_sense.bed"),
        new File(dir+"/other_datasets/lee_2007/score/lee2007_sacCer1-xu_gene_five_150.0.bed"),
        new File(dir+"/other_datasets/lee_2007/score/lee2007_sacCer1-xu_gene_five_0.150.bed"),
        new File(dir+"/other_datasets/lee_2007/score/lee2007_sacCer1-xu_gene_cds_300.300.bed")
            });
   
    File out= new File(dd+"/combine.txt");
    cc.writeToFile(out);
   
}
   
   
}
TOP

Related Classes of data.cerevisiae.harbison.Combine

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.