00001 package org.gel.mauve.chado;
00002
00003 import java.sql.*;
00004
00005 public class ChadoFeatureLoader {
00006
00007
00008
00009
00010
00011 private Connection conn;
00012
00013 public ChadoFeatureLoader (Connection chado_conn){
00014 conn = chado_conn;
00015 }
00016
00017 public void getFeatures(String genus, String species ) throws SQLException{
00018 String query = "SELECT organism_id FROM organism WHERE " +
00019 "genus = "+genus+" AND species = "+species+";";
00020 Statement st = conn.createStatement();
00021 ResultSet rs = st.executeQuery(query);
00022 String org_id = rs.getString("organism_id");
00023 st = conn.createStatement();
00024 query = "SELECT * FROM feature WHERE organism_id = "+org_id;
00025 query = "SELECT * FROM feature INNER JOIN annotations WHERE feature.unique_name = annotations.organism_id = "+org_id;
00026 rs = st.executeQuery(query);
00027 int left = -1;
00028 int right = -1;
00029 int strand = 0;
00030 String type = null;
00031 while(rs.next()){
00032 left = rs.getInt("fmin");
00033 right = rs.getInt("fmax");
00034 strand = rs.getInt("strand");
00035 type = rs.getString("name");
00036
00037 }
00038 }
00039
00040 private static String QUERY =
00041 "SELECT featureprop.feature_id, cvterm.name, featureprop.value, featureloc.fmin, featureloc.fmax, featureloc.strand, feature.name, db.name, dbxref.accession, feature.dbxref_id, feature_dbxref.dbxref_id, dbxref.dbxref_id "+
00042 "FROM featureprop, cvterm, featureloc, feature, feature_dbxref, dbxref, db "+
00043 "WHERE organism_id = ? " +
00044 "(featureprop.type_id = cvterm.cvterm_id) AND " +
00045 "(featureprop.feature_id = featureloc.feature_id) AND "+
00046 "(featureprop.feature_id = feature.feature_id) AND " +
00047 "(featureprop.feature_id = feature_dbxref.feature_id) AND "+
00048 "(feature_dbxref.dbxref_id = dbxref.dbxref_id) AND "+
00049 "(dbxref.db_id = db.db_id) "+
00050 "LIMIT 100 OFFSET 0";
00051
00052 }