Package prop

Source Code of prop.PropName

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

import fork.lib.bio.anno.id.CrossAnno;
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 java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import prop.clas.ClassTelomere;

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

protected File link, file;

public GenomicRegionsBuilder gb;


   
    public PropName(File link, File file) throws Exception{
        this.link=link;
        this.file=file;
        init();
    }
   
   
protected void init() throws Exception{
    gb= new BedReader(file).getGenomicRegionsBuilder();
   
    CrossAnno cr= new CrossAnno(link,0,1);
    Iterator<GenomicRegion> it = gb.iterator();
    while(it.hasNext()){
        GenomicRegion gr= it.next();
        String n= gr.attr.toString();
        String nn= cr.map(n);
        if(nn==null){
            nn= n;
        }
        gr.attr= new Object[]{n, nn};
    }
}
   
public void writeToFile(File out) throws Exception{
    BedExporter be= new BedExporter(gb){
        protected String column3(GenomicRegion gr){
            return ((Object[])gr.attr)[0].toString();
        }
        protected String column4(GenomicRegion gr){
            return ((Object[])gr.attr)[1].toString();
        }
    };
    be.writeToFile(out);
}
   
   


public static void main(String[] args) throws Exception {
    File dir= new File("/home/forksapien/mystudy/phd/files");
    //File dir= new File("G:/mystudy/phd/files");
   
    File f= new File(dir+"/anno/sgdGene_sacCer1.bed");
    File nf= new File(dir+"/anno/raw/sgd_name.txt");
   
    PropName cl= new PropName(nf, f);
    cl.writeToFile(new File(dir+"/anno/sgd_name.bed"));
   
}
   
   
}
TOP

Related Classes of prop.PropName

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.