Package data.cerevisiae.tfpwm

Source Code of data.cerevisiae.tfpwm.BadisToLandscape

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

import fork.lib.base.collection.NamedTable;
import fork.lib.base.file.FileName;
import fork.lib.base.file.io.txt.MarkEntry;
import fork.lib.base.file.io.txt.MarkReader;
import fork.lib.base.file.management.Dirs;
import fork.lib.bio.seq.FastaEntry;
import fork.lib.bio.seq.FastaReader;
import fork.lib.bio.seq.align.MotifToLandscape;
import fork.lib.bio.seq.align.PWM;
import java.io.File;
import java.util.ArrayList;

/**
*
* @author forksapien
*/
public class BadisToLandscape {
   
   
   
   
public static void main(String[] args) throws Exception{ //debug
    File dir= Dirs.getFile("dir");
   
    File f= new File(dir+"/data/tf/badis_2008_tf.txt");
    File od= new File(dir+"/data/tf/"+FileName.getBaseName(f));
   
   
    MarkReader ff= new MarkReader(f,">");
    MarkEntry en;
   
    while( (en=ff.nextEntry())!=null ){
        String nm= en.getTitle().split("_TRH1")[0];
        NamedTable<Character,Integer,Double> tab= new NamedTable<>();
        ArrayList<String> ch= en.getChunk();
        for(int i=1; i<ch.size() ; i++){
            String[] ss= ch.get(i).split("\t");
            Character row = ss[0].charAt(0);
            tab.appendEmptyRow(row);
            for(int j=1; j<ss.length ; j++){
                Integer col= j;
                Double v= Double.parseDouble(ss[j]);
                if(!tab.containsColumn(col)){
                    tab.appendEmptyColumn(col);
                }
                tab.setValueAt(v, row, col);
            }
        }
        FastaReader fr= new FastaReader(new File(dir+"/anno/genomes/sacCer1/sacCer1.fa"));
        PWM mot= new PWM(tab);
        MotifToLandscape ml= new MotifToLandscape(fr, mot);

        System.out.println(nm+"  ");
       
        File of= new File(od+"/"+nm+".wig");
        ml.writeToFile(of, nm);
        fr.close();
       
        //System.exit(1);
    }
   
   
}   
   
   
}



TOP

Related Classes of data.cerevisiae.tfpwm.BadisToLandscape

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.