/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package data.human.inhouse.chippeak.cuff;
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.BedReader;
import fork.lib.bio.anno.genomic.region.GenomicRegionsBuilder;
import fork.lib.bio.anno.genomic.region.GenomicRegionsComparator;
import fork.lib.bio.anno.genomic.region.GenomicRegionsModifier;
import java.io.File;
/**
*
* @author muxin gu
*/
public class CountAssociated {
protected GenomicRegionsBuilder gbpeak, gbtr;
public int side= 100;
public CountAssociated(GenomicRegionsBuilder gbpeak, GenomicRegionsBuilder gbtr)throws Exception{
this.gbpeak= gbpeak;
this.gbtr= gbtr;
}
public void writeToDir(File od, String tag)throws Exception{
GenomicRegionsBuilder gbr= new GenomicRegionsModifier(gbtr).getExtendedRegions(side, side);
GenomicRegionsComparator gc= new GenomicRegionsComparator(gbpeak, gbr);
File ofa= new File(od+"/asso-"+side+"_"+ tag+".bed");
File ofn= new File(od+"/asso-not-"+side+"_"+ tag+".bed");
new BedExporter( gc.getIntersection() ).writeToFile(ofa);
new BedExporter( gc.getNonIntersection() ).writeToFile(ofn);
}
public static void main(String[] args) throws Exception { //debug
File dir = Dirs.getFile("dir");
String time= "5";
File zd= new File(dir+"/data/human_magnus/h2az/macs/novel");
File rd= new File(dir+"/data\\human_magnus\\rna\\cuff/time-"+time);
File zf= new File(zd+"/novel_mcf7_chip-h2az_time-"+time+"_peaks.bed");
File rf= new File(rd+"/novel.bed");
GenomicRegionsBuilder gbz= new BedReader(zf).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbr= new BedReader(rf).getGenomicRegionsBuilder();
CountAssociated cc= new CountAssociated(gbz, gbr);
cc.writeToDir(rd, FileName.getBaseName(zf));
}
}