* 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) {
/*
* 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;