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;
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<Row> rows = results.all();
* 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) {
+ private String findJnetpred(Map<String, String> pred) {
if (pred != null) {
- if (pred.containsKey("jnetpred"))
+ if (pred.containsKey("jnetpred"))
return pred.get("jnetpred");
}
return null;
}
+
/*
* getting protein sequences by counter
*/
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
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
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");