/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package common.inspect;
import com.mysql.jdbc.Statement;
import common.Connect;
import fork.lib.base.Print;
import fork.lib.base.file.io.txt.ReadTable;
import fork.lib.math.algebra.elementary.set.discrete.DiscreteSet;
import java.io.File;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
/**
*
* @author forksapien
*/
public class InspectSetAll {
protected DiscreteSet<String> set= new DiscreteSet<>();
protected String tab;
protected ArrayList<String> cols;
public InspectSetAll(Collection<String> ss, String tab)throws Exception{
this.set.addAll(ss);
this.tab=tab;
init();
start();
}
protected void init()throws Exception{
cols= Connect.getColumnNames(tab);
}
protected void start()throws Exception{
System.out.println("list size: "+ set.size()+"\n");
for( int i=0; i<cols.size() ; i++ ){
//for( int i=28; i<29 ; i++ ){
String cn= cols.get(i);
System.out.println(cn);
String q= "select id,"+cn+" from "+ tab+";";
ResultSet res= Connect.conn.createStatement().executeQuery(q);
HashMap<String, Double> idv= new HashMap<>();
while(res.next()){
String fd= res.getString(cn);
if(fd==null){
fd="0";
}
idv.put(res.getString("id"), Double.parseDouble(fd));
}
res.close();
ClassifierGeneValue cl= new ClassifierGeneValue(idv,cn, 10);
InspectSet ins= new InspectSet(cl, set);
System.out.println(ins.getOutput());
}
}
public static void main(String[] args) throws Exception {
File f= new File("/home/forksapien/mystudy/phd/files/temp2/list.txt"); int col=0;
//File f= new File("/home/forksapien/mystudy/phd/files/temp2/772-wt_sense.bed"); int col=3;
String tab= "xuhistone";
List li =Arrays.asList(new ReadTable(f).getColumn(col));
InspectSetAll in= new InspectSetAll(li, tab);
}
}