Package prop.clas

Source Code of prop.clas.ClassSubteloFromData

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package prop.clas;

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 fork.lib.math.algebra.elementary.set.continuous.Region;
import java.io.File;
import java.util.ArrayList;

/**
*
* @author forksapien
*/
public class ClassSubteloFromData {

   
protected File dir= Dirs.getFile("dir");
protected File f= new File(dir+"/anno/sacCer1_euchr_lab.bed");

protected GenomicRegionsBuilder gbtel;
public static int sublen= 10000;
   
   
   
    public ClassSubteloFromData()throws Exception{
        init();
    }
   
   
   
protected void init() throws Exception{
    gbtel= new BedReader(f).getGenomicRegionsBuilder();
}
   
public void writeToFile(File anno, File out)throws Exception{
    GenomicRegionsBuilder gb= new BedReader(anno).getGenomicRegionsBuilder();
    GenomicRegionsBuilder gbout= new GenomicRegionsBuilder();
   
    String[] chrs= gb.getChromosomeList();
    for(int i=0; i<chrs.length ; i++){
        String chr= chrs[i];
        Region telr= gbtel.getRegionsForChromosome(chr).get(0);
        int low= (int)telr.low+sublen;
        int high= (int)telr.high-sublen;
        Region eur= new Region(low, high);
        ArrayList<Region> rs= gb.getRegionsForChromosome(chr);
        for(int j=0; j<rs.size() ; j++){
            GenomicRegion r= (GenomicRegion)rs.get(j);
            if(eur.contains(r)){
                r.setValue(0);
            }else{
                r.setValue(1);
            }
           
            gbout.add((GenomicRegion)r);
        }
    }
   
    gbout.writeToFileBed(out);
   
}
   


public static void main(String[] args) throws Exception{ //debug
    File dir= Dirs.getFile("dir");
    File anno = new File(dir+"/anno/xu_2009_orfs.bed"); String org= "sacCer1-xu";
    File out= new File(dir+"/anno/bed/"+org+"/prop/"+org+"_subtelo_lab.bed");
   
    ClassSubteloFromData ss= new ClassSubteloFromData();
    ss.writeToFile(anno, out);
   
   
}
   
   
}
TOP

Related Classes of prop.clas.ClassSubteloFromData

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.