created features report
[proteocache.git] / datadb / compbio / cassandra / CassandraReader.java
index 00a9f27..1720c48 100644 (file)
@@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.ResultSet;
+
 import compbio.engine.JobStatus;
 
 public class CassandraReader {
@@ -198,6 +199,40 @@ public class CassandraReader {
        }
 
        /*
+        * getting protein sequence from the db ProteinRow
+        */
+       public Map<String, String> ReadProtein() {
+               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();
+               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;
+               for (Row r : rows) {
+                       String prot = r.getString("Protein");
+                       String prediction = findJnetpred(r.getMap("Predictions", String.class, String.class));
+                       if (prot != null || prediction != null) 
+                               res.put(prot, prediction);
+               }
+               final long endTime = System.currentTimeMillis();
+               System.out.println(c + " rows analysed, execution time is " + (endTime - startTime) + " msec");
+               return res;
+       }
+
+       private String findJnetpred (Map<String,String> pred) {
+               if (pred != null) {
+                       if (pred.containsKey("jnetpred")) 
+                               return pred.get("jnetpred");
+               }
+               return null;
+       }
+       /*
         * getting protein sequences by counter
         */
        public Map<String, Integer> ReadProteinSequenceByCounter() {