Package data.cerevisiae.lee2007

Source Code of data.cerevisiae.lee2007.NormToLee

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

import fork.lib.base.file.FileName;
import fork.lib.base.file.management.Dirs;
import fork.lib.bio.anno.genomic.BarReader;
import fork.lib.bio.anno.genomic.BedGraphBuffer;
import fork.lib.bio.anno.genomic.LandscapeBuffer;
import fork.lib.bio.anno.genomic.LandscapeComparatorBuffer;
import java.io.File;

/**
*
* @author forksapien
*/
public class NormToLee {
   
   
protected File f;
protected LandscapeBuffer lbref;

public static File dir= Dirs.getFile("dir");
public static File leef= new File(dir+"/other_datasets/lee_2007/unlog_analyzed_data_complete_bw20.bar");
   


    public NormToLee(File f)throws Exception{
        this.f=f;
        init();
    }
   
   
protected void init() throws Exception{
    lbref= new BarReader(leef).getLandscapeBuilder();
}
   
   
   
public void writeToFile(File out)throws Exception{
    out.getParentFile().mkdirs();
    LandscapeBuffer lb= new BedGraphBuffer(f);
    LandscapeComparatorBuffer lc = new LandscapeComparatorBuffer(lb, lbref) {
            @Override
            public double newValue(double v, double refv) {
                if(refv<0.01){
                    refv=0.01;
                }
                return new Double( (double)Math.round(v/refv * 1000)/1000  );
            }
        };
    String tag= FileName.getBaseName(f)+"_lee2007";
    System.out.println("write ratio to: "+out);
    lc.writeToFile(out, "ratio_"+tag);
}
   
   
   
   
public static void main(String[] args) throws Exception{ //debug
    File dir= Dirs.getFile("dir");
    File d= new File(dir+"/data/chip-seq/norm");
   
    File f= new File(d+"/norm_wig_chip_742-wt_r2_sacCer1.wig");
   
    File od= new File(dir+"/other_datasets/lee_2007/norm");
    File out= new File(od+"/ratio-lee2007_"+FileName.getBaseName(f)+".wig");
   
    NormToLee nn= new NormToLee(f);
    nn.writeToFile(out);
   
}
   
   
   
}
TOP

Related Classes of data.cerevisiae.lee2007.NormToLee

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.