/*
* 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 data.cerevisiae.inhouse.jointable.JoinTable;
import fork.lib.base.file.FileName;
import fork.lib.base.file.io.txt.ReadTable;
import fork.lib.base.file.management.Dirs;
import fork.lib.bio.anno.genomic.BedAttribute;
import fork.lib.bio.anno.genomic.BedReader;
import fork.lib.bio.anno.genomic.region.GenomicRegion;
import fork.lib.bio.anno.genomic.region.GenomicRegionsBuilder;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
/**
*
* @author man-mqbpjmg4
*/
public class CombineChip extends JoinTable{
public void addMergeFile(File f)throws Exception {
String cntag= FileName.getBaseName(f);
HashMap<String, String> hma= new HashMap<>();
HashMap<String, String> hmb= new HashMap<>();
GenomicRegionsBuilder gb= new BedReader(f).getGenomicRegionsBuilder();
Iterator<GenomicRegion> it= gb.iterator();
while(it.hasNext()){
GenomicRegion gr= it.next();
String u= gr.chr+":"+(int)gr.low+"-"+(int)gr.high;
hma.put( u, gr.getID());
hmb.put( u, Double.toString(gr.getValue()));
}
this.addHashMapIDToVal(hma, cntag+"_gene");
this.addHashMapIDToVal(hmb, cntag+"_loc");
}
public static void main(String[] args) throws Exception { //debug
File dir= Dirs.getFile("dir");
//File d= new File(dir+"/data\\human_magnus\\h2az\\norm\\peak/merge/score");
//File d= new File(dir+"/data\\human_magnus\\h2az\\norm\\peak/merge/scoreNorm");
File d= new File(dir+"/data\\human_magnus\\h2az/macs/merge/scoreNorm");
File out= new File(d+"/combine.txt");
String[] tms= new String[]{
"0","5","10","20","40","80","160","320","640","1280",
};
CombineChip jj= new CombineChip();
boolean ifinit= false;
for( int i=0; i<tms.length; i++ ){
File f= new File(d+"/chip_norm_wig_mcf7_chip-h2az_time-"+tms[i]+"_hg19.bed");
if(FileName.getExt(f).equals("bed")){
if(!ifinit){
jj.initRows(f);
//jj.addMergeFile( new File(d.getParentFile()+"/locate_refseq_hg19_exon.bed"));
//jj.addMergeFile( new File(d.getParentFile()+"/locate_ensGene_hg19_exon.bed"));
ifinit=true;
}
jj.addBedFile(f);
}
}
jj.writeToFile(out);
}
}