/*
* 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.statham2014mods;
import fork.lib.base.file.management.Dirs;
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.GenomicRegionsCrossover;
import fork.lib.bio.anno.genomic.region.rand.RandomGenomicRegionSet;
import fork.lib.math.algebra.RandomObject;
import fork.lib.math.applied.stat.Distribution;
import fork.lib.math.applied.stat.FrequencyCount;
import java.io.File;
/**
*
* @author man-mqbpjmg4
*/
public class InspectCrossover {
protected GenomicRegionsBuilder gbtar, gbref, gball;
public InspectCrossover(GenomicRegionsBuilder gbtar, GenomicRegionsBuilder gbref, GenomicRegionsBuilder gball)throws Exception {
this.gbtar= gbtar;
this.gbref = gbref;
this.gball= gball;
init();
}
protected void init() throws Exception {
//overlap();
random();
}
protected int ovl(GenomicRegionsBuilder tar, GenomicRegionsBuilder ref) throws Exception{
GenomicRegionsCrossover gc= new GenomicRegionsComparator(tar, ref).getCrossover();
//gc.both.print();
return gc.both.size();
//return gc.tarOnly.size();
}
protected void random()throws Exception {
System.out.println(ovl(gbtar, gbref));
Distribution disb= new Distribution();
//for( int i=0; i<100; i++ ){
for( int i=0; i<1; i++ ){
FrequencyCount<Integer> lens= gbtar.lengthDistribution();
//System.out.print(i+" ");
GenomicRegionsBuilder rset= new RandomGenomicRegionSet(gball, lens).getRandomGenomicRegions();
//rset.print();
int ovl= ovl(rset, gbref);
System.out.println(rset.size()+" "+ gbref.size()+" "+ovl);
}
}
public static GenomicRegionsBuilder overlap(GenomicRegionsBuilder tar, GenomicRegionsBuilder ref)throws Exception {
GenomicRegionsCrossover gc= new GenomicRegionsComparator(tar, ref).getCrossover();
return gc.both;
}
public static GenomicRegionsBuilder tarOnly(GenomicRegionsBuilder tar, GenomicRegionsBuilder ref)throws Exception {
GenomicRegionsCrossover gc= new GenomicRegionsComparator(tar, ref).getCrossover();
return gc.tarOnly;
}
public static void main(String[] args) throws Exception { //debug
File dir= Dirs.getFile("dir");
File ad= new File(dir+"/anno/bed/hg19/ensGene_hg19/genic");
File d= new File(dir+"/other_datasets/statham2014_mcf7-mods/norm/peaks/locate");
File d2= new File(dir+"/data/human_magnus/h2az/norm/peak/locate/ensGene_hg19_exon");
String pos= "intergenic"; File af= new File(ad+"/hg19_intergenic_5000.bed");
File ef= new File(d+
"/ensGene_hg19_exon/peak_norm_wig_mcf7_h3k27ac_SRR1282218_hg19"+
"/locate_"+pos+".bed"
);
File emf= new File(d+
"/ensGene_hg19_exon/peak_norm_wig_mcf7_h3k4me1_SRR1282220_hg19"+
"/locate_"+pos+".bed"
);
File zf= new File(d2+"/peak_norm_wig_mcf7_chip-h2az_time-0_hg19"+
"/locate_"+pos+".bed"
);
String xxx= "h3k4me3";
File xf= new File(dir+"/data/human_magnus/"+xxx+"/norm/peak/locate/ensGene_hg19_exon"+
"/peak_norm_wig_mcf7_chip-"+xxx+"_time-0_hg19"+
"/locate_"+pos+".bed"
);
GenomicRegionsBuilder gbe= new BedReader(ef).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbem= new BedReader(emf).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbz= new BedReader(zf).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbx= new BedReader(xf).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbinter= new BedReader(af).getGenomicRegionsBuilder();
GenomicRegionsBuilder gbndr= new BedReader(new File(dir+"/other_datasets/statham2014_mcf7-mods/locate/GSM1383850_MCF7_NDR_"+pos+".bed")).getGenomicRegionsBuilder();
GenomicRegionsBuilder gba= overlap(gbem, gbz);
GenomicRegionsBuilder gbb= gbndr;
System.out.println("a: "+gba.size());
System.out.println("b: "+gbb.size());
InspectCrossover ins = new InspectCrossover(gba, gbb, gbinter );
}
}