Fi bug for wrong job selection
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Wed, 29 Jan 2014 08:03:26 +0000 (08:03 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Wed, 29 Jan 2014 08:03:26 +0000 (08:03 +0000)
datadb/compbio/cassandra/CassandraReaderOld.java
server/compbio/statistic/CassandraRequester.java

index 6055e60..ccd13ed 100644 (file)
@@ -207,27 +207,24 @@ public class CassandraReaderOld {
         * getting protein sequence from the db ProteinRow
         */
        public Map<String, String> 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<Row> rows = results.all();
-               System.out.println("Query time is " + (queryTime - startTime) + " msec");
-               System.out.println(" rows analysed,  " + rows.size());
-               Map<String, String> res = new HashMap<String, String>();
-               int c = 0;
+               Map<String, String> output = new HashMap<String, String>();
                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<String, String> pred) {
index 1791c0f..1e2d00b 100755 (executable)
@@ -201,17 +201,17 @@ public class CassandraRequester {
        /*
         * query: protein feature
         */
+
        public Map<String, String> readProteinsPrediction(String feature, int percent) {
-               Map<String, String> result = db.ReadProtein();
-               ;
-               if (result == null)
+               Map<String, String> results = db.ReadProtein();
+               if (results == null)
                        return null;
                Map<String, String> query = new HashMap<String, String>();
-               for (Map.Entry<String, String> 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<String, String> 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;