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 {
}
/*
+ * 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() {