Package data.human.inhouse.chippeak

Source Code of data.human.inhouse.chippeak.GetNovelPeaksIntron

/*
* 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.BedReader;
import fork.lib.bio.anno.genomic.SplicedBedReader;
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 man-mqbpjmg4
*/
public class GetNovelPeaksIntron {
   
   
   
   
protected GenomicRegionsBuilder peaks, in, ex;
   
   
    public GetNovelPeaksIntron(GenomicRegionsBuilder peaks, GenomicRegionsBuilder in, GenomicRegionsBuilder ex)throws Exception {
        this.peaks=peaks;
        this.in=in;
        this.ex=ex;
    }
   
   
   
   
protected void writeToFile(File out)throws Exception {
    GenomicRegionsComparator comp= new GenomicRegionsComparator(peaks, in);
    GenomicRegionsBuilder gbOverlapIn= comp.getIntersection();
    GenomicRegionsComparator comp2= new GenomicRegionsComparator(gbOverlapIn, ex);
    GenomicRegionsBuilder gbOverlapInNotEx = comp2.getNonIntersection();
   
    new BedExporter(gbOverlapInNotEx).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/peak");
    File annof= new File(dir+"/anno/hg19_exon.bed");
   
    File od= new File(d+"/novelIntron");

    int side= -1000;

    SplicedBedReader sr= new SplicedBedReader(annof);
    GenomicRegionsBuilder gbin= sr.getAllIntrons();
    GenomicRegionsModifier gmin= new GenomicRegionsModifier(gbin);
    GenomicRegionsBuilder gbinside= gmin.getExtendedRegions(side, side);
    GenomicRegionsBuilder gbex= sr.getAllExons();
    GenomicRegionsModifier gmex= new GenomicRegionsModifier(gbex);
    GenomicRegionsBuilder gbexside= gmex.getExtendedRegions(500, 500);
   
   
    File[] fs= d.listFiles();
    for( int i=0; i<fs.length; i++ ){
        File pf= fs[i];
        if(FileName.getExt(pf).equals("bed")){
            GenomicRegionsBuilder gbpeak= new BedReader(pf).getGenomicRegionsBuilder();
            GetNovelPeaksIntron gn= new GetNovelPeaksIntron(gbpeak, gbinside, gbexside);

            File out= new File(od+"/novel_"+ pf.getName());
            gn.writeToFile(out);
        }
    }
}





}
TOP

Related Classes of data.human.inhouse.chippeak.GetNovelPeaksIntron

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.