From 58c9b97523e2273a316a947d977ca7ddd8b1356a Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Wed, 29 Jan 2014 08:03:26 +0000 Subject: [PATCH] Fi bug for wrong job selection --- datadb/compbio/cassandra/CassandraReaderOld.java | 21 +++++++++------------ server/compbio/statistic/CassandraRequester.java | 16 ++++++++-------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/datadb/compbio/cassandra/CassandraReaderOld.java b/datadb/compbio/cassandra/CassandraReaderOld.java index 6055e60..ccd13ed 100644 --- a/datadb/compbio/cassandra/CassandraReaderOld.java +++ b/datadb/compbio/cassandra/CassandraReaderOld.java @@ -207,27 +207,24 @@ 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) { diff --git a/server/compbio/statistic/CassandraRequester.java b/server/compbio/statistic/CassandraRequester.java index 1791c0f..1e2d00b 100755 --- a/server/compbio/statistic/CassandraRequester.java +++ b/server/compbio/statistic/CassandraRequester.java @@ -201,17 +201,17 @@ public class CassandraRequester { /* * query: protein feature */ + public Map readProteinsPrediction(String feature, int percent) { - Map result = db.ReadProtein(); - ; - if (result == null) + Map results = db.ReadProtein(); + if (results == null) return null; Map query = new HashMap(); - for (Map.Entry entry : result.entrySet()) { - String pred = entry.getValue(); - if (pred.replaceAll("[^" + feature + "]", "").length() > pred.length() * percent / 100 && (!entry.getKey().equals(""))) { - // if (!entry.getKey().equals("")) - query.put(entry.getKey(), pred); + for (Map.Entry entry : results.entrySet()) { + String prediction = entry.getValue(); + String protein = entry.getKey(); + if (prediction.replaceAll("[^" + feature + "]", "").length() > prediction.length() * percent / 100 && !protein.equals("")) { + query.put(protein, prediction); } } return query; -- 1.7.10.2