X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=datadb%2Fcompbio%2Fcassandra%2FCassandraReaderOld.java;h=f483dc1a7696e638586a5b065b8b7008f4901561;hb=9bb6ee99ca7f738fac1087190b5481b8fe6e8d9f;hp=f29bc9f3b9954f7b135b9615206084684ba5b206;hpb=23ef7a6a36233ee82656f6d0f602b82f009847ed;p=proteocache.git diff --git a/datadb/compbio/cassandra/CassandraReaderOld.java b/datadb/compbio/cassandra/CassandraReaderOld.java index f29bc9f..f483dc1 100644 --- a/datadb/compbio/cassandra/CassandraReaderOld.java +++ b/datadb/compbio/cassandra/CassandraReaderOld.java @@ -12,7 +12,12 @@ import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.ResultSet; +import compbio.beans.DateBean; +import compbio.beans.JobBean; +import compbio.beans.ProteinBean; +import compbio.beans.Total; import compbio.engine.JobStatus; +import compbio.engine.Pair; public class CassandraReaderOld { private Session session; @@ -119,7 +124,7 @@ public class CassandraReaderOld { String com = "SELECT JobID, Predictions FROM ProteinRow WHERE Protein = '" + queryProtein + "';"; System.out.println("Command: " + com); ResultSet results = session.execute(com); - if (results.isExhausted()) + if (results.isExhausted()) return null; final long queryTime = System.currentTimeMillis(); List rows = results.all(); @@ -202,36 +207,34 @@ public class CassandraReaderOld { * getting protein sequence from the db ProteinRow */ public Map ReadProtein() { - final long startTime = System.currentTimeMillis(); + //final long startTime = System.currentTimeMillis(); String com = "SELECT * FROM ProteinRow;"; System.out.println("Command: " + com); ResultSet results = session.execute(com); if (results.isExhausted()) return null; - final long queryTime = System.currentTimeMillis(); + //final long queryTime = System.currentTimeMillis(); List rows = results.all(); - System.out.println("Query time is " + (queryTime - startTime) + " msec"); - System.out.println(" rows analysed, " + rows.size()); - Map res = new HashMap(); - int c = 0; + Map output = new HashMap(); for (Row r : rows) { - String prot = r.getString("Protein"); + String protein = r.getString("Protein"); String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class)); - if (prot != null || prediction != null) - res.put(prot, prediction); + if (protein != null && prediction != null) { + output.put(protein, prediction); + } } - final long endTime = System.currentTimeMillis(); - System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec"); - return res; + //final long endTime = System.currentTimeMillis(); + return output; } - private String findJnetpred (Map pred) { + private String findJnetpred(Map pred) { if (pred != null) { - if (pred.containsKey("jnetpred")) + if (pred.containsKey("jnetpred")) return pred.get("jnetpred"); } return null; } + /* * getting protein sequences by counter */ @@ -250,7 +253,6 @@ public class CassandraReaderOld { int c = 0; for (Row r : rows) { String protein = r.getString("Protein"); - String id = r.getString("JobID"); if (res.containsKey(protein)) res.put(protein, res.get(protein) + 1); else @@ -279,7 +281,6 @@ public class CassandraReaderOld { int c = 0; for (Row r : rows) { String ip = r.getString("ip"); - String id = r.getString("JobID"); if (res.containsKey(ip)) res.put(ip, res.get(ip) + 1); else @@ -310,6 +311,12 @@ public class CassandraReaderOld { Row row1 = results1.one(); JobBean res = new JobBean(row.getString("Protein"), row.getString("JobID"), row.getString("DataBegin"), row.getString("DataEnd"), row.getString("ip"), row1.getMap("Predictions", String.class, String.class)); + String program = row.getString("ProgramName"); + String version = row.getString("ProgramVersion"); + if (null != program && null != version) { + res.setProgramName(program); + res.setProgramVersion(version); + } System.out.println("Query time is " + (queryTime - startTime) + " msec"); final long endTime = System.currentTimeMillis(); System.out.println(" rows analysed, execution time is " + (endTime - startTime) + " msec");