Package data.cerevisiae.region

Source Code of data.cerevisiae.region.GenerateWindowsNonOverlapping

/*
* 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.cerevisiae.region;

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.GenomicRegion;
import fork.lib.bio.anno.genomic.region.GenomicRegionsBuilder;
import fork.lib.math.algebra.elementary.set.continuous.Region;
import java.io.File;

/**
*
* @author man-mqbpjmg4
*/
public class GenerateWindowsNonOverlapping {
   
protected GenomicRegionsBuilder gb;
protected int len;
protected GenomicRegionsBuilder gbout= new GenomicRegionsBuilder();

   
    public GenerateWindowsNonOverlapping(GenomicRegionsBuilder gb, int len)throws Exception {
        this.gb=gb;
        this.len=len;
        init();
    }
   
   
protected void init() throws Exception {
    String[] chrs= gb.getChromosomeList();
    for( int i=0; i<chrs.length; i++ ){
        String chr= chrs[i];
        Region r= gb.getRegionsForChromosome(chr).get(0);
        double low = r.low;
        while(low+len< r.high){
            Region win= new Region((double)low, (double)low+len-1);
            gbout.add(new GenomicRegion(chr, win));
            low+=len;
        }
    }
}

public void writeToFile(File out)throws Exception {
    new BedExporter(gbout).writeToFile(out);
}
   
   
   
   
   
public static void main(String[] args) throws Exception { //debug
    File dir= Dirs.getFile("dir");
    File d= new File(dir+"/anno/bed/sacCer1");
    File anno = new File(dir+"/anno/sacCer1_chr.bed");
   
    int len= 10;
   
    GenomicRegionsBuilder gb= new BedReader(anno).getGenomicRegionsBuilder();
   
    GenerateWindowsNonOverlapping gg= new GenerateWindowsNonOverlapping(gb, len);
    gg.writeToFile(new File(d+"/window/non-ol_"+ len+"_"+FileName.getBaseName(anno)+".bed"));
   
}
   
   
   
   
}
TOP

Related Classes of data.cerevisiae.region.GenerateWindowsNonOverlapping

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.