Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Fixed empty args error. Also added code to print actual SQL error messages
authorelserj <elserj@localhost>
Fri, 20 Jul 2012 23:37:26 +0000 (23:37 +0000)
committerelserj <elserj@localhost>
Fri, 20 Jul 2012 23:37:26 +0000 (23:37 +0000)
svn path=/; revision=366

Personnel/miles/2/src/Heatmap.java

index f20e09acf6a2fbd8adec05c1dbd09725edb4d362..ee58794329439d9d78db5a861377211779435221 100644 (file)
@@ -17,8 +17,9 @@ public class Heatmap {
        static int[] allClusterIDs;
        
        public static void main(String[] args) {
-               //String[] geneIDs = new String[] {"mgf009407m", "GRMZM2G457201_T02", "LOC_Os03g53530.1", "Bradi3g44220.1"};
-               Species[] species = getHeatChartData(args);
+               String[] geneIDs = new String[] {"mgf009407m", "GRMZM2G457201_T02", "LOC_Os03g53530.1", "Bradi3g44220.1"};
+               
+               Species[] species = getHeatChartData(geneIDs);
                
                // IF asked for table
                generateDelimitedTable(species);
@@ -44,7 +45,7 @@ public class Heatmap {
                }
                
                PrintWriter printWriter = new PrintWriter(fileWriter);
-               printWriter.print("Species \t");
+               /*printWriter.print("Species \t");
                for (int clust = 0; clust < allClusterIDs.length; clust ++) {
                        printWriter.print("Cluster " + clust + "\t");
                }
@@ -66,7 +67,24 @@ public class Heatmap {
                        }
                }
                printWriter.close();
-       }
+               */
+               
+               printWriter.print("Cluster id");
+               for (int s = 0; s< species.length; s++) {
+                       printWriter.print("\t" + species[s].name);
+               }
+               for (int c = 0; c < allClusterIDs.length; c ++) {
+                       printWriter.print("\n" + c);
+                       for (int s = 0; s < species.length; s ++) {
+                               int frequency = species[s].findClusterFrequency(allClusterIDs[c]);
+                               if (frequency == -1) {
+                                       frequency = 0;
+                               }
+                               printWriter.print("\t" + frequency);
+                       }
+                       
+               }
+               }
        
        // creates a connection, distributes work and information to the various helper functions
        // gathers the final list of species and their geneMaps in one place
@@ -132,6 +150,7 @@ public class Heatmap {
                                        "group by species, super_id order by species");
                } catch (SQLException e) {
                        System.out.println("Statement failed to prepare");
+                       System.err.println("SQLException: " + e.getMessage());
                }
                
                
@@ -140,6 +159,7 @@ public class Heatmap {
                }
                  catch (SQLException e) {
                          System.out.println("Could not execute Query, possible error in statement");
+                         System.err.println("SQLException: " + e.getMessage());
                }
                  
                try {
@@ -153,6 +173,7 @@ public class Heatmap {
                }
                  catch (SQLException e) {
                          System.out.println("Error in returned data - check database");
+                         System.err.println("SQLException: " + e.getMessage());
                  }
                  
                rawSpecies = new Species[speciesCount]; // initialize it to the correct size
@@ -177,6 +198,7 @@ public class Heatmap {
                }
                  catch (SQLException e) {
                          System.out.println("Unexpected Error");
+                         System.err.println("SQLException: " + e.getMessage());
                  }
                  
                rawSpecies = groupSpecies(rawSpecies);
@@ -243,6 +265,8 @@ public class Heatmap {
                                logicStatement = logicStatement + "'";
                        }
                }
+               System.out.println(geneIDs.length);
+               System.out.println(logicStatement);
                
                // finds the clusters that the genes are in
                PreparedStatement findCluster;
@@ -251,6 +275,7 @@ public class Heatmap {
                                        + logicStatement);
                } catch (SQLException e1) {
                        System.out.println("Statment failed to prepare");
+                       System.err.println("SQLException: " + e1.getMessage());
                        findCluster = null;
                }
                
@@ -258,6 +283,7 @@ public class Heatmap {
                        rs = findCluster.executeQuery();
                } catch (SQLException e) {
                        System.out.println("Unable to execute Query");
+                       System.err.println("SQLException: " + e.getMessage());
                }
                
                int totalClusters = 0;
@@ -268,6 +294,7 @@ public class Heatmap {
                        rs.beforeFirst();
                } catch (SQLException e) {
                        System.out.println("Error in data, unable to parse");
+                       System.err.println("SQLException: " + e.getMessage());
                }
                
                allClusters = new int[totalClusters];
@@ -278,6 +305,7 @@ public class Heatmap {
                                allClusters[i] = rs.getInt(1);
                        } catch (SQLException e) {
                                System.out.println("Genes overlap");
+                               System.err.println("SQLException: " + e.getMessage());
                        }
                }
                
@@ -291,12 +319,14 @@ public class Heatmap {
                        useDatabase = connection.prepareStatement("USE inparanoid_data");
                } catch (SQLException e2) {
                        System.out.println("Unexpected Error");
+                       System.err.println("SQLException: " + e2.getMessage());
                        useDatabase = null;
                }
                try {
                        useDatabase.execute();
                } catch (SQLException e) {
                        System.out.println("Unexpected Error");
+                       System.err.println("SQLException: " + e.getMessage());
                }
                return connection;
        }
@@ -323,6 +353,7 @@ public class Heatmap {
                  }
                    catch(SQLException x) {
                        System.out.println("Couldn’t get connection!");
+                       System.err.println("SQLException: " + x.getMessage());
                    }
                    return null;
                  }