import java.util.Map;
import compbio.cassandra.CassandraNativeConnector;
+import compbio.cassandra.CassandraReader;
import compbio.cassandra.DataBase;
import compbio.cassandra.Pair;
+import compbio.cassandra.StructureJobLog;
import compbio.cassandra.StructureProteinPrediction;
public class CassandraRequester {
- private CassandraNativeConnector DBInstance = new CassandraNativeConnector();
+ private CassandraReader db = new CassandraReader();
private ArrayList<DataBase> query;
private static long currentDate = 0;
private static long earlestDate = 0;
List<Integer> totalTime = new ArrayList<Integer>();
for (int i = 0; i < nbins; i++)
totalTime.add(i, 0);
- List<Pair<String, String>> res = DBInstance.ReadProteinDataTable();
+ List<Pair<String, String>> res = db.ReadProteinDataTable();
List<Pair<Date, Long>> numres = new ArrayList<Pair<Date, Long>>();
for (Pair<String, String> entry : res) {
end.setTime(new Date(dateEnd));
query = new ArrayList<DataBase>();
for (Date date = start.getTime(); !start.after(end); start.add(Calendar.DATE, 1), date = start.getTime()) {
- Integer res = DBInstance.ReadDateTable(date.getTime());
+ Integer res = db.ReadDateTable(date.getTime());
if (res == null)
continue;
DataBase db = new DataBase();
db.setTotal(res);
db.setDate(DateFormat(date.getTime()));
query.add(db);
- }
+ }
System.out.println("StatisticsProt.readLength: total number of dates = " + query.size());
return query;
}
query = new ArrayList<DataBase>();
List<StructureProteinPrediction> res;
if (flag.equals("whole"))
- res = DBInstance.ReadWholeSequence(protIn);
+ res = db.ReadWholeSequence(protIn);
else
- res = DBInstance.ReadPartOfSequence(protIn);
+ res = db.ReadPartOfSequence(protIn);
for (StructureProteinPrediction entry : res) {
Map<String,String> pred = entry.getPrediction();
Iterator it = pred.entrySet().iterator();
* */
public List<DataBase> readProteinByCounter(int counter) {
query = new ArrayList<DataBase>();
- // List<Pair<String, String>> res = DBInstance.ReadProteinDataByCounter(counter);
-
+ Map<String, Integer> map = db.ReadProteinDataByCounter();
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
+ if (entry.getValue() > counter) {
+ DataBase db = new DataBase();
+ db.setTotalId(entry.getValue());
+ db.setProt(entry.getKey());
+ query.add(db);
+ }
+ }
return query;
}
-
+ /*
+ * query jobs log info
+ */
+ public DataBase readJobLog(String jobid) {
+ // query = new ArrayList<DataBase>();
+ StructureJobLog res = db.ReadJobLog(jobid);
+ DataBase query = new DataBase();
+ query.setLogInfo(res);
+ // query.setres);
+ return query;
+ }
+ /*
+ * create list of parts of protein sequence;
+ */
private static List<String> CreateSubprot (String protein, String subprot) {
List<String> sub = new ArrayList<String>();
String subStr = protein;
* find the earliest date in the database
*/
public long earliestDate() {
- earlestDate = DBInstance.getEarliestDateInDB();
+ earlestDate = CassandraNativeConnector.getEarliestDateInDB();
return earlestDate;
}