/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package data.human.inhouse.chippeak;
import fork.lib.base.file.FileName;
import fork.lib.base.file.management.Dirs;
import fork.lib.bio.anno.genomic.BedExporter;
import fork.lib.bio.anno.genomic.BedGraphReader;
import fork.lib.bio.anno.genomic.LandscapeBuilder;
import fork.lib.bio.anno.genomic.PeakIdentifier;
import fork.lib.bio.anno.genomic.region.GenomicRegionsBuilder;
import java.io.File;
/**
*
* @author man-mqbpjmg4
*/
public class GetPeaks {
protected LandscapeBuilder lb;
public GetPeaks(LandscapeBuilder lb){
this.lb=lb;
}
public void writeToFile(File out)throws Exception {
PeakIdentifier pi= new PeakIdentifier(lb, null);
pi.param().joinGap=150;
GenomicRegionsBuilder gb= pi.getPeaks();
new BedExporter(gb).writeToFile(out);
}
public static void main(String[] args) throws Exception { //debug
File dir= Dirs.getFile("dir");
//File d= new File(dir+"/data/human_magnus/h2az/norm");
File d= new File(dir+"/data/human_magnus/h3k4me3/norm");
//File d= new File(dir+"/data/human_magnus/era/norm");
//File d= new File(dir+"/data/human_magnus/polii/norm");
File od= new File(d+"/peak");
File[] fs= d.listFiles();
for( int i=0; i<fs.length; i++ ){
File f= fs[i];
if(FileName.getExt(f).equals("wig")){
GetPeaks gg= new GetPeaks(new BedGraphReader(f).getLandscapeBuilder());
File out= new File(od+"/peak_"+FileName.getBaseName(f)+".bed");
gg.writeToFile(out);
}
}
}
}