Package data.cerevisiae.region.wt4krlen

Source Code of data.cerevisiae.region.wt4krlen.GenerateLen

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package data.cerevisiae.region.wt4krlen;

import fork.lib.base.file.management.Dirs;
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.Iterator;

/**
*
* @author forksapien
*/
public class GenerateLen {
   
   
protected GenomicRegionsBuilder gb;
protected GenomicRegionsBuilder gbout;

protected int len;
protected int off;

   
   
    public GenerateLen(GenomicRegionsBuilder gb, int len, int off) throws Exception{
        this.gb= gb;
        this.len=len;
        this.off=off;
        init();
    }
   

private void init() throws Exception{
    gbout= new GenomicRegionsBuilder();
    Iterator<GenomicRegion> it= gb.iterator();
    while(it.hasNext()){
        GenomicRegion gr= it.next();
        int low = (int)gr.low;
        int high= (int)gr.high;
        int ind= low+off;
        while( (ind+len)<=high ){
            gbout.add(new GenomicRegion(gr.chr, ind, ind+len-1));
            ind+= len;
        }
    }
}
   


public void writeToFile(File out) throws Exception{
    gbout.writeToFileBed(out);
}
   
   

public static void main(String[] args) throws Exception {
    File dir= Dirs.getFile("dir");
    int len= 150;
    //int len= 300;
    int[] offs= new int[]{0, 50, 100};
   
    for( int i=0; i<offs.length; i++ ){
        int off= offs[i];
        GenerateLen gg= new GenerateLen(
                new BedReader(new File(dir+"/anno/sacCer1_chr.bed")).getGenomicRegionsBuilder(),
                len, off );
        gg.writeToFile(new File(dir+"/anno/bed/len/len_"+len+"_off_"+off+".bed"));
    }
   
   
}
   
   
}
TOP

Related Classes of data.cerevisiae.region.wt4krlen.GenerateLen

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.